Skip to content

Global logger service that logs in job #90

@yann-eugone

Description

@yann-eugone

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 logger
  • PostExecuteEvent 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

https://github.com/symfony/monolog-bundle/blob/master/DependencyInjection/Configuration.php#L29

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions