This commit is contained in:
Shish 2013-08-29 20:23:08 +01:00
parent 12bc4a90f7
commit 7c140680b7
2 changed files with 14 additions and 8 deletions

View File

@ -250,10 +250,16 @@ class LogEvent extends Event {
*/ */
var $time; 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->section = $section;
$this->priority = $priority; $this->priority = $priority;
$this->message = $message; $this->message = $message;
$this->args = $args;
$this->time = time(); $this->time = time();
} }
} }

View File

@ -902,8 +902,8 @@ define("SCORE_LOG_NOTSET", 0);
* $flash = true - show the message to the user as well * $flash = true - show the message to the user as well
* $flash = "some string" - log the message, flash the string * $flash = "some string" - log the message, flash the string
*/ */
function log_msg(/*string*/ $section, /*int*/ $priority, /*string*/ $message, $flash=null) { function log_msg(/*string*/ $section, /*int*/ $priority, /*string*/ $message, $flash=null, $args=array()) {
send_event(new LogEvent($section, $priority, $message)); send_event(new LogEvent($section, $priority, $message, $args));
$threshold = defined("CLI_LOG_LEVEL") ? CLI_LOG_LEVEL : 0; $threshold = defined("CLI_LOG_LEVEL") ? CLI_LOG_LEVEL : 0;
if(is_cli() && ($priority >= $threshold)) { if(is_cli() && ($priority >= $threshold)) {
print date("c")." $section: $message\n"; 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 // More shorthand ways of logging
function log_debug( /*string*/ $section, /*string*/ $message, $flash=null) {log_msg($section, SCORE_LOG_DEBUG, $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) {log_msg($section, SCORE_LOG_INFO, $message, $flash);} 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) {log_msg($section, SCORE_LOG_WARNING, $message, $flash);} 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) {log_msg($section, SCORE_LOG_ERROR, $message, $flash);} 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) {log_msg($section, SCORE_LOG_CRITICAL, $message, $flash);} function log_critical(/*string*/ $section, /*string*/ $message, $flash=null, $args=array()) {log_msg($section, SCORE_LOG_CRITICAL, $message, $flash, $args);}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\