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

/pacore/ext/Log/error_log.php

https://github.com/DigitalCityMechanics/PeopleAggregator
PHP | 115 lines | 37 code | 12 blank | 66 comment | 4 complexity | 60a2540d1756cd5d96cf8ea7999cba5a MD5 | raw file
Possible License(s): BSD-3-Clause, MIT, LGPL-2.1
  1. <?php
  2. /** !
  3. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  4. * [filename] is a part of PeopleAggregator.
  5. * [description including history]
  6. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  7. * @author [creator, or "Original Author"]
  8. * @license http://bit.ly/aVWqRV PayAsYouGo License
  9. * @copyright Copyright (c) 2010 Broadband Mechanics
  10. * @package PeopleAggregator
  11. */
  12. ?>
  13. <?php
  14. /**
  15. * $Header: /repository/pear/Log/Log/error_log.php,v 1.7 2005/02/26 14:48:58 chagenbu Exp $
  16. *
  17. * @version $Revision: 1.7 $
  18. * @package Log
  19. */
  20. /**
  21. * The Log_error_log class is a concrete implementation of the Log abstract
  22. * class that logs messages using PHP's error_log() function.
  23. *
  24. * @author Jon Parise <jon@php.net>
  25. * @since Log 1.7.0
  26. * @package Log
  27. *
  28. * @example error_log.php Using the error_log handler.
  29. */
  30. class Log_error_log extends Log
  31. {
  32. /**
  33. * The error_log() log type.
  34. * @var integer
  35. * @access private
  36. */
  37. var $_type = PEAR_LOG_TYPE_SYSTEM;
  38. /**
  39. * The type-specific destination value.
  40. * @var string
  41. * @access private
  42. */
  43. var $_destination = '';
  44. /**
  45. * Additional headers to pass to the mail() function when the
  46. * PEAR_LOG_TYPE_MAIL type is used.
  47. * @var string
  48. * @access private
  49. */
  50. var $_extra_headers = '';
  51. /**
  52. * Constructs a new Log_error_log object.
  53. *
  54. * @param string $name Ignored.
  55. * @param string $ident The identity string.
  56. * @param array $conf The configuration array.
  57. * @param int $level Log messages up to and including this level.
  58. * @access public
  59. */
  60. function Log_error_log($name, $ident = '', $conf = array(),
  61. $level = PEAR_LOG_DEBUG)
  62. {
  63. $this->_id = md5(microtime());
  64. $this->_type = $name;
  65. $this->_ident = $ident;
  66. $this->_mask = Log::UPTO($level);
  67. if (!empty($conf['destination'])) {
  68. $this->_destination = $conf['destination'];
  69. }
  70. if (!empty($conf['extra_headers'])) {
  71. $this->_extra_headers = $conf['extra_headers'];
  72. }
  73. }
  74. /**
  75. * Logs $message using PHP's error_log() function. The message is also
  76. * passed along to any Log_observer instances that are observing this Log.
  77. *
  78. * @param mixed $message String or object containing the message to log.
  79. * @param string $priority The priority of the message. Valid
  80. * values are: PEAR_LOG_EMERG, PEAR_LOG_ALERT,
  81. * PEAR_LOG_CRIT, PEAR_LOG_ERR, PEAR_LOG_WARNING,
  82. * PEAR_LOG_NOTICE, PEAR_LOG_INFO, and PEAR_LOG_DEBUG.
  83. * @return boolean True on success or false on failure.
  84. * @access public
  85. */
  86. function log($message, $priority = null)
  87. {
  88. /* If a priority hasn't been specified, use the default value. */
  89. if ($priority === null) {
  90. $priority = $this->_priority;
  91. }
  92. /* Abort early if the priority is above the maximum logging level. */
  93. if (!$this->_isMasked($priority)) {
  94. return false;
  95. }
  96. /* Extract the string representation of the message. */
  97. $message = $this->_extractMessage($message);
  98. $success = error_log($this->_ident . ': ' . $message, $this->_type,
  99. $this->_destination, $this->_extra_headers);
  100. $this->_announce(array('priority' => $priority, 'message' => $message));
  101. return $success;
  102. }
  103. }