Skip to content

Instantly share code, notes, and snippets.

@jhonata-menezes
Created February 10, 2017 12:55
Show Gist options
  • Save jhonata-menezes/fad588bc422fe3f7b899ba82bb1f4c27 to your computer and use it in GitHub Desktop.
Save jhonata-menezes/fad588bc422fe3f7b899ba82bb1f4c27 to your computer and use it in GitHub Desktop.
<?php
$logger = new Logger('name_app');
$logger->pushProcessor(function(array $record){
if($record['level_name'] >= Logger::ERROR){
$record['context'] = debug_backtrace();
}
$debug = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 10);
if(count($debug) >= 6 && isset($debug[6]['class'], $debug[6]['line'], $debug[6]['function'])){
$record['level_name'] = sprintf('%s::%s', $debug[6]['class'], $debug[6]['function']);//add name class and function
}
return $record;
});
//output
//2017-02-10 10:53:40 forseti-app.Forseti\App\Name\Class::functionName : my name not is Johnny
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment