mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2025-04-02 01:41:37 +02:00
LSlog handlers: fix log TRACE enabled error (even if disabled)
This commit is contained in:
parent
1e6fa6fe8e
commit
988054bfc5
6 changed files with 48 additions and 12 deletions
|
@ -42,6 +42,8 @@ class LSlog_console extends LSlog_handler {
|
||||||
parent :: __construct($config);
|
parent :: __construct($config);
|
||||||
$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)
|
||||||
|
LSlog :: log_trace("$this Enabled", get_class($this));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -43,7 +43,8 @@ class LSlog_email extends LSlog_handler {
|
||||||
public function __construct($config) {
|
public function __construct($config) {
|
||||||
parent :: __construct($config);
|
parent :: __construct($config);
|
||||||
$this -> recipient = self :: getConfig('recipient');
|
$this -> recipient = self :: getConfig('recipient');
|
||||||
$this -> logging('TRACE', "$this Enabled", get_class($this));
|
if ($this -> enabled)
|
||||||
|
LSlog :: log_trace("$this Enabled", get_class($this));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -43,7 +43,8 @@ class LSlog_file extends LSlog_handler {
|
||||||
$this -> path = self :: getConfig('path', LSlog :: getConfig('filename', 'tmp/LS.log'));
|
$this -> path = self :: getConfig('path', LSlog :: getConfig('filename', 'tmp/LS.log'));
|
||||||
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;
|
||||||
$this -> logging('TRACE', "$this Enabled", get_class($this));
|
if ($this -> enabled)
|
||||||
|
LSlog :: log_trace("$this Enabled", get_class($this));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -87,6 +87,32 @@ class LSlog_handler {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get handler info
|
||||||
|
*
|
||||||
|
* @param[in] $key string The info name
|
||||||
|
*
|
||||||
|
* @retval mixed The info value
|
||||||
|
**/
|
||||||
|
public function __get($key) {
|
||||||
|
switch ($key) {
|
||||||
|
case 'enabled':
|
||||||
|
return $this -> getConfig('enabled', true, 'bool');
|
||||||
|
case 'format':
|
||||||
|
if (php_sapi_name() == "cli")
|
||||||
|
$format = $this -> getConfig('cli_format', $this -> default_cli_format, 'string');
|
||||||
|
else
|
||||||
|
$format = $this -> getConfig('format', $this -> default_format, 'string');
|
||||||
|
// Add datetime prefix (if enabled)
|
||||||
|
if ($this -> getConfig('datetime_prefix', $this -> default_datetime_prefix, 'boolean')) {
|
||||||
|
$format = date($this -> getConfig('datetime_format', $this -> default_datetime_format, 'string'))." - $format";
|
||||||
|
}
|
||||||
|
return $format;
|
||||||
|
}
|
||||||
|
// Unknown key, log warning
|
||||||
|
LSlog :: log_warning("$this -> __get($key): invalid property requested\n".LSlog :: get_debug_backtrace_context());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check system compatibility with this handler
|
* Check system compatibility with this handler
|
||||||
*
|
*
|
||||||
|
@ -184,16 +210,8 @@ class LSlog_handler {
|
||||||
**/
|
**/
|
||||||
protected function format($level, $message, $logger=null) {
|
protected function format($level, $message, $logger=null) {
|
||||||
global $argv;
|
global $argv;
|
||||||
if (php_sapi_name() == "cli")
|
|
||||||
$format = $this -> getConfig('cli_format', $this -> default_cli_format, 'string');
|
|
||||||
else
|
|
||||||
$format = $this -> getConfig('format', $this -> default_format, 'string');
|
|
||||||
// Add datetime prefix (if enabled)
|
|
||||||
if ($this -> getConfig('datetime_prefix', $this -> default_datetime_prefix, 'boolean')) {
|
|
||||||
$format = date($this -> getConfig('datetime_format', $this -> default_datetime_format, 'string'))." - $format";
|
|
||||||
}
|
|
||||||
return getFData(
|
return getFData(
|
||||||
$format,
|
$this -> format,
|
||||||
array(
|
array(
|
||||||
'level' => $level,
|
'level' => $level,
|
||||||
'message' => $message,
|
'message' => $message,
|
||||||
|
|
|
@ -59,7 +59,8 @@ class LSlog_syslog extends LSlog_handler {
|
||||||
public function __construct($config) {
|
public function __construct($config) {
|
||||||
parent :: __construct($config);
|
parent :: __construct($config);
|
||||||
$this -> priority = static :: getConfig('priority');
|
$this -> priority = static :: getConfig('priority');
|
||||||
$this -> logging('TRACE', "$this Enabled", get_class($this));
|
if ($this -> enabled)
|
||||||
|
LSlog :: log_trace("$this Enabled", get_class($this));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -30,6 +30,19 @@ class LSlog_system extends LSlog_handler {
|
||||||
// Default datetime prefix (enabled/disabled)
|
// Default datetime prefix (enabled/disabled)
|
||||||
protected $default_datetime_prefix = false;
|
protected $default_datetime_prefix = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param[in] $config array The handler configuration
|
||||||
|
*
|
||||||
|
* @retval void
|
||||||
|
**/
|
||||||
|
public function __construct($config) {
|
||||||
|
parent :: __construct($config);
|
||||||
|
if ($this -> enabled)
|
||||||
|
LSlog :: log_trace("$this Enabled", get_class($this));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log a message
|
* Log a message
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue