summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorthomascube <thomas@roundcube.net>2009-07-13 19:23:02 +0000
committerthomascube <thomas@roundcube.net>2009-07-13 19:23:02 +0000
commit75fd64f17f30e7184f32170290b335189b713f32 (patch)
tree5508d448e7e5ba43912606afbeb7312dbaac5db4
parent92fc5398dbd24eefcd5fed23194addd6f41eebf8 (diff)
Add hook to write_log function
-rw-r--r--program/include/main.inc19
1 files 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';