Replace LogHandler with LoggerInterface
fabiante opened this issue · comments
Hi,
I am currently testing this library and noticed that it is only possible to set a Monolog\Handler\HandlerInterface
for logging.
I think that using a Psr\Log\LoggerInterface
would be a better option.
In a typical dependency injection chain I would not directly use a Handler for logging but rather the logger itself.
If this seems sensible I could submit a PR.
Yeah, that sounds great! A PR would be very much appreciated.
Alright, will do ;)
@thelfensdrfer There are two routes I could go with this.
- Replace the existing
HandlerInterface
withLoggerInterface
- Add the option to use the
LoggerInterface
without removing anything
Option 1 would not be backward compatible. Option 2 would be backward compatible but requires a bit more effort.
What's your opinion on that?
I personally would prefer option 1 and would release a new major version after merging your changes, so that old code does not break.
I started implementation in #53 but moved in the direction of Option 2.
I could still completely remove the HandlerInterface
usage if you like. I guess it would be the correct thing, especially if you have no problem with releasing a new major version.
If you don't mind, that would be great. It's better to make a clean cut, since adding a new logger interface is clearly the better choice :)
Alright. I just now saw that the PR has trouble with the dependencies. To use the latest PSR3 package, I would have to update monolog. I figure the library itself shouldn't really have a lot of dependencies on monolog apart from the example. where a concrete logger is created.
To update the dependencies was on my todo list before creating a new major release, so please feel free to update at least the logger dependencies. But you are right that it shouldn't be required, so maybe move them to the dev section of the composer file?
Hmmm, I could do that but must admit I am not very confident in my composer skills. In the PR I had to downgrade the log PSR version anyway (because the latest requires php 8) and that would also resolve the other issues I hope.
Ok no problem, I can check it myself later.