The Laravel helper logger() returns the Logger singleton as defined by Laravel's LogServiceProvider. When adding a monolog handler to this log, it will make Monolog write to Laravel's default log and the new log. To circumvent this you could pop all handlers from the underlying Monolog instance before adding your own, though I am uncertain what kind of repercussions that would have on the rest of the logging functionality.
As such I went with creating a new logger altogether. Laravel's handler uses a Monolog channel name based on the app environment, but I think hardcoding one for a dedicated log file is fine as well.
Now, since this is wanted behavior and not covered by any of the tests, I recommend to create another one to test for it:
Make log path configurable (?)
Include a virtual file stream package for testing (such as adlawson/vfs)
Overwrite the storage_path helper to aim at a virtual file stream path, so that laravel's logs get posted in it
Configure this package's log path (for testing) to aim at the virtual file stream also
Force a lost-in-translation notice to be logged
Assert the laravel log to be empty and the lost-in-translation log to have content
If you agree with this plan of action I'll gladly give it a shot to implement this myself.
Coverage remained the same at 100.0% when pulling b6047acbd17766b6c598fcc3265492c98a853bc2 on padarom:develop into 4fb656bad99e313375969117de566c8c859fbbb4 on stevegrunwell:develop.
This PR solves #1.
The Laravel helper
logger()
returns the Logger singleton as defined by Laravel'sLogServiceProvider
. When adding a monolog handler to this log, it will make Monolog write to Laravel's default log and the new log. To circumvent this you could pop all handlers from the underlying Monolog instance before adding your own, though I am uncertain what kind of repercussions that would have on the rest of the logging functionality.As such I went with creating a new logger altogether. Laravel's handler uses a Monolog channel name based on the app environment, but I think hardcoding one for a dedicated log file is fine as well.
Now, since this is wanted behavior and not covered by any of the tests, I recommend to create another one to test for it:
adlawson/vfs
)storage_path
helper to aim at a virtual file stream path, so that laravel's logs get posted in itIf you agree with this plan of action I'll gladly give it a shot to implement this myself.