Blame view

sources/3rdparty/phpdocx/classes/PhpdocxLogger.inc 1.38 KB
31b7f2792   Kload   Upgrade to ownclo...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
  <?php
  
  /**
   * Logger
   *
   * @category   Phpdocx
   * @package    logger
   * @copyright  Copyright (c) Narcea Producciones Multimedia S.L.
   *             (http://www.2mdc.com)
   * @license    LGPL
   * @version    3.0
   * @link       http://www.phpdocx.com
   * @since      File available since Release 3.0
   */
  
  class PhpdocxLogger
  {
      /**
       *
       * @access private
       * @static
       * @var string
       */
      private static $_log = NULL;
  
      /**
       * Singleton, return instance of class
       *
       * @access public
       * @param $message Message to send to logging framework
       * @param $level Allowed values: trace, debug, info, warn, error, fatal
       * @static
       */
      public static function logger($message, $level)
      {
          $levels = array(
              'debug', 
              'info', 
              'notice', 
              'warning', 
              'error', 
              'fatal',
          );
  
          if (!self::$_log) {
              Logger::configure(dirname(__FILE__) . '/../config/log4php.xml');
              self::$_log = Logger::getLogger('phpdocx_logger');
          }
  
          // only some levels are valid
          if (in_array($level, $levels)) {
              $stringLevel = strtolower($level);
              self::$_log->info($message);
  
              // stop phpdocx if fatal level
              if ($level == 'fatal') {
                  throw new Exception($message);
              }
          }
      }
  }