25 class Logger extends \Monolog\Logger {
27 const CHANNEL =
'ELGG';
35 protected static $elgg_levels = [
37 100 => LogLevel::DEBUG,
38 200 => LogLevel::INFO,
39 250 => LogLevel::NOTICE,
40 300 => LogLevel::WARNING,
42 500 => LogLevel::CRITICAL,
43 550 => LogLevel::ALERT,
44 600 => LogLevel::EMERGENCY,
51 protected static $legacy_levels = [
53 'INFO' => LogLevel::INFO,
54 'NOTICE' => LogLevel::NOTICE,
55 'WARNING' => LogLevel::WARNING,
72 private $disabled_stack;
83 $logger =
new static(self::CHANNEL);
85 if (\
Elgg\Application::isCli()) {
90 $app =
new CliApplication();
96 \
Elgg\Application::getStdErr(),
101 $formatter->allowInlineLineBreaks();
102 $formatter->ignoreEmptyContextAndExtra();
110 $handler->pushProcessor(
new WebProcessor());
113 $formatter->allowInlineLineBreaks();
114 $formatter->ignoreEmptyContextAndExtra();
118 $handler->pushProcessor(
new MemoryUsageProcessor());
119 $handler->pushProcessor(
new MemoryPeakUsageProcessor());
120 $handler->pushProcessor(
new ProcessIdProcessor());
124 $handler->pushProcessor(
new PsrLogMessageProcessor());
145 if (array_key_exists($level, self::$legacy_levels)) {
146 $level = self::$legacy_levels[$level];
149 if (array_key_exists($level, self::$elgg_levels)) {
150 $level = self::$elgg_levels[$level];
153 if (!in_array($level, self::$elgg_levels)) {
169 if (!isset($level)) {
170 $php_error_level = error_reporting();
174 if (($php_error_level & E_NOTICE) == E_NOTICE) {
175 $level = LogLevel::NOTICE;
176 }
else if (($php_error_level & E_WARNING) == E_WARNING) {
177 $level = LogLevel::WARNING;
178 }
else if (($php_error_level & E_ERROR) == E_ERROR) {
183 $this->level = $this->normalizeLevel($level);
196 return array_search($this->level, self::$elgg_levels);
210 $level = $this->normalizeLevel($level);
212 $severity = array_search($level, self::$elgg_levels);
213 if (!$this->getLevel() || $severity < $this->getLevel()) {
225 $level = $this->normalizeLevel($level);
227 if (!empty($this->disabled_stack)) {
229 end($this->disabled_stack);
230 $key = key($this->disabled_stack);
231 $this->disabled_stack[
$key][] = [
237 if (!$this->isLoggable($level)) {
242 if (!empty($this->disabled_stack)) {
253 if (!$this->hooks->triggerDeprecated(
'debug',
'log',
$params,
true)) {
354 $this->disabled_stack[] = [];
365 return array_pop($this->disabled_stack);
377 $this->hooks = $hooks;
disable()
Temporarily disable logging and capture logs (before tests)
log($msg, $level=LogLevel::NOTICE)
Log a message.
$params
Saves global plugin settings.
info($message, array $context=[])
{}
getLevel($severity=true)
Get the current logging level severity.
emergency($message, array $context=[])
{}
static getStdOut()
Load console output interface.
static factory(InputInterface $input=null, OutputInterface $output=null)
Build a new logger.
setHooks(PluginHooksService $hooks)
Reset the hooks service for this instance (testing)
if(elgg_trigger_plugin_hook('usersettings:save', 'user', $hooks_params, true)) foreach($request->validation() ->all() as $item) $data
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.
catch(LoginException $e) if($request->isXhr()) $output
warning($message, array $context=[])
{}
log($level, $message, array $context=[])
{}
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
warn($message, array $context=[])
Log message at the WARNING level.
static getStdIn()
Load console input interface.
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=[])
{}