From 7c140680b757489d6720a83da8f58c25f196f6f3 Mon Sep 17 00:00:00 2001 From: Shish Date: Thu, 29 Aug 2013 20:23:08 +0100 Subject: [PATCH] log args --- core/event.class.php | 8 +++++++- core/util.inc.php | 14 +++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/core/event.class.php b/core/event.class.php index 81dda8ee..4ff4a1e1 100644 --- a/core/event.class.php +++ b/core/event.class.php @@ -250,10 +250,16 @@ class LogEvent extends Event { */ var $time; - public function __construct($section, $priority, $message) { + /** + * Extra data to be held separate + */ + var $args; + + public function __construct($section, $priority, $message, $args) { $this->section = $section; $this->priority = $priority; $this->message = $message; + $this->args = $args; $this->time = time(); } } diff --git a/core/util.inc.php b/core/util.inc.php index 6dd9dbc3..73138cf9 100644 --- a/core/util.inc.php +++ b/core/util.inc.php @@ -902,8 +902,8 @@ define("SCORE_LOG_NOTSET", 0); * $flash = true - show the message to the user as well * $flash = "some string" - log the message, flash the string */ -function log_msg(/*string*/ $section, /*int*/ $priority, /*string*/ $message, $flash=null) { - send_event(new LogEvent($section, $priority, $message)); +function log_msg(/*string*/ $section, /*int*/ $priority, /*string*/ $message, $flash=null, $args=array()) { + send_event(new LogEvent($section, $priority, $message, $args)); $threshold = defined("CLI_LOG_LEVEL") ? CLI_LOG_LEVEL : 0; if(is_cli() && ($priority >= $threshold)) { print date("c")." $section: $message\n"; @@ -917,11 +917,11 @@ function log_msg(/*string*/ $section, /*int*/ $priority, /*string*/ $message, $f } // More shorthand ways of logging -function log_debug( /*string*/ $section, /*string*/ $message, $flash=null) {log_msg($section, SCORE_LOG_DEBUG, $message, $flash);} -function log_info( /*string*/ $section, /*string*/ $message, $flash=null) {log_msg($section, SCORE_LOG_INFO, $message, $flash);} -function log_warning( /*string*/ $section, /*string*/ $message, $flash=null) {log_msg($section, SCORE_LOG_WARNING, $message, $flash);} -function log_error( /*string*/ $section, /*string*/ $message, $flash=null) {log_msg($section, SCORE_LOG_ERROR, $message, $flash);} -function log_critical(/*string*/ $section, /*string*/ $message, $flash=null) {log_msg($section, SCORE_LOG_CRITICAL, $message, $flash);} +function log_debug( /*string*/ $section, /*string*/ $message, $flash=null, $args=array()) {log_msg($section, SCORE_LOG_DEBUG, $message, $flash, $args);} +function log_info( /*string*/ $section, /*string*/ $message, $flash=null, $args=array()) {log_msg($section, SCORE_LOG_INFO, $message, $flash, $args);} +function log_warning( /*string*/ $section, /*string*/ $message, $flash=null, $args=array()) {log_msg($section, SCORE_LOG_WARNING, $message, $flash, $args);} +function log_error( /*string*/ $section, /*string*/ $message, $flash=null, $args=array()) {log_msg($section, SCORE_LOG_ERROR, $message, $flash, $args);} +function log_critical(/*string*/ $section, /*string*/ $message, $flash=null, $args=array()) {log_msg($section, SCORE_LOG_CRITICAL, $message, $flash, $args);} /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\