-
Notifications
You must be signed in to change notification settings - Fork 1
Closed
Labels
Description
Description
There is currently only one way to access the JobExecution
's logger: you need to get your hand on the JobExecution
itself.
Either by implementing JobExecutionAwareInterface
(if the component calling your class is aware of the trick).
Or passing the object all along the way as an argument.
Could be handy if we could just use a service that will abstract this mechanism.
Example
A class implementing LoggerInterface
.
This class should subscribe to:
PreExecuteEvent
to access and remember the loggerPostExecuteEvent
to forget the logger
When called to log, it delegates logging to either the remembered JobExecution
's logger, or a NullLogger
if nothing remembered.
In a symfony project, a monolog handler could be declared as of:
monolog:
handlers:
batch:
type: service
service:
id: service.to.be.defined