mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-11-22 01:49:08 +01:00
LSlog: add log_errors_context & log_errors_context_with_args paramters
This commit is contained in:
parent
4c7f6847fd
commit
b5b540de65
3 changed files with 96 additions and 45 deletions
|
@ -6,6 +6,8 @@ Cette section décrit le tableau de configuration de la journalisation de l'appl
|
||||||
$GLOBALS['LSlog'] = array(
|
$GLOBALS['LSlog'] = array(
|
||||||
'enable' => [booléen],
|
'enable' => [booléen],
|
||||||
'level' => '[niveau]',
|
'level' => '[niveau]',
|
||||||
|
'log_errors_context' => [booléen],
|
||||||
|
'log_errors_context_with_args' => [booléen],
|
||||||
'handlers' => array(
|
'handlers' => array(
|
||||||
'[handler 1]',
|
'[handler 1]',
|
||||||
array (
|
array (
|
||||||
|
@ -53,6 +55,17 @@ $GLOBALS['LSlog'] = array(
|
||||||
- `ERROR`
|
- `ERROR`
|
||||||
- `FATAL`
|
- `FATAL`
|
||||||
|
|
||||||
|
- `log_errors_context`
|
||||||
|
|
||||||
|
Booléen permatant de définir si le contexte _(=backtrace)_ doit être inclus lors de la
|
||||||
|
journalisation d'une erreurs.
|
||||||
|
|
||||||
|
- `log_errors_context_with_args`
|
||||||
|
|
||||||
|
Booléen permatant de définir si les arguments des méthodes/fonctions appelées doivent être
|
||||||
|
inclus lors de la journalisation du contexte des erreurs.
|
||||||
|
__Note :__ ce paramètre n'as aucun effet si le paramètre `log_errors_context` n'est pas activé.
|
||||||
|
|
||||||
- `handlers`
|
- `handlers`
|
||||||
|
|
||||||
Tableau permettant de configurer les *handlers* de la journalisation. Chaque *handler* gère les
|
Tableau permettant de configurer les *handlers* de la journalisation. Chaque *handler* gère les
|
||||||
|
|
|
@ -204,60 +204,77 @@ define('LS_CSS_DIR', 'css');
|
||||||
define('LSdebug',false);
|
define('LSdebug',false);
|
||||||
|
|
||||||
// Logging
|
// Logging
|
||||||
$GLOBALS['LSlog']['handlers'] = array (
|
$GLOBALS['LSlog'] = array (
|
||||||
array (
|
// Enable/disable logs
|
||||||
'handler' => 'file',
|
'enable' => true,
|
||||||
'path' => 'tmp/LS.log',
|
|
||||||
//'level' => 'DEBUG',
|
// Global logs level (TRACE, DEBUG, INFO, WARNING, ERROR, FATAL)
|
||||||
//'enabled' => false, // Uncomment to disable this handler
|
'level' => 'INFO',
|
||||||
// Filter on specific loggers
|
|
||||||
//'loggers' => array('LSurl', 'LSlang'),
|
// Log errors's context (=backtrace)
|
||||||
'excluded_loggers' => array('generate_lang_file', 'generate_ldapsaisie_pot'),
|
'log_errors_context' => true,
|
||||||
// Default formats
|
|
||||||
//'format' => '%{requesturi} - %{remoteaddr} - %{ldapservername} - %{authuser} - %{level} - %{message}',
|
// Log errors's context with arguments of called method/functions
|
||||||
//'cli_format' => '%{clibinpath} - %{level} - %{message}',
|
'log_errors_context_with_args' => false,
|
||||||
//'datetime_prefix' => true, // Prefix message with datetime ?
|
|
||||||
//'datetime_format' => 'Y/m/d H:i:s', // Datetime prefix format (see php date() function)
|
/**
|
||||||
|
* Logs handlers are components that logged message emitted by the application.
|
||||||
|
* Each handlers handle emitted message as its own way (storing it in file/database, send it via
|
||||||
|
* email or to an external backend, ...).
|
||||||
|
*/
|
||||||
|
'handlers' => array (
|
||||||
|
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'),
|
||||||
|
// Default formats
|
||||||
|
//'format' => '%{requesturi} - %{remoteaddr} - %{ldapservername} - %{authuser} - %{level} - %{message}',
|
||||||
|
//'cli_format' => '%{clibinpath} - %{level} - %{message}',
|
||||||
|
//'datetime_prefix' => true, // Prefix message with datetime ?
|
||||||
|
//'datetime_format' => 'Y/m/d H:i:s', // Datetime prefix format (see php date() function)
|
||||||
|
),
|
||||||
|
array (
|
||||||
|
'handler' => 'email', // Email handler (each logged message generated an email)
|
||||||
|
'level' => 'FATAL',
|
||||||
|
'recipient' => 'root@localhost', // Email recipient
|
||||||
|
),
|
||||||
|
/*
|
||||||
|
array (
|
||||||
|
'handler' => 'syslog', // Syslog handler
|
||||||
|
//'priority' => 'WARNING', // Force priority : EMERG, ALERT, CRITICAL, ERROR, WARNING, NOTICE, INFO, DEBUG
|
||||||
|
),
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
array (
|
||||||
|
'handler' => 'system', // System logging (using PHP error_log)
|
||||||
|
'level' => 'ERROR',
|
||||||
|
),
|
||||||
|
*/
|
||||||
),
|
),
|
||||||
array (
|
|
||||||
'handler' => 'email', // Email handler (each logged message generated an email)
|
|
||||||
'level' => 'FATAL',
|
|
||||||
'recipient' => 'root@localhost', // Email recipient
|
|
||||||
),
|
|
||||||
/*
|
|
||||||
array (
|
|
||||||
'handler' => 'syslog', // Syslog handler
|
|
||||||
//'priority' => 'WARNING', // Force priority : EMERG, ALERT, CRITICAL, ERROR, WARNING, NOTICE, INFO, DEBUG
|
|
||||||
),
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
array (
|
|
||||||
'handler' => 'system', // System logging (using PHP error_log)
|
|
||||||
'level' => 'ERROR',
|
|
||||||
),
|
|
||||||
*/
|
|
||||||
);
|
|
||||||
$GLOBALS['LSlog']['loggers'] = array (
|
|
||||||
/**
|
/**
|
||||||
* Loggers permit to define different log parameters for specific components
|
* Loggers permit to define different log parameters for specific components
|
||||||
* of LdapSaisie (a class, an addon, ...). You could :
|
* of LdapSaisie (a class, an addon, ...). You could :
|
||||||
* - Enabled/disabled logs for this component with 'enabled' parameter
|
* - Enabled/disabled logs for this component with 'enabled' parameter
|
||||||
* - Set a specific log level for this component with 'enabled' parameter
|
* - Set a specific log level for this component with 'enabled' parameter
|
||||||
**/
|
**/
|
||||||
/*
|
"loggers" => array(
|
||||||
'LSurl' => array (
|
/*
|
||||||
'level' => 'DEBUG',
|
'LSurl' => array (
|
||||||
|
'level' => 'DEBUG',
|
||||||
|
),
|
||||||
|
'LSldap' => array (
|
||||||
|
'level' => 'DEBUG',
|
||||||
|
),
|
||||||
|
'LSlang' => array (
|
||||||
|
'enabled' => false,
|
||||||
|
),
|
||||||
|
*/
|
||||||
),
|
),
|
||||||
'LSldap' => array (
|
|
||||||
'level' => 'DEBUG',
|
|
||||||
),
|
|
||||||
'LSlang' => array (
|
|
||||||
'enabled' => false,
|
|
||||||
),
|
|
||||||
*/
|
|
||||||
);
|
);
|
||||||
$GLOBALS['LSlog']['level'] = 'INFO'; // TRACE, DEBUG, INFO, WARNING, ERROR, FATAL
|
|
||||||
$GLOBALS['LSlog']['enable'] = true;
|
|
||||||
|
|
||||||
define('NB_LSOBJECT_LIST',30);
|
define('NB_LSOBJECT_LIST',30);
|
||||||
define('NB_LSOBJECT_LIST_SELECT',20);
|
define('NB_LSOBJECT_LIST_SELECT',20);
|
||||||
|
|
|
@ -33,6 +33,18 @@ class LSlog {
|
||||||
*/
|
*/
|
||||||
private static $enabled = false;
|
private static $enabled = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log errors context
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
private static $log_errors_context = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log errors context with arguments
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
private static $log_errors_context_with_args = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configured handlers
|
* Configured handlers
|
||||||
* @see self::start()
|
* @see self::start()
|
||||||
|
@ -91,6 +103,8 @@ class LSlog {
|
||||||
public static function start() {
|
public static function start() {
|
||||||
// Load configuration
|
// Load configuration
|
||||||
self :: $enabled = self :: getConfig('enable', false, 'bool');
|
self :: $enabled = self :: getConfig('enable', false, 'bool');
|
||||||
|
self :: $log_errors_context = self :: getConfig('log_errors_context', false, 'bool');
|
||||||
|
self :: $log_errors_context_with_args = self :: getConfig('log_errors_context_with_args', false, 'bool');
|
||||||
self :: setLevel();
|
self :: setLevel();
|
||||||
|
|
||||||
// Load default handlers class
|
// Load default handlers class
|
||||||
|
@ -252,6 +266,13 @@ class LSlog {
|
||||||
$message = varDump($message);
|
$message = varDump($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Append context to message (if enabled)
|
||||||
|
if (self :: $log_errors_context && self :: checkLevel($level, "ERROR"))
|
||||||
|
$message .= "\n".self :: get_debug_backtrace_context(
|
||||||
|
self :: $log_errors_context_with_args,
|
||||||
|
2
|
||||||
|
);
|
||||||
|
|
||||||
foreach (self :: $handlers as $handler) {
|
foreach (self :: $handlers as $handler) {
|
||||||
// Check handler level
|
// Check handler level
|
||||||
if (!$handler -> checkLevel($level))
|
if (!$handler -> checkLevel($level))
|
||||||
|
|
Loading…
Reference in a new issue