ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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
4include_once './Services/Logging/lib/vendor/autoload.php';
5include_once './Services/Logging/classes/public/class.ilLogLevel.php';
6
7
10
11
20abstract class ilLogger
21{
22 private $logger = null;
23
24 public function __construct(Logger $logger)
25 {
26 $this->logger = $logger;
27 }
28
29 public function log($a_message, $a_level = ilLogLevel::INFO)
30 {
31 return $this->getLogger()->log($a_level, $a_message);
32 }
33
34 public function dump($a_variable, $a_level = ilLogLevel::INFO)
35 {
36 return $this->log(print_r($a_variable,TRUE), $a_level);
37 }
38
39 public function debug($a_message, $a_context = array())
40 {
41 return $this->getLogger()->debug($a_message,$a_context);
42 }
43
44 public function info($a_message)
45 {
46 return $this->getLogger()->info($a_message);
47 }
48
49 public function notice($a_message)
50 {
51 return $this->getLogger()->notice($a_message);
52 }
53
54 public function warning($a_message)
55 {
56 return $this->getLogger()->warning($a_message);
57 }
58
59 public function error($a_message)
60 {
61 return $this->getLogger()->error($a_message);
62 }
63
64 public function critical($a_message)
65 {
66 $this->getLogger()->critical($a_message);
67 }
68
69 public function alert($a_message)
70 {
71 return $this->getLogger()->alert($a_message);
72 }
73
74
75 public function emergency($a_message)
76 {
77 return $this->getLogger()->emergency($a_message);
78 }
79
84 public function getLogger()
85 {
86 return $this->logger;
87 }
88
94 public function write($a_message, $a_level = ilLogLevel::INFO)
95 {
96 include_once './Services/Logging/classes/public/class.ilLogLevel.php';
97 if(!in_array($a_level, ilLogLevel::getLevels()))
98 {
99 $a_level = ilLogLevel::INFO;
100 }
101
102 $this->getLogger()->log($a_level, $a_message);
103 }
104
109 public function writeLanguageLog($a_topic, $a_lang_key)
110 {
111 $this->getLogger()->debug("Language (".$a_lang_key."): topic -".$a_topic."- not present");
112 }
113
120 public function logStack($a_level = null, $a_message = '')
121 {
122 if(is_null($a_level))
123 {
124 $a_level = ilLogLevel::INFO;
125 }
126
127 include_once './Services/Logging/classes/public/class.ilLogLevel.php';
128 if(!in_array($a_level, ilLogLevel::getLevels()))
129 {
130 $a_level = ilLogLevel::INFO;
131 }
132
133
134 try {
135 throw new \Exception($a_message);
136 }
137 catch (Exception $ex) {
138 $this->getLogger()->log($a_level, $a_message."\n" . $ex->getTraceAsString());
139 }
140 }
141
147 public function writeMemoryPeakUsage($a_level)
148 {
149 $this->getLogger()->pushProcessor(new MemoryPeakUsageProcessor());
150 $this->getLogger()->log($a_level, 'Memory usage: ');
151 $this->getLogger()->popProcessor();
152 }
153}
154?>
Monolog log channel.
Definition: Logger.php:28
Injects memory_get_peak_usage in all records.
static getLevels()
Component logger with individual log levels by component id.
critical($a_message)
writeMemoryPeakUsage($a_level)
Write memory peak usage Automatically called at end of script.
error($a_message)
__construct(Logger $logger)
logStack($a_level=null, $a_message='')
log stack trace
dump($a_variable, $a_level=ilLogLevel::INFO)
writeLanguageLog($a_topic, $a_lang_key)
Write language log.
alert($a_message)
debug($a_message, $a_context=array())
warning($a_message)
write($a_message, $a_level=ilLogLevel::INFO)
write log message
notice($a_message)
log($a_message, $a_level=ilLogLevel::INFO)
info($a_message)
getLogger()
Get logger instance.
emergency($a_message)