From bc7fd66b5fa9bf2b97ccee2af3b69f1c0cf76d40 Mon Sep 17 00:00:00 2001 From: Nomad Arton Date: Thu, 11 Jan 2018 14:02:30 +0000 Subject: [PATCH] Make log_caldav_action log to syslog Additionally, not only log intended actions, but also log completed actions --- inc/log_caldav_action.php | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/inc/log_caldav_action.php b/inc/log_caldav_action.php index 7639d7c2..1f56546b 100644 --- a/inc/log_caldav_action.php +++ b/inc/log_caldav_action.php @@ -24,17 +24,20 @@ * @param string $dav_name The DAV path of the item, relative to the DAViCal base path */ function log_caldav_action( $action_type, $uid, $user_no, $collection_id, $dav_name ) { - global $c; - $logline = sprintf( '%s %s %s %s %s %s', gmdate('Ymd\THis\Z'), $action_type, $uid, $user_no, $collection_id, $dav_name ); - if ( !isset($c->action_log_name) ) { - error_log( $logline ); - return; - } + $logline = sprintf( '%s, %s, %s, %s, %s', $action_type, $uid, $user_no, $collection_id, $dav_name ); - $logline .= "\n"; + openlog('davical', LOG_PID, LOG_LOCAL0); + syslog(LOG_INFO, $logline); + closelog(); + +} +function post_commit_action( $action_type, $uid, $user_no, $collection_id, $dav_name ) { + + $logline = sprintf( '%s, %s, %s, %s, %s', $action_type, $uid, $user_no, $collection_id, $dav_name ); + + openlog('davical', LOG_PID, LOG_LOCAL0); + syslog(LOG_INFO, $logline); + closelog(); - $logfile = fopen( $c->action_log_name, "a+" ); - fwrite( $logfile, $logline ); - fclose($logfile); }