laminas / laminas-log

Robust, composite logger with filtering, formatting, and PSR-3 support
https://docs.laminas.dev/laminas-log/
BSD 3-Clause "New" or "Revised" License
26 stars 30 forks source link

Implement PSR-3 for LoggerInterface #10

Closed panvid closed 4 years ago

panvid commented 4 years ago

Hey,

is there any information or discussion about implementing the PSR-3 standard for Logger (https://github.com/php-fig/log). We often have this problem (like using also Monolog Logger).

If not we will laminas-log and replace it with another framework.

Best regards, David

michalbundyra commented 4 years ago

@dpauli Have you seen the docs? https://docs.laminas.dev/laminas-log/psr3/

panvid commented 4 years ago

Ah, thx :-) Now I'm satisfied.

panvid commented 4 years ago

Okay, working with this solution causing the problem, that every usable Writer (like Noop or Stream) from Laminas not using the PSR-3 standard.

Is there a plan to change this, next major sounds nice? Or doublicating the given Writers for PSR usage?

weierophinney commented 4 years ago

The writers will work fine with PSR-3, assuming you use the PsrLoggerAdapter, which requires you to configure the logger and its writers slightly differently: see https://docs.laminas.dev/laminas-log/service-manager/#psrloggerabstractservicefactory (which was linked to from the page we linked you to originally).

Can you demonstrate what you have tried? It's likely a configuration issue, but we need to know what you're doing so that we can attempt to reproduce and either point out the correct configuration, or determine that there is a bug.

panvid commented 4 years ago

Perhaps I see it wrong, or does not get it:

The not-PSR3 Logger adds the Writer (https://github.com/laminas/laminas-log/blob/master/src/Logger.php#L273). The PSR3 Logger will be added by the PSR3 ready Writter (see https://github.com/laminas/laminas-log/blob/master/src/Writer/Psr.php#L64).

If I use the PSR3 Logger it can not be added by the old Writter. All Writer implementation in laminas-log are instances of the old Writer and cannot add the Logger.

Xerkus commented 4 years ago

@dpauli This library predates PSR Logger and was a direct influence over it. It means that laminas-logger is pretty close but slightly incompatible. PSR decorators were enough and difference did not warrant backwards incompatible change for existing users.

If you would like to handle the major undertaking preparing laminas-log 3.0.0 by bring it in line with PSR-3 and current Laminas code quality standards, we will be happy to provide guidance and assistance.

Xerkus commented 4 years ago

If I use the PSR3 Logger it can not be added by the old Writter. All Writer implementation in laminas-log are instances of the old Writer and cannot add the Logger

I did not understand that part. Writers are not part of PSR-3, they are library internal detail. When you want to use laminas-logger as a PSR-3 logger you would decorate it with Laminas\Log\PsrLoggerAdapter; when you want laminas-logger to write messages to another PSR-3 logger you would use Psr writer.

panvid commented 4 years ago

Thats I wanna say :) There is a interface of a PSR-3 Writer (Wrter\Psr) but no ready implementation in laminas-logger. All existing Writer (like Writer\Stream) are not PSR-3 ready and does not implement the Writer\Psr interface.

Therefore my question:

When laminas-logger will have implementation of Writer\Psr?

Xerkus commented 4 years ago

@dpauli I would suggest to move this topic to the forums as it is a support kind. https://discourse.laminas.dev/c/questions/components/6