Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.1] Use laravel's log writer class instead of monolog. #10922

Merged
merged 1 commit into from
Nov 13, 2015

Conversation

usm4n
Copy link
Contributor

@usm4n usm4n commented Nov 13, 2015

Our Laravel's cool Illuminate\Log\Writer already implements the Psr\Log\LoggerInterface interface. Using the Monolog logger for the Psr\Log\LoggerInterface binding bypasses the Logging event system of the laravel. For instance, I just wanted to log all the exceptions to the console for the quick view 👓 :

    public function boot(DispatcherContract $events)
    {
        parent::boot($events);

        $events->listen('illuminate.log',function($level, $message) {

             $output = new \Symfony\Component\Console\Output\ConsoleOutput(3);

             $output->writeln('Console Log::' . $level . ': ' . $message);
             $output->writeln("++++++++++++++++++++++++++++++++++++++++++++++++++++++");

        });

        //
    }

And found out that the events were not firing, because the Monolog\Logger was being injected for the Psr\Log\LoggerInterface.

I hope it all make sense :)

Usman.

// Next, we will bind a Closure that resolves the PSR logger implementation
// as this will grant us the ability to be interoperable with many other
// libraries which are able to utilize the PSR standardized interface.
$app->bind('Psr\Log\LoggerInterface', function ($app) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Psr\Log\LoggerInterfaced is already aliased in the Container : https://github.com/laravel/framework/blob/5.1/src/Illuminate/Foundation/Application.php#L1048

@GrahamCampbell
Copy link
Member

Maybe this should go to 5.2, since it's not really broken atm, and could have undesired consequences.

@usm4n
Copy link
Contributor Author

usm4n commented Nov 13, 2015

@GrahamCampbell let us see what Taylor says. I don't have any issues with this to go in 5.2.

@usm4n
Copy link
Contributor Author

usm4n commented Nov 13, 2015

But as 5.1 is LTS, this should be fixed in 5.1 as well.

@GrahamCampbell
Copy link
Member

But as 5.1 is LTS, this should be fixed in 5.1 as well.

Nothing is broken though, so it's not a fix.

@usm4n
Copy link
Contributor Author

usm4n commented Nov 13, 2015

Yeah, but the behaviour is undesired IMHO.

taylorotwell added a commit that referenced this pull request Nov 13, 2015
[5.1] Use laravel's log writer class instead of monolog.
@taylorotwell taylorotwell merged commit 7e98997 into laravel:5.1 Nov 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants