Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5 > Using monolog introspection processor

I have configured Laravel 5 to use a custom logging configuration (default is way too simple). I've added monolog's IntrospectionProcessor to log the file name and line number of the log call.

The problem is that all lines get the same file and line number:

[2015-06-29 17:31:46] local.DEBUG (/home/vagrant/project/vendor/laravel/framework/src/Illuminate/Log/Writer.php#201): Loading view...  [192.168.10.1 - GET /loans/create]

Is there a way to config the IntrospectionProcessor to print the actual lines and not the facade ones?

If I do Log::getMonolog()->info('Hello'); it works and prints the correct file and line number... but I don't know how safe is to avoid calling the Writer.writeLog function because it fires a log event (is it safe to not fire that event?).

like image 701
rvignacio Avatar asked Oct 27 '25 12:10

rvignacio


1 Answers

(Only tried in Laravel 4.2!)

When pushing the Introspection Processor to Monolog it is possible to give an skipClassesPartial array as second parameter in the IntrospectionProcessor contructor. With this array it is possible to skip the Laravel Illuminate classes and the logger logs the class calling the log method.

$log->pushProcessor(new IntrospectionProcessor(Logger::DEBUG, array('Illuminate\\')));

also see: https://github.com/Seldaek/monolog/blob/master/src/Monolog/Processor/IntrospectionProcessor.php

like image 114
Elisabeth L Avatar answered Oct 29 '25 00:10

Elisabeth L



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!