szjani / predaddy

DDD/CQRS/EventSourcing framework with annotation driven message bus
MIT License
169 stars 6 forks source link

Convert to PSR-3 logger methods #4

Closed redthor closed 8 years ago

redthor commented 9 years ago

Hi @szjani

We're getting deprecated notices for warn in SimpleMessageBus.

Would your advice be to use https://github.com/szjani/lf4php-psr3 or do you plan to convert the lf4php Logger interface to Psr\Log\LoggerInterface and therefore update predaddy?

Thanks, Doug

szjani commented 9 years ago

Hi @redthor,

I don't understand what notices you get. Which lf4php binder (lf4php-psr3?) and logging framework do you use when this issue happens?

It seems it's rather an lf4php issue than a predaddy one, but let's clarify it here.

szjani commented 9 years ago

I don't know how you got that notice, I think you may misconfigured something.

Predaddy does not depend on PSR-3, it depends on lf4php. lf4php is also an API just like PSR-3, but it has several extra features. It was designed before PSR-3 was released. It is not and never will be a PSR-3 implementation.

To use a logging framework through lf4php API, you need a logging framework of course and a proper lf4php binder. If you use monolog for instance, you can use the lf4php-monolog binder. lf4php-psr3 is also a binder which can be used for monolog (since that is a PSR-3 implementation), but PSR-3 definitely provides much less features than monolog directly, so I highly recommend to use monolog with lf4php-monolog.

Any logging framework you use, predaddy will depend on lf4php. It means it's your responsibility to pull a proper lf4php binder which will be used as a bridge between lf4php and the framework itself. If you don't define a binder as a dependency, lf4php will use NOPLoggerFactory, eventually predaddy will not log anything.

For more info please check lf4php documentation: https://github.com/szjani/lf4php

If your issue is still valid, please give some more details. Thanks.

redthor commented 8 years ago

Thanks @szjani

This is the actual error:

php.INFO: The Symfony\Bridge\Monolog\Logger::warn method inherited from the Symfony\Component\HttpKernel\Log\LoggerInterface interface is deprecated since version 2.2 and will be removed in 3.0. Use the warning() method instead, which is PSR-3 compatible.

here is part of the call stack:

{
    "stack": [
        {
            "class": "Symfony\\Component\\Debug\\ErrorHandler",
            "function": "handleError",
            "type": "->"
        },
        {
            "file": "tmp/cache/int_test/classes.php",
            "function": "trigger_error",
            "line": 3497
        },
        {
            "class": "Symfony\\Bridge\\Monolog\\Logger",
            "file": "www/vendor/lf4php/lf4php-monolog/src/lf4php/impl/MonologLoggerAdapter.php",
            "function": "warn",
            "line": 119,
            "type": "->"
        },
        {
            "class": "lf4php\\impl\\MonologLoggerAdapter",
            "file": "www/vendor/predaddy/predaddy/src/predaddy/messagehandling/SimpleMessageBus.php",
            "function": "warn",
            "line": 190,
            "type": "->"
        },
        {
            "class": "predaddy\\messagehandling\\SimpleMessageBus",
            "file": "www/vendor/predaddy/predaddy/src/predaddy/messagehandling/InterceptableMessageBus.php",
            "function": "dispatch",
            "line": 92,
            "type": "->"
        },
        {
            "class": "predaddy\\messagehandling\\InterceptableMessageBus",
            "function": "predaddy\\messagehandling\\{closure}",
            "type": "->"
        },

Should we just use your PSR-3 adapter? Thanks

szjani commented 8 years ago

Thank you, now it's clear.

I've found the following class which extends \Monolog\Logger: https://github.com/symfony/monolog-bridge/blob/2.8/Logger.php

It is a great example of violating the Liskov Substitution Principle. The maintainers should be informed about it.

Anyway, since it is not a big deal to change in the monolog binder, I've already done it. Please use version 3.1.2: https://github.com/szjani/lf4php-monolog/releases/tag/3.1.2

Thank you for the issue. If you still have any problems, don't hesitate to repoen this issue.

redthor commented 8 years ago

great job, thanks!