23 protected static $levels = array(
39 protected $display =
false;
59 private $disabled_stack;
69 $this->config = $config;
70 $this->hooks = $hooks;
82 if (is_string($level)) {
83 $levelStringsToInts = array_flip(self::$levels);
84 $level = $levelStringsToInts[$level];
86 $this->level = $level;
109 $this->display = $display;
120 if ($this->disabled_stack) {
122 end($this->disabled_stack);
123 $key = key($this->disabled_stack);
124 $this->disabled_stack[
$key][] = [
130 if ($this->level == self::OFF || $level < $this->level) {
134 if (!array_key_exists($level, self::$levels)) {
139 if ($this->disabled_stack) {
143 $levelString = self::$levels[$level];
146 $display = $this->display && $level > self::NOTICE;
148 $this->process(
"$levelString: $message", $display, $level);
170 return $this->log(
$message, self::WARNING);
180 return $this->log(
$message, self::NOTICE);
190 return $this->log(
$message, self::INFO);
219 'display' => $display,
220 'to_screen' => $display,
223 if (!$this->hooks->trigger(
'debug',
'log',
$params,
true)) {
230 if (!isset($GLOBALS[
'_ELGG']->pagesetupdone)) {
235 if ($this->context->contains(
'js') || $this->context->contains(
'css')) {
241 if (preg_match(
'~^(cache|action|serve-file)/~',
$path)) {
245 if ($display ==
true) {
246 echo '<pre class="elgg-logger-data">';
247 echo htmlspecialchars(print_r(
$data,
true), ENT_QUOTES,
'UTF-8');
251 error_log(print_r(
$data,
true));
268 $this->disabled_stack[] = [];
280 return array_pop($this->disabled_stack);
291 $this->hooks = $hooks;
disable()
Temporarily disable logging and capture logs (before tests)
setLogger(\Elgg\Logger $logger=null)
Set a logger instance, e.g.
Access to configuration values.
setHooks(PluginHooksService $hooks)
Reset the hooks service for this instance (testing)
process($data, $display, $level)
Process logging data.
getLevel()
Get the current logging level.
setDisplay($display)
Set whether the logging should be displayed to the user.
setLevel($level)
Set the logging level.
__construct(PluginHooksService $hooks, Config $config, Context $context)
Constructor.
enable()
Restore logging and get record of log calls (after tests)
elgg echo
Translates a string.
elgg_get_site_url($site_guid=0)
Get the URL for the current (or specified) site.
error($message)
Log message at the ERROR level.
log($message, $level=self::NOTICE)
Add a message to the log.
dump($data, $display=true)
Dump data to log or screen.
info($message)
Log message at the INFO level.
warn($message)
Log message at the WARNING level.
notice($message)
Log message at the NOTICE level.
Manages a global stack of strings for sharing information about the current execution context...