Automatically exported from code.google.com/p/planningalerts
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

error_log.php 3.1 KiB

před 17 roky
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php
  2. /**
  3. * $Header: /home/ppcvs/paypal_php_sdk/Log/error_log.php,v 1.1 2006/02/19 08:22:29 dennis Exp $
  4. *
  5. * @version $Revision: 1.1 $
  6. * @package Log
  7. */
  8. /**
  9. * The Log_error_log class is a concrete implementation of the Log abstract
  10. * class that logs messages using PHP's error_log() function.
  11. *
  12. * @author Jon Parise <jon@php.net>
  13. * @since Log 1.7.0
  14. * @package Log
  15. *
  16. * @example error_log.php Using the error_log handler.
  17. */
  18. class Log_error_log extends Log
  19. {
  20. /**
  21. * The error_log() log type.
  22. * @var integer
  23. * @access private
  24. */
  25. var $_type = PEAR_LOG_TYPE_SYSTEM;
  26. /**
  27. * The type-specific destination value.
  28. * @var string
  29. * @access private
  30. */
  31. var $_destination = '';
  32. /**
  33. * Additional headers to pass to the mail() function when the
  34. * PEAR_LOG_TYPE_MAIL type is used.
  35. * @var string
  36. * @access private
  37. */
  38. var $_extra_headers = '';
  39. /**
  40. * Constructs a new Log_error_log object.
  41. *
  42. * @param string $name Ignored.
  43. * @param string $ident The identity string.
  44. * @param array $conf The configuration array.
  45. * @param int $level Log messages up to and including this level.
  46. * @access public
  47. */
  48. function Log_error_log($name, $ident = '', $conf = array(),
  49. $level = PEAR_LOG_DEBUG)
  50. {
  51. $this->_id = md5(microtime());
  52. $this->_type = $name;
  53. $this->_ident = $ident;
  54. $this->_mask = Log::UPTO($level);
  55. if (!empty($conf['destination'])) {
  56. $this->_destination = $conf['destination'];
  57. }
  58. if (!empty($conf['extra_headers'])) {
  59. $this->_extra_headers = $conf['extra_headers'];
  60. }
  61. }
  62. /**
  63. * Logs $message using PHP's error_log() function. The message is also
  64. * passed along to any Log_observer instances that are observing this Log.
  65. *
  66. * @param mixed $message String or object containing the message to log.
  67. * @param string $priority The priority of the message. Valid
  68. * values are: PEAR_LOG_EMERG, PEAR_LOG_ALERT,
  69. * PEAR_LOG_CRIT, PEAR_LOG_ERR, PEAR_LOG_WARNING,
  70. * PEAR_LOG_NOTICE, PEAR_LOG_INFO, and PEAR_LOG_DEBUG.
  71. * @return boolean True on success or false on failure.
  72. * @access public
  73. */
  74. function log($message, $priority = null)
  75. {
  76. /* If a priority hasn't been specified, use the default value. */
  77. if ($priority === null) {
  78. $priority = $this->_priority;
  79. }
  80. /* Abort early if the priority is above the maximum logging level. */
  81. if (!$this->_isMasked($priority)) {
  82. return false;
  83. }
  84. /* Extract the string representation of the message. */
  85. $message = $this->_extractMessage($message);
  86. $success = error_log($this->_ident . ': ' . $message, $this->_type,
  87. $this->_destination, $this->_extra_headers);
  88. $this->_announce(array('priority' => $priority, 'message' => $message));
  89. return $success;
  90. }
  91. }