From 75fd64f17f30e7184f32170290b335189b713f32 Mon Sep 17 00:00:00 2001 From: thomascube Date: Mon, 13 Jul 2009 19:23:02 +0000 Subject: [PATCH] Add hook to write_log function --- program/include/main.inc | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/program/include/main.inc b/program/include/main.inc index 296e13fad..3099a7290 100644 --- a/program/include/main.inc +++ b/program/include/main.inc @@ -987,23 +987,30 @@ function console() */ function write_log($name, $line) { - global $CONFIG; + global $CONFIG, $RCMAIL; if (!is_string($line)) $line = var_export($line, true); if (empty($CONFIG['log_date_format'])) $CONFIG['log_date_format'] = 'd-M-Y H:i:s O'; + + // trigger logging hook + if (is_object($RCMAIL) && is_object($RCMAIL->plugins)) { + $log = $RCMAIL->plugins->exec_hook('write_log', array('name' => $name, 'line' => $line)); + $name = $log['name']; + $line = $log['line']; + if ($log['abort']) + return; + } $log_entry = sprintf("[%s]: %s\n", date($CONFIG['log_date_format']), $line); if ($CONFIG['log_driver'] == 'syslog') { - if ($name == 'errors') - $prio = LOG_ERR; - else - $prio = LOG_INFO; + $prio = $name == 'errors' ? LOG_ERR : LOG_INFO; syslog($prio, $log_entry); - } else { + } + else { // log_driver == 'file' is assumed here if (empty($CONFIG['log_dir'])) $CONFIG['log_dir'] = INSTALL_PATH.'logs';