ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 './libs/composer/vendor/autoload.php';
5include_once __DIR__ . '/public/class.ilLogLevel.php';
6
7
10
19abstract class ilLogger
20{
21 private $logger = null;
22
23 public function __construct(Logger $logger)
24 {
25 $this->logger = $logger;
26 }
27
33 public function isHandling($a_level)
34 {
35 return $this->getLogger()->isHandling($a_level);
36 }
37
38 public function log($a_message, $a_level = ilLogLevel::INFO)
39 {
40 return $this->getLogger()->log($a_level, $a_message);
41 }
42
43 public function dump($a_variable, $a_level = ilLogLevel::INFO)
44 {
45 return $this->log(print_r($a_variable, true), $a_level);
46 }
47
48 public function debug($a_message, $a_context = array())
49 {
50 return $this->getLogger()->debug($a_message, $a_context);
51 }
52
53 public function info($a_message)
54 {
55 return $this->getLogger()->info($a_message);
56 }
57
58 public function notice($a_message)
59 {
60 return $this->getLogger()->notice($a_message);
61 }
62
63 public function warning($a_message)
64 {
65 return $this->getLogger()->warning($a_message);
66 }
67
68 public function error($a_message)
69 {
70 return $this->getLogger()->error($a_message);
71 }
72
73 public function critical($a_message)
74 {
75 $this->getLogger()->critical($a_message);
76 }
77
78 public function alert($a_message)
79 {
80 return $this->getLogger()->alert($a_message);
81 }
82
83
84 public function emergency($a_message)
85 {
86 return $this->getLogger()->emergency($a_message);
87 }
88
93 public function getLogger()
94 {
95 return $this->logger;
96 }
97
103 public function write($a_message, $a_level = ilLogLevel::INFO)
104 {
105 include_once './Services/Logging/classes/public/class.ilLogLevel.php';
106 if (!in_array($a_level, ilLogLevel::getLevels())) {
107 $a_level = ilLogLevel::INFO;
108 }
109
110 $this->getLogger()->log($a_level, $a_message);
111 }
112
117 public function writeLanguageLog($a_topic, $a_lang_key)
118 {
119 $this->getLogger()->debug("Language (" . $a_lang_key . "): topic -" . $a_topic . "- not present");
120 }
121
128 public function logStack($a_level = null, $a_message = '')
129 {
130 if (is_null($a_level)) {
131 $a_level = ilLogLevel::INFO;
132 }
133
134 include_once './Services/Logging/classes/public/class.ilLogLevel.php';
135 if (!in_array($a_level, ilLogLevel::getLevels())) {
136 $a_level = ilLogLevel::INFO;
137 }
138
139
140 try {
141 throw new \Exception($a_message);
142 } catch (Exception $ex) {
143 $this->getLogger()->log($a_level, $a_message . "\n" . $ex->getTraceAsString());
144 }
145 }
146
152 public function writeMemoryPeakUsage($a_level)
153 {
154 $this->getLogger()->pushProcessor(new MemoryPeakUsageProcessor());
155 $this->getLogger()->log($a_level, 'Memory usage: ');
156 $this->getLogger()->popProcessor();
157 }
158}
An exception for terminatinating execution or to throw for unit testing.
Monolog log channel.
Definition: Logger.php:29
Injects memory_get_peak_usage in all records.
static getLevels()
Component logger with individual log levels by component id.
isHandling($a_level)
Check whether current logger is handling a log level.
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)