PageRenderTime 45ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/apps/lib/PEAR/Log/error_log.php

https://github.com/MasahiroOzeki/web_crawler
PHP | 100 lines | 33 code | 11 blank | 56 comment | 3 complexity | 24994796d6ca7b2c0d40ddc5cf235374 MD5 | raw file
  1. <?php
  2. /**
  3. * $Header: /repository/pear/Log/Log/error_log.php,v 1.5 2004/01/02 02:03:40 jon Exp $
  4. *
  5. * @version $Revision: 1.5 $
  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. * The default is PEAR_LOG_INFO.
  72. * @return boolean True on success or false on failure.
  73. * @access public
  74. */
  75. function log($message, $priority = PEAR_LOG_INFO)
  76. {
  77. /* Abort early if the priority is above the maximum logging level. */
  78. if (!$this->_isMasked($priority)) {
  79. return false;
  80. }
  81. /* Extract the string representation of the message. */
  82. $message = $this->_extractMessage($message);
  83. $success = error_log($this->_ident . ': ' . $message, $this->_type,
  84. $this->_destination, $this->_extra_headers);
  85. $this->_announce(array('priority' => $priority, 'message' => $message));
  86. return $success;
  87. }
  88. }
  89. ?>