Skip to content

Instantly share code, notes, and snippets.

@xurenlu
Created December 1, 2011 06:32
Show Gist options
  • Save xurenlu/1414333 to your computer and use it in GitHub Desktop.
Save xurenlu/1414333 to your computer and use it in GitHub Desktop.
php errorlog modify
<?php
register_shutdown_function('handleShutdown');
function handleShutdown() {
$error = error_get_last();
if($error !== NULL){
$info = "[SHUTDOWN] file:".$error['file']." | ln:".$error['line']." | msg:".$error['message'] .PHP_EOL;
$sapi_type = php_sapi_name();
$sapi = substr($sapi_type, 0, 3);
if($sapi=="cli"){
$info .= join(" ",$_SERVER["argv"]);
}else{
$info .= $_SERVER["HTTP_HOST"]."".$_SERVER["REQUEST_URI"];
}
error_log($info.PHP_EOL,3,ini_get("error_log"));
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment