laravel / octane

Supercharge your Laravel application's performance.
https://laravel.com/docs/octane
MIT License
3.78k stars 296 forks source link

Wrong label for `INFO` and `WARNING` logs in terminal #272

Closed smortexa closed 3 years ago

smortexa commented 3 years ago

Description:

Octane labels Log::info(), Log::warning('bar') and logger() as ERROR in terminal.

Steps To Reproduce:

DanCharousek commented 3 years ago

@seyed-me

I thought that I had a similar problem so I looked into it. It seems this is not an issue with Octane itself. If you server freshly installed Laravel app with Octane and try to Log::debug, Log::info or Log::warn you will probably find out that it does not do anything. The default LOG_CHANNEL is stack. If you check the config/logging.php you'll see that the stack includes only channel single by default.

In my case, the "issue" was, that besides single I had also stderr included in the channel list of the stack ('channels' => ['single', 'stderr']. This caused all output from the logger to appear in the console with ERROR label.

If you look closer into https://github.com/laravel/octane/blob/1.x/src/Commands/Concerns/InteractsWithIO.php you'll see that Octane logs are being sent to the stdout. I do not thing you are able to output custom log levels into Octane's terminal output at the moment (although I might be wrong).

Try this simple demo:

Route::get('/', function () {
    fwrite(STDERR, 'Lorem ipsum!');
    fwrite(STDOUT, 'Hello world!' . PHP_EOL);

    return view('welcome');
});

And you should see something similar in the terminal after hitting localhost:8000:

image

Hope this helps.

nunomaduro commented 3 years ago

@DanCharousek is correct.