From 5872430863f5629d867b15392433e8602b59a542 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Tue, 30 Jun 2020 11:03:48 +0200 Subject: [PATCH] LSlog handlers: add enabled parameter --- debian/changelog | 1 + doc/conf/LSlog.docbook | 9 +++++++++ src/conf/config.inc.php | 1 + src/includes/class/class.LSlog.php | 2 ++ 4 files changed, 13 insertions(+) diff --git a/debian/changelog b/debian/changelog index fbfb5f3f..365154a1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -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 diff --git a/doc/conf/LSlog.docbook b/doc/conf/LSlog.docbook index 74251a01..28d24575 100644 --- a/doc/conf/LSlog.docbook +++ b/doc/conf/LSlog.docbook @@ -14,6 +14,7 @@ de l'application. '[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. + + enabled + + Booléen permettant d'activer ou désactiver cet handler + (paramètre facultatif, par défaut : True). + + + loggers diff --git a/src/conf/config.inc.php b/src/conf/config.inc.php index c89751ca..c1c5fa73 100644 --- a/src/conf/config.inc.php +++ b/src/conf/config.inc.php @@ -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'), diff --git a/src/includes/class/class.LSlog.php b/src/includes/class/class.LSlog.php index 4e0a8b4e..a65efcc7 100644 --- a/src/includes/class/class.LSlog.php +++ b/src/includes/class/class.LSlog.php @@ -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