somsip / logger
Extensions and variations for use with Monolog
This package's canonical repository appears to be gone and the package has been frozen as a result.
dev-master
2016-04-27 15:37 UTC
Requires
- monolog/monolog: 1.*
Requires (Dev)
- phpunit/phpunit: ~4.0
This package is not auto-updated.
Last update: 2023-02-04 09:57:53 UTC
README
Currently there is only one extension which injects the calling Class::function() into the log entry. Eg:
Log::debug('called');
(outputs)
[2016-04-21 23:51:42] testing.DEBUG: AdminController::home() called
Laravel
This works with Laravel 5.1 (and maybe others). This can be accomplished by adding the following to AppServiceProvider:
use Monolog\Logger;
use Monolog\Processor\IntrospectionProcessor;
use Somsip\Logger\Formatter\CallerInlineFormatter;
And in the register() method:
// Setup some custom logging
$monolog = Log::getMonolog();
// Change the default formatter
$monolog->getHandlers()[0]->setFormatter(new CallerInlineFormatter());
// Get all output from logger, but ignore references to non-app classes
$ignores = [
'Writer',
'Facade'
];
$monolog->pushProcessor(new IntrospectionProcessor(Logger::DEBUG, $ignores));