PageRenderTime 43ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/SyracavaPHP/syracava/ext/log4php/LoggerLog.php

http://syracava.googlecode.com/
PHP | 99 lines | 29 code | 9 blank | 61 comment | 3 complexity | 98d89cbbdb9ee344906930a8bc1d7ba8 MD5 | raw file
Possible License(s): Apache-2.0, LGPL-2.0, LGPL-2.1
  1. <?php
  2. /**
  3. * log4php is a PHP port of the log4j java logging package.
  4. *
  5. * <p>This framework is based on log4j (see {@link http://jakarta.apache.org/log4j log4j} for details).</p>
  6. * <p>Design, strategies and part of the methods documentation are developed by log4j team
  7. * (Ceki Gülcü as log4j project founder and
  8. * {@link http://jakarta.apache.org/log4j/docs/contributors.html contributors}).</p>
  9. *
  10. * <p>PHP port, extensions and modifications by VxR. All rights reserved.<br>
  11. * For more information, please see {@link http://www.vxr.it/log4php/}.</p>
  12. *
  13. * <p>This software is published under the terms of the LGPL License
  14. * a copy of which has been included with this distribution in the LICENSE file.</p>
  15. *
  16. * @package log4php
  17. */
  18. /**
  19. * @ignore
  20. */
  21. if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__));
  22. /**
  23. * Helper class for internal logging
  24. *
  25. * <p>It uses php {@link PHP_MANUAL#trigger_error trigger_error()} function
  26. * to output messages.</p>
  27. * <p>You need to recode methods to output messages in a different way.</p>
  28. *
  29. * @author VxR <vxr@vxr.it>
  30. * @version $Revision: 125 $
  31. * @package log4php
  32. */
  33. class LoggerLog {
  34. /**
  35. * Log if debug is enabled.
  36. *
  37. * Log using php {@link PHP_MANUAL#trigger_error trigger_error()} function
  38. * with E_USER_NOTICE level by default.
  39. *
  40. * @param string $message log message
  41. * @param integer $errLevel level to log
  42. * @static
  43. */
  44. function log($message, $errLevel = E_USER_NOTICE)
  45. {
  46. if (LoggerLog::internalDebugging())
  47. trigger_error($message, $errLevel);
  48. }
  49. function internalDebugging($value = null)
  50. {
  51. static $debug = false;
  52. if (is_bool($value))
  53. $debug = $value;
  54. return $debug;
  55. }
  56. /**
  57. * Report a debug message.
  58. *
  59. * @param string $message log message
  60. * @static
  61. * @since 0.3
  62. */
  63. function debug($message)
  64. {
  65. LoggerLog::log($message, E_USER_NOTICE);
  66. }
  67. /**
  68. * Report an error message.
  69. *
  70. * @param string $message log message
  71. * @static
  72. * @since 0.3
  73. */
  74. function error($message)
  75. {
  76. trigger_error($message, E_USER_ERROR);
  77. }
  78. /**
  79. * Report a warning message.
  80. *
  81. * @param string $message log message
  82. * @static
  83. * @since 0.3
  84. */
  85. function warn($message)
  86. {
  87. trigger_error($message, E_USER_WARNING);
  88. }
  89. }
  90. ?>