Extend LSlog_handler using LSlog_staticLoggerClass

This commit is contained in:
Benjamin Renard 2020-09-10 10:26:49 +02:00
parent 988054bfc5
commit d0d3e944ed
6 changed files with 11 additions and 9 deletions

View file

@ -43,7 +43,7 @@ class LSlog_console extends LSlog_handler {
$this -> stdout = fopen('php://stdout', 'w'); $this -> stdout = fopen('php://stdout', 'w');
$this -> stderr = fopen('php://stderr', 'w'); $this -> stderr = fopen('php://stderr', 'w');
if ($this -> enabled) if ($this -> enabled)
LSlog :: log_trace("$this Enabled", get_class($this)); self :: log_trace("$this Enabled", get_class($this));
} }
/** /**

View file

@ -44,7 +44,7 @@ class LSlog_email extends LSlog_handler {
parent :: __construct($config); parent :: __construct($config);
$this -> recipient = self :: getConfig('recipient'); $this -> recipient = self :: getConfig('recipient');
if ($this -> enabled) if ($this -> enabled)
LSlog :: log_trace("$this Enabled", get_class($this)); self :: log_trace("$this Enabled", get_class($this));
} }
/** /**

View file

@ -44,7 +44,7 @@ class LSlog_file extends LSlog_handler {
if (substr($this -> path, 0, 1) != '/') if (substr($this -> path, 0, 1) != '/')
$this -> path = LS_ROOT_DIR."/".$this -> path; $this -> path = LS_ROOT_DIR."/".$this -> path;
if ($this -> enabled) if ($this -> enabled)
LSlog :: log_trace("$this Enabled", get_class($this)); self :: log_trace("$this Enabled", get_class($this));
} }
/** /**

View file

@ -20,12 +20,14 @@
******************************************************************************/ ******************************************************************************/
LSsession :: loadLSclass('LSlog_staticLoggerClass');
/** /**
* Default logging handler * Default logging handler
* *
* @author Benjamin Renard <brenard@easter-eggs.com> * @author Benjamin Renard <brenard@easter-eggs.com>
*/ */
class LSlog_handler { class LSlog_handler extends LSlog_staticLoggerClass {
// The handler configuration // The handler configuration
protected $config; protected $config;
@ -110,7 +112,7 @@ class LSlog_handler {
return $format; return $format;
} }
// Unknown key, log warning // Unknown key, log warning
LSlog :: log_warning("$this -> __get($key): invalid property requested\n".LSlog :: get_debug_backtrace_context()); self :: log_warning("__get($key): invalid property requested\n".LSlog :: get_debug_backtrace_context());
} }
/** /**
@ -151,10 +153,10 @@ class LSlog_handler {
**/ **/
public function setLevel($level) { public function setLevel($level) {
if (!is_null($level) && !LSlog :: checkLevelExists($level)) { if (!is_null($level) && !LSlog :: checkLevelExists($level)) {
LSlog :: error("Invalid log level '$level'"); self :: log_error("Invalid log level '$level'");
return false; return false;
} }
LSlog :: debug("Log handler ".get_called_class()." level set to ".(is_null($level)?'default':$level)); self :: log_debug("Log handler ".get_called_class()." level set to ".(is_null($level)?'default':$level));
$this -> level = $level; $this -> level = $level;
} }

View file

@ -60,7 +60,7 @@ class LSlog_syslog extends LSlog_handler {
parent :: __construct($config); parent :: __construct($config);
$this -> priority = static :: getConfig('priority'); $this -> priority = static :: getConfig('priority');
if ($this -> enabled) if ($this -> enabled)
LSlog :: log_trace("$this Enabled", get_class($this)); self :: log_trace("$this Enabled", get_class($this));
} }
/** /**

View file

@ -40,7 +40,7 @@ class LSlog_system extends LSlog_handler {
public function __construct($config) { public function __construct($config) {
parent :: __construct($config); parent :: __construct($config);
if ($this -> enabled) if ($this -> enabled)
LSlog :: log_trace("$this Enabled", get_class($this)); self :: log_trace("$this Enabled", get_class($this));
} }
/** /**