Log4phpLogger.php
1 <?php
2 /**
3  * wCMF - wemove Content Management Framework
4  * Copyright (C) 2005-2020 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;
15 
16 /**
17  * Log4phpLogger is a wrapper for the log4php library.
18  *
19  * @author ingo herwig <ingo@wemove.com>
20  */
22 
23  private static $initialized = false;
24 
25  private $log4phpLogger = null;
26 
27  /**
28  * Constructor
29  */
30  public function __construct($name, $configFile='') {
31  if (!self::$initialized) {
32  Logger::configure($configFile);
33  self::$initialized = true;
34  }
35  $name = str_replace('\\', '.', $name);
36  $this->log4phpLogger = Logger::getLogger($name);
37  }
38 
39  /**
40  * @see Logger::trace()
41  */
42  public function trace($message) {
43  $this->log4phpLogger->trace($message);
44  }
45 
46  /**
47  * @see Logger::debug()
48  */
49  public function debug($message) {
50  $this->log4phpLogger->debug($message);
51  }
52 
53  /**
54  * @see Logger::info()
55  */
56  public function info($message) {
57  $this->log4phpLogger->info($message);
58  }
59 
60  /**
61  * @see Logger::warn()
62  */
63  public function warn($message) {
64  $this->log4phpLogger->warn($message);
65  }
66 
67  /**
68  * @see Logger::error()
69  */
70  public function error($message) {
71  $this->log4phpLogger->error($message);
72  }
73 
74  /**
75  * @see Logger::fatal()
76  */
77  public function fatal($message) {
78  $this->log4phpLogger->fatal($message);
79  }
80 
81  /**
82  * @see Logger::isDebugEnabled()
83  */
84  public function isDebugEnabled() {
85  return $this->log4phpLogger->isDebugEnabled();
86  }
87 
88  /**
89  * @see Logger::isInfoEnabled()
90  */
91  public function isInfoEnabled() {
92  return $this->log4phpLogger->isInfoEnabled();
93  }
94 
95  /**
96  * @see Logger::isWarnEnabled()
97  */
98  public function isWarnEnabled() {
99  return $this->log4phpLogger->isWarnEnabled();
100  }
101 
102  /**
103  * @see Logger::isErrorEnabled()
104  */
105  public function isErrorEnabled() {
106  return $this->log4phpLogger->isErrorEnabled();
107  }
108 
109  /**
110  * @see Logger::isFatalEnabled()
111  */
112  public function isFatalEnabled() {
113  return $this->log4phpLogger->isFatalEnabled();
114  }
115 
116  /**
117  * @see Logger::getLogger()
118  */
119  public static function getLogger($name) {
120  return new Log4phpLogger($name);
121  }
122 }
123 ?>
__construct($name, $configFile='')
Constructor.
Log4phpLogger is a wrapper for the log4php library.
static getLogger($name)
Get a Logger instance by name.
AbstractLogger is the abstract base class for Logger implementations.
Interface for logger implementations.
Definition: Logger.php:18