Commit f1aeb50c by irul

add log with addtional arguments

1 parent 6e9a6e9e
......@@ -86,7 +86,14 @@ class Logger
public function log($string)
{
$log_source = sprintf("%s:%d", basename(debug_backtrace()[0]['file']), debug_backtrace()[0]['line']);
$this->do_write($string, $log_source);
$args = func_get_args();
if (count($args) > 1) {
array_shift($args);
$log_string = vsprintf($string, $args);
} else {
$log_string = $string;
}
$this->do_write($log_string, $log_source);
}
/*
......
......@@ -8,3 +8,4 @@ require_once 'Logger.php';
/* Define log path and log filename */
$logger = Logger::get_logger('./logs', 'my-log');
$logger->log("set log path and filename");
$logger->log("log with addtional arguments: %s, %s", "msg1", "msg2");
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!