PageRenderTime 36ms CodeModel.GetById 9ms RepoModel.GetById 0ms app.codeStats 0ms

/administrator/components/com_virtuemart/classes/Log/observer.php

https://bitbucket.org/dgough/annamaria-daneswood-25102012
PHP | 154 lines | 42 code | 12 blank | 100 comment | 8 complexity | da36ca769906f054d0659272ff760292 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1
  1. <?php
  2. if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );
  3. /**
  4. *
  5. * @version $Id: observer.php 1336 2008-03-31 17:06:23Z soeren_nb $
  6. * @package VirtueMart
  7. * @subpackage Log
  8. * @copyright Copyright (C) 2004-2008 soeren - All rights reserved.
  9. * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
  10. * VirtueMart is free software. This version may have been modified pursuant
  11. * to the GNU General Public License, and as distributed it includes or
  12. * is derivative of works licensed under the GNU General Public License or
  13. * other free or open source software licenses.
  14. * See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details.
  15. *
  16. * http://virtuemart.net
  17. */
  18. /**
  19. * $Header$
  20. * $Horde: horde/lib/Log/observer.php,v 1.5 2000/06/28 21:36:13 jon Exp $
  21. *
  22. * @version $Revision: 1336 $
  23. * @package Log
  24. */
  25. /**
  26. * The vmLog_observer:: class implements the Observer end of a Subject-Observer
  27. * pattern for watching log activity and taking actions on exceptional events.
  28. *
  29. * @author Chuck Hagenbuch <chuck@horde.org>
  30. * @since Horde 1.3
  31. * @since Log 1.0
  32. * @package Log
  33. *
  34. * @example observer_mail.php An example vmLog_observer implementation.
  35. */
  36. class vmLog_observer
  37. {
  38. /**
  39. * Instance-specific unique identification number.
  40. *
  41. * @var integer
  42. * @access private
  43. */
  44. var $_id = 0;
  45. /**
  46. * The minimum priority level of message that we want to hear about.
  47. * PEAR_LOG_EMERG is the highest priority, so we will only hear messages
  48. * with an integer priority value less than or equal to ours. It defaults
  49. * to PEAR_LOG_INFO, which listens to everything except PEAR_LOG_DEBUG.
  50. *
  51. * @var string
  52. * @access private
  53. */
  54. var $_priority = PEAR_LOG_INFO;
  55. /**
  56. * Creates a new basic vmLog_observer instance.
  57. *
  58. * @param integer $priority The highest priority at which to receive
  59. * log event notifications.
  60. *
  61. * @access public
  62. */
  63. function vmLog_observer($priority = PEAR_LOG_INFO)
  64. {
  65. $this->_id = md5(microtime());
  66. $this->_priority = $priority;
  67. }
  68. /**
  69. * Attempts to return a new concrete vmLog_observer instance of the requested
  70. * type.
  71. *
  72. * @param string $type The type of concreate vmLog_observer subclass
  73. * to return.
  74. * @param integer $priority The highest priority at which to receive
  75. * log event notifications.
  76. * @param array $conf Optional associative array of additional
  77. * configuration values.
  78. *
  79. * @return object The newly created concrete vmLog_observer
  80. * instance, or an false on an error.
  81. */
  82. function &factory($type, $priority = PEAR_LOG_INFO, $conf = array())
  83. {
  84. $type = strtolower($type);
  85. $class = 'vmLog_observer_' . $type;
  86. /* Support both the new-style and old-style file naming conventions. */
  87. if (file_exists(dirname(__FILE__) . '/observer_' . $type . '.php')) {
  88. $classfile = 'Log/observer_' . $type . '.php';
  89. $newstyle = true;
  90. } else {
  91. $classfile = 'Log/' . $type . '.php';
  92. $newstyle = false;
  93. }
  94. /* Issue a warning if the old-style conventions are being used. */
  95. if (!$newstyle)
  96. {
  97. trigger_error('Using old-style vmLog_observer conventions',
  98. E_USER_WARNING);
  99. }
  100. /*
  101. * Attempt to include our version of the named class, but don't treat
  102. * a failure as fatal. The caller may have already included their own
  103. * version of the named class.
  104. */
  105. @include_once $classfile;
  106. /* If the class exists, return a new instance of it. */
  107. if (class_exists($class)) {
  108. /* Support both new-style and old-style construction. */
  109. if ($newstyle) {
  110. return new $class($priority, $conf);
  111. } else {
  112. return new $class($priority);
  113. }
  114. }
  115. return false;
  116. }
  117. /**
  118. <<<<<<< observer.php
  119. * This is a stub method to make sure that vmLog_observer classes do
  120. * something when they are notified of a message. The default
  121. * behavior is to just print the message, which is obviously not
  122. * desireable in practically any situation - which is why you need
  123. * to override this method. :)
  124. *
  125. * @param array $messageOb A hash containing all information - the text
  126. * message itself, the priority, what log it came
  127. * from, etc.
  128. =======
  129. * This is a stub method to make sure that vmLog_observer classes do
  130. * something when they are notified of a message. The default behavior
  131. * is to just print the message, which is obviously not desireable in
  132. * practically any situation - which is why you need to override this
  133. * method. :)
  134. *
  135. * @param array $event A hash describing the log event.
  136. >>>>>>> 1.5
  137. */
  138. function notify($event)
  139. {
  140. print_r($event);
  141. }
  142. }