Skip to content

Instantly share code, notes, and snippets.

@Freeaqingme
Created February 22, 2013 09:08
Show Gist options
  • Save Freeaqingme/5011931 to your computer and use it in GitHub Desktop.
Save Freeaqingme/5011931 to your computer and use it in GitHub Desktop.
PHP: Log parse errors to syslog()
<?php
register_shutdown_function(function() {
$error = error_get_last();
if (!$error) {
return;
}
switch($error['type']){
case E_ERROR:
case E_CORE_ERROR:
case E_COMPILE_ERROR:
case E_USER_ERROR:
case E_PARSE:
syslog(
LOG_EMERG,
sprintf('%s in file %s on line %d',
$error['message'],
$error['file'],
$error['line']
)
);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment