Skip to content

Instantly share code, notes, and snippets.

@xatest
Created September 13, 2012 17:17
Show Gist options
  • Save xatest/3715930 to your computer and use it in GitHub Desktop.
Save xatest/3715930 to your computer and use it in GitHub Desktop.
add function to Logger err()
public static function err($str)
{
if ( !strlen($str) ) {
return false;
}
if ( empty(self::$log) ) {
self::$log = new Logger(LOG_NAME);
}
if (self::$log->level < self::ERR) {
return false;
}
$trc = debug_backtrace();
$s = "[" . date('Y-m-d H:i:s') . "]";
$s .= "[ERR][PID=" . trim(self::$log->processID) . "]";
$fileList = preg_split('[\/]', $trc[0]['file']);
$s .= "[file=" . $fileList[count($fileList) - 1] . "]";
$s .= "[func=" . $trc[0]['function'] . "]";
$s .= "[line=" . $trc[0]['line'] . "]";
$s .= "[ip=" . trim(self::$log->ip) . "]";
$s .= $str;
self::_write($s);
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment