Log4phpLogger.php
1 <?php
2 /**
3  * wCMF - wemove Content Management Framework
4  * Copyright (C) 2005-2015 wemove digital solutions GmbH
5  *
6  * Licensed under the terms of the MIT License.
7  *
8  * See the LICENSE file distributed with this work for
9  * additional information.
10  */
11 namespace wcmf\lib\core\impl;
12 
13 use \Logger;
14 
15 /**
16  * Log4phpLogger is a wrapper for the log4php library.
17  *
18  * @author ingo herwig <ingo@wemove.com>
19  */
21 
22  private static $_initialized = false;
23 
24  private $_log4phpLogger = null;
25 
26  /**
27  * Constructor
28  */
29  public function __construct($name, $configFile='') {
30  if (!self::$_initialized) {
31  Logger::configure($configFile);
32  self::$_initialized = true;
33  }
34  $name = str_replace('\\', '.', $name);
35  $this->_log4phpLogger = Logger::getLogger($name);
36  }
37 
38  /**
39  * @see Logger::trace()
40  */
41  public function trace($message) {
42  $this->_log4phpLogger->trace($message);
43  }
44 
45  /**
46  * @see Logger::debug()
47  */
48  public function debug($message) {
49  $this->_log4phpLogger->debug($message);
50  }
51 
52  /**
53  * @see Logger::info()
54  */
55  public function info($message) {
56  $this->_log4phpLogger->info($message);
57  }
58 
59  /**
60  * @see Logger::warn()
61  */
62  public function warn($message) {
63  $this->_log4phpLogger->warn($message);
64  }
65 
66  /**
67  * @see Logger::error()
68  */
69  public function error($message) {
70  $this->_log4phpLogger->error($message);
71  }
72 
73  /**
74  * @see Logger::fatal()
75  */
76  public function fatal($message) {
77  $this->_log4phpLogger->fatal($message);
78  }
79 
80  /**
81  * @see Logger::isDebugEnabled()
82  */
83  public function isDebugEnabled() {
84  return $this->_log4phpLogger->isDebugEnabled();
85  }
86 
87  /**
88  * @see Logger::isInfoEnabled()
89  */
90  public function isInfoEnabled() {
91  return $this->_log4phpLogger->isInfoEnabled();
92  }
93 
94  /**
95  * @see Logger::isWarnEnabled()
96  */
97  public function isWarnEnabled() {
98  return $this->_log4phpLogger->isWarnEnabled();
99  }
100 
101  /**
102  * @see Logger::isErrorEnabled()
103  */
104  public function isErrorEnabled() {
105  return $this->_log4phpLogger->isErrorEnabled();
106  }
107 
108  /**
109  * @see Logger::isFatalEnabled()
110  */
111  public function isFatalEnabled() {
112  return $this->_log4phpLogger->isFatalEnabled();
113  }
114 
115  /**
116  * @see Logger::getLogger()
117  */
118  public static function getLogger($name) {
119  return new Log4phpLogger($name);
120  }
121 }
122 ?>
Interface for logger implementations.
Definition: Logger.php:18
Log4phpLogger is a wrapper for the log4php library.
static getLogger($name)
Get a Logger instance by name.
__construct($name, $configFile='')
Constructor.