PageRenderTime 42ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/php/Log/null.php

https://bitbucket.org/adarshj/convenient_website
PHP | 68 lines | 23 code | 6 blank | 39 comment | 2 complexity | 4069cc1c274eb4865ef2ee8ff9df7eb7 MD5 | raw file
Possible License(s): Apache-2.0, MPL-2.0-no-copyleft-exception, LGPL-2.1, BSD-2-Clause, GPL-2.0, LGPL-3.0
  1. <?php
  2. /**
  3. * $Header: /repository/pear/Log/Log/null.php,v 1.3 2004/01/19 08:02:40 jon Exp $
  4. *
  5. * @version $Revision: 1.3 $
  6. * @package Log
  7. */
  8. /**
  9. * The Log_null class is a concrete implementation of the Log:: abstract
  10. * class. It simply consumes log events.
  11. *
  12. * @author Jon Parise <jon@php.net>
  13. * @since Log 1.8.2
  14. * @package Log
  15. *
  16. * @example null.php Using the null handler.
  17. */
  18. class Log_null extends Log
  19. {
  20. /**
  21. * Constructs a new Log_null object.
  22. *
  23. * @param string $name Ignored.
  24. * @param string $ident The identity string.
  25. * @param array $conf The configuration array.
  26. * @param int $level Log messages up to and including this level.
  27. * @access public
  28. */
  29. function Log_null($name, $ident = '', $conf = array(),
  30. $level = PEAR_LOG_DEBUG)
  31. {
  32. $this->_id = md5(microtime());
  33. $this->_ident = $ident;
  34. $this->_mask = Log::UPTO($level);
  35. }
  36. /**
  37. * Simply consumes the log event. The message will still be passed
  38. * along to any Log_observer instances that are observing this Log.
  39. *
  40. * @param mixed $message String or object containing the message to log.
  41. * @param string $priority The priority of the message. Valid
  42. * values are: PEAR_LOG_EMERG, PEAR_LOG_ALERT,
  43. * PEAR_LOG_CRIT, PEAR_LOG_ERR, PEAR_LOG_WARNING,
  44. * PEAR_LOG_NOTICE, PEAR_LOG_INFO, and PEAR_LOG_DEBUG.
  45. * @return boolean True on success or false on failure.
  46. * @access public
  47. */
  48. function log($message, $priority = null)
  49. {
  50. /* If a priority hasn't been specified, use the default value. */
  51. if ($priority === null) {
  52. $priority = $this->_priority;
  53. }
  54. /* Abort early if the priority is above the maximum logging level. */
  55. if (!$this->_isMasked($priority)) {
  56. return false;
  57. }
  58. $this->_announce(array('priority' => $priority, 'message' => $message));
  59. return true;
  60. }
  61. }
  62. ?>