ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilLogger.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once './libs/composer/vendor/autoload.php';
5 include_once __DIR__.'/public/class.ilLogLevel.php';
6 
7 
10 
11 
20 abstract class ilLogger
21 {
22  private $logger = null;
23 
24  public function __construct(Logger $logger)
25  {
26  $this->logger = $logger;
27  }
28 
34  public function isHandling($a_level)
35  {
36  return $this->getLogger()->isHandling($a_level);
37  }
38 
39  public function log($a_message, $a_level = ilLogLevel::INFO)
40  {
41  return $this->getLogger()->log($a_level, $a_message);
42  }
43 
44  public function dump($a_variable, $a_level = ilLogLevel::INFO)
45  {
46  return $this->log(print_r($a_variable,TRUE), $a_level);
47  }
48 
49  public function debug($a_message, $a_context = array())
50  {
51  return $this->getLogger()->debug($a_message,$a_context);
52  }
53 
54  public function info($a_message)
55  {
56  return $this->getLogger()->info($a_message);
57  }
58 
59  public function notice($a_message)
60  {
61  return $this->getLogger()->notice($a_message);
62  }
63 
64  public function warning($a_message)
65  {
66  return $this->getLogger()->warning($a_message);
67  }
68 
69  public function error($a_message)
70  {
71  return $this->getLogger()->error($a_message);
72  }
73 
74  public function critical($a_message)
75  {
76  $this->getLogger()->critical($a_message);
77  }
78 
79  public function alert($a_message)
80  {
81  return $this->getLogger()->alert($a_message);
82  }
83 
84 
85  public function emergency($a_message)
86  {
87  return $this->getLogger()->emergency($a_message);
88  }
89 
94  public function getLogger()
95  {
96  return $this->logger;
97  }
98 
104  public function write($a_message, $a_level = ilLogLevel::INFO)
105  {
106  include_once './Services/Logging/classes/public/class.ilLogLevel.php';
107  if(!in_array($a_level, ilLogLevel::getLevels()))
108  {
109  $a_level = ilLogLevel::INFO;
110  }
111 
112  $this->getLogger()->log($a_level, $a_message);
113  }
114 
119  public function writeLanguageLog($a_topic, $a_lang_key)
120  {
121  $this->getLogger()->debug("Language (".$a_lang_key."): topic -".$a_topic."- not present");
122  }
123 
130  public function logStack($a_level = null, $a_message = '')
131  {
132  if(is_null($a_level))
133  {
134  $a_level = ilLogLevel::INFO;
135  }
136 
137  include_once './Services/Logging/classes/public/class.ilLogLevel.php';
138  if(!in_array($a_level, ilLogLevel::getLevels()))
139  {
140  $a_level = ilLogLevel::INFO;
141  }
142 
143 
144  try {
145  throw new \Exception($a_message);
146  }
147  catch (Exception $ex) {
148  $this->getLogger()->log($a_level, $a_message."\n" . $ex->getTraceAsString());
149  }
150  }
151 
157  public function writeMemoryPeakUsage($a_level)
158  {
159  $this->getLogger()->pushProcessor(new MemoryPeakUsageProcessor());
160  $this->getLogger()->log($a_level, 'Memory usage: ');
161  $this->getLogger()->popProcessor();
162  }
163 }
164 ?>
writeLanguageLog($a_topic, $a_lang_key)
Write language log.
logStack($a_level=null, $a_message='')
log stack trace
dump($a_variable, $a_level=ilLogLevel::INFO)
Monolog log channel.
Definition: Logger.php:27
error($a_message)
debug($a_message, $a_context=array())
info($a_message)
log($a_message, $a_level=ilLogLevel::INFO)
static getLevels()
Injects memory_get_peak_usage in all records.
getLogger()
Get logger instance.
write($a_message, $a_level=ilLogLevel::INFO)
write log message
emergency($a_message)
critical($a_message)
__construct(Logger $logger)
notice($a_message)
writeMemoryPeakUsage($a_level)
Write memory peak usage Automatically called at end of script.
Create styles array
The data for the language used.
isHandling($a_level)
Check whether current logger is handling a log level.
warning($a_message)
alert($a_message)
Component logger with individual log levels by component id.