Commit 6e9a6e9e by irul

add log source file and line number to log msg

1 parent fdc10bc8
...@@ -85,7 +85,8 @@ class Logger ...@@ -85,7 +85,8 @@ class Logger
* */ * */
public function log($string) public function log($string)
{ {
$this->do_write($string); $log_source = sprintf("%s:%d", basename(debug_backtrace()[0]['file']), debug_backtrace()[0]['line']);
$this->do_write($string, $log_source);
} }
/* /*
...@@ -99,7 +100,9 @@ class Logger ...@@ -99,7 +100,9 @@ class Logger
* */ * */
public function dump($var_name, $string = '') public function dump($var_name, $string = '')
{ {
$this->do_write((empty($string) ? 'VARDUMP ' : 'Dump of ') . $string . ' => ' . var_export($var_name, true)); $log_source = sprintf("%s:%d", basename(debug_backtrace()[0]['file']), debug_backtrace()[0]['line']);
$log_string = (empty($string) ? 'VARDUMP ' : 'Dump of ') . $string . ' => ' . var_export($var_name, true);
$this->do_write($log_string, $log_source);
} }
/* /*
...@@ -110,9 +113,9 @@ class Logger ...@@ -110,9 +113,9 @@ class Logger
* *
* $access public * $access public
* */ * */
public function do_write($log_string) public function do_write($log_string, $log_source)
{ {
$log_string = sprintf("%s %s", date(DATESTRING_FULL), $log_string); $log_string = sprintf("%s %s -- %s", date(DATESTRING_FULL), $log_string, $log_source);
$log_string = $log_string . PHP_EOL; $log_string = $log_string . PHP_EOL;
if ($this->user_handle) { if ($this->user_handle) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!