Add hook to write_log function

release-0.6
thomascube 16 years ago
parent 92fc5398db
commit 75fd64f17f

@ -987,23 +987,30 @@ function console()
*/ */
function write_log($name, $line) function write_log($name, $line)
{ {
global $CONFIG; global $CONFIG, $RCMAIL;
if (!is_string($line)) if (!is_string($line))
$line = var_export($line, true); $line = var_export($line, true);
if (empty($CONFIG['log_date_format'])) if (empty($CONFIG['log_date_format']))
$CONFIG['log_date_format'] = 'd-M-Y H:i:s O'; $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); $log_entry = sprintf("[%s]: %s\n", date($CONFIG['log_date_format']), $line);
if ($CONFIG['log_driver'] == 'syslog') { if ($CONFIG['log_driver'] == 'syslog') {
if ($name == 'errors') $prio = $name == 'errors' ? LOG_ERR : LOG_INFO;
$prio = LOG_ERR;
else
$prio = LOG_INFO;
syslog($prio, $log_entry); syslog($prio, $log_entry);
} else { }
else {
// log_driver == 'file' is assumed here // log_driver == 'file' is assumed here
if (empty($CONFIG['log_dir'])) if (empty($CONFIG['log_dir']))
$CONFIG['log_dir'] = INSTALL_PATH.'logs'; $CONFIG['log_dir'] = INSTALL_PATH.'logs';

Loading…
Cancel
Save