LSlog_handler : add excluded_loggers configuration parameter

This commit is contained in:
Benjamin Renard 2020-05-08 13:18:17 +02:00
parent aebdb4a111
commit b574300ab3
2 changed files with 15 additions and 1 deletions

View file

@ -198,6 +198,7 @@ $GLOBALS['LSlog']['handlers'] = array (
//'level' => 'DEBUG',
// Filter on specific loggers
//'loggers' => array('LSurl', 'LSlang'),
'excluded_loggers' => array('generate_lang_file', 'generate_ldapsaisie_pot'),
// Default formats
//'format' => '%{requesturi} - %{remoteaddr} - %{ldapservername} - %{authuser} - %{level} - %{message}',
//'cli_format' => '%{clibinpath} - %{level} - %{message}',

View file

@ -40,6 +40,10 @@ class LSlog_handler {
// Default datetime format
protected $default_datetime_format = 'Y/m/d H:i:s';
// Loggers filters
protected $loggers = array();
protected $excluded_loggers = array();
/**
* Constructor
*
@ -52,6 +56,9 @@ class LSlog_handler {
$this -> loggers = $this -> getConfig('loggers', array());
if (!is_array($this -> loggers))
$this -> loggers = array($this -> loggers);
$this -> excluded_loggers = $this -> getConfig('excluded_loggers', array());
if (!is_array($this -> excluded_loggers))
$this -> excluded_loggers = array($this -> excluded_loggers);
}
/**
@ -102,7 +109,13 @@ class LSlog_handler {
* @retval bool True if message of this logger have to be logged, False otherwise
**/
public function checkLogger($logger) {
return (!$this -> loggers || in_array($logger, $this -> loggers));
if (!$this -> loggers && !$this -> excluded_loggers)
return true;
if ($this -> loggers && in_array($logger, $this -> loggers))
return true;
if ($this -> excluded_loggers && !in_array($logger, $this -> excluded_loggers))
return true;
return false;
}
/**