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

/trunk/rucrm/log4php.debug/appenders/LoggerAppenderPhp.php

https://code.google.com/p/vtiger-ru-fork/
PHP | 85 lines | 36 code | 8 blank | 41 comment | 4 complexity | 3dd47e963bd396f814e90d5af6e92bf5 MD5 | raw file
Possible License(s): LGPL-2.1, MPL-2.0-no-copyleft-exception, GPL-2.0, LGPL-3.0
  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. * @subpackage appenders
  18. */
  19. /**
  20. * @ignore
  21. */
  22. if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__) . '/..');
  23. require_once(LOG4PHP_DIR . '/LoggerAppenderSkeleton.php');
  24. require_once(LOG4PHP_DIR . '/LoggerLevel.php');
  25. require_once(LOG4PHP_DIR . '/LoggerLog.php');
  26. /**
  27. * Log events using php {@link PHP_MANUAL#trigger_error} function and a {@link LoggerLayoutTTCC} default layout.
  28. *
  29. * <p>Levels are mapped as follows:</p>
  30. * - <b>level &lt; WARN</b> mapped to E_USER_NOTICE
  31. * - <b>WARN &lt;= level &lt; ERROR</b> mapped to E_USER_WARNING
  32. * - <b>level &gt;= ERROR</b> mapped to E_USER_ERROR
  33. *
  34. * @author VxR <vxr@vxr.it>
  35. * @version $Revision: 1.11 $
  36. * @package log4php
  37. * @subpackage appenders
  38. */
  39. class LoggerAppenderPhp extends LoggerAppenderSkeleton {
  40. /**
  41. * @access private
  42. */
  43. var $requiresLayout = false;
  44. /**
  45. * Constructor
  46. *
  47. * @param string $name appender name
  48. */
  49. function LoggerAppenderPhp($name)
  50. {
  51. $this->LoggerAppenderSkeleton($name);
  52. }
  53. function activateOptions()
  54. {
  55. $this->layout = LoggerLayout::factory('LoggerLayoutTTCC');
  56. $this->closed = false;
  57. }
  58. function close()
  59. {
  60. $this->closed = true;
  61. }
  62. function append($event)
  63. {
  64. if ($this->layout !== null) {
  65. LoggerLog::debug("LoggerAppenderPhp::append()");
  66. $level = $event->getLevel();
  67. if ($level->isGreaterOrEqual(LoggerLevel::getLevelError())) {
  68. trigger_error($this->layout->format($event), E_USER_ERROR);
  69. } elseif ($level->isGreaterOrEqual(LoggerLevel::getLevelWarn())) {
  70. trigger_error($this->layout->format($event), E_USER_WARNING);
  71. } else {
  72. trigger_error($this->layout->format($event), E_USER_NOTICE);
  73. }
  74. }
  75. }
  76. }
  77. ?>