26 class Logger extends \Monolog\Logger {
28 const CHANNEL =
'ELGG';
36 protected static $elgg_levels = [
38 100 => LogLevel::DEBUG,
39 200 => LogLevel::INFO,
40 250 => LogLevel::NOTICE,
41 300 => LogLevel::WARNING,
42 400 => LogLevel::ERROR,
43 500 => LogLevel::CRITICAL,
44 550 => LogLevel::ALERT,
45 600 => LogLevel::EMERGENCY,
52 protected static $legacy_levels = [
54 'INFO' => LogLevel::INFO,
55 'NOTICE' => LogLevel::NOTICE,
56 'WARNING' => LogLevel::WARNING,
57 'ERROR' => LogLevel::ERROR,
68 protected $disabled_stack = [];
79 $logger =
new static(self::CHANNEL);
81 if (\
Elgg\Application::isCli()) {
86 $app =
new CliApplication();
92 \
Elgg\Application::getStdErr(),
97 $formatter->allowInlineLineBreaks();
98 $formatter->ignoreEmptyContextAndExtra();
106 $handler->pushProcessor(
new WebProcessor());
109 $formatter->allowInlineLineBreaks();
110 $formatter->ignoreEmptyContextAndExtra();
114 $handler->pushProcessor(
new MemoryUsageProcessor());
115 $handler->pushProcessor(
new MemoryPeakUsageProcessor());
116 $handler->pushProcessor(
new ProcessIdProcessor());
120 $handler->pushProcessor(
new PsrLogMessageProcessor());
137 if (!is_string($level) || !in_array($level, self::$elgg_levels)) {
138 $level_value = $level;
139 if ($level ===
false) {
140 $level_value =
'false';
143 $this->warning(
"Deprecated in 6.1: Using the log level '{$level_value}' has been deprecated. Use the \Psr\Log\LogLevel constants.");
150 if (array_key_exists($level, self::$legacy_levels)) {
151 $level = self::$legacy_levels[$level];
152 if ($level ===
false) {
158 if (array_key_exists($level, self::$elgg_levels)) {
159 $level = self::$elgg_levels[$level];
162 if (!in_array($level, self::$elgg_levels)) {
180 if (!isset($level)) {
181 $php_error_level = error_reporting();
183 $level = LogLevel::CRITICAL;
185 if (($php_error_level & E_NOTICE) == E_NOTICE) {
186 $level = LogLevel::NOTICE;
187 }
else if (($php_error_level & E_WARNING) == E_WARNING) {
188 $level = LogLevel::WARNING;
189 }
else if (($php_error_level & E_ERROR) == E_ERROR) {
190 $level = LogLevel::ERROR;
194 $this->level = $this->normalizeLevel($level);
207 return array_search($this->level, self::$elgg_levels);
221 $level = $this->normalizeLevel($level);
223 $severity = array_search($level, self::$elgg_levels);
224 if (!$this->getLevel() || $severity < $this->getLevel()) {
236 $level = $this->normalizeLevel($level);
238 if (!empty($this->disabled_stack)) {
240 end($this->disabled_stack);
241 $key = key($this->disabled_stack);
242 $this->disabled_stack[
$key][] = [
250 if (!$this->isLoggable($level)) {
337 $this->disabled_stack[] = [];
348 return array_pop($this->disabled_stack);
disable()
Temporarily disable logging and capture logs (before tests)
info($message, array $context=[])
{}
getLevel($severity=true)
Get the current logging level severity.
c Accompany it with the information you received as to the offer to distribute corresponding source complete source code means all the source code for all modules it plus any associated interface definition plus the scripts used to control compilation and installation of the executable as a special the source code distributed need not include anything that is normally and so on of the operating system on which the executable unless that component itself accompanies the executable If distribution of executable or object code is made by offering access to copy from a designated then offering equivalent access to copy the source code from the same place counts as distribution of the source even though third parties are not compelled to copy the source along with the object code You may not or distribute the Program except as expressly provided under this License Any attempt otherwise to sublicense or distribute the Program is void
emergency($message, array $context=[])
{}
static getStdOut()
Load console output interface.
static factory(InputInterface $input=null, OutputInterface $output=null)
Build a new logger.
alert($message, array $context=[])
{}
Wrapper for console application.
debug($message, array $context=[])
{}
Inject backtrace stack into the record.
setLevel($level=null)
Set the logging level.
warning($message, array $context=[])
{}
log($level, $message, array $context=[])
{}
if(!$entity instanceof\ElggUser) $data
enable()
Restore logging and get record of log calls (after tests)
error($message, array $context=[])
{}
Handle system and PHP errors.
critical($message, array $context=[])
{}
if($container instanceof ElggGroup &&$container->guid!=elgg_get_page_owner_guid()) $key
static getStdIn()
Load console input interface.
log($level, $message, array $context=[])
Log a message.
dump($data)
Dump data to log.
isLoggable($level)
Check if a level is loggable under current logging level.
normalizeLevel($level=null)
Normalizes legacy string or numeric representation of the level to LogLevel strings.
notice($message, array $context=[])
{}