LSlog handlers: add enabled parameter

This commit is contained in:
Benjamin Renard 2020-06-30 11:03:48 +02:00
parent b898b0a9b7
commit 5872430863
4 changed files with 13 additions and 0 deletions

1
debian/changelog vendored
View file

@ -36,6 +36,7 @@ ldapsaisie (3.0.0-1) UNRELEASED; urgency=medium
- fix handling non-string message
- add loggers, filters and format message by handlers
- some fixes and improvements on get_debug_backtrace_context() method
- add enabled parameter for handlers
* LSerror:
- permit to control message escape method by adding a $escape parameter to all
accessible methods

View file

@ -14,6 +14,7 @@ de l'application.</para>
'[handler 1]',
array (
'handler' => [handler 2],
'enabled' => [booléen],
'level' => '[niveau]',
'loggers' => array('logger1', [...]),
'excluded_loggers' => array('logger2', [...]),
@ -121,6 +122,14 @@ de l'application.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>enabled</term>
<listitem>
<simpara>Booléen permettant d'activer ou désactiver cet <emphasis>handler</emphasis>
(paramètre facultatif, par défaut : <literal>True</literal>).</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>loggers</term>
<listitem>

View file

@ -203,6 +203,7 @@ $GLOBALS['LSlog']['handlers'] = array (
'handler' => 'file',
'path' => 'tmp/LS.log',
//'level' => 'DEBUG',
//'enabled' => false, // Uncomment to disable this handler
// Filter on specific loggers
//'loggers' => array('LSurl', 'LSlang'),
'excluded_loggers' => array('generate_lang_file', 'generate_ldapsaisie_pot'),

View file

@ -103,6 +103,8 @@ class LSlog {
* @retval boolean True if handler added, false otherwise
**/
public static function add_handler($handler, $handler_config = array()) {
if (!LSconfig :: get('enabled', true, 'bool', $handler_config))
return true;
$handler_class = "LSlog_$handler";
// Load handler class