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

Logs formatted as valid json breaks octane #315

Closed
henriquebremenkanp opened this issue Jun 10, 2021 · 0 comments · Fixed by #316
Closed

Logs formatted as valid json breaks octane #315

henriquebremenkanp opened this issue Jun 10, 2021 · 0 comments · Fixed by #316
Labels

Comments

@henriquebremenkanp
Copy link
Contributor

  • Octane Version: 1.0.4
  • Laravel Version: 8.46.0
  • PHP Version: 8.0.7
  • Server & Version: Swoole 4.6.7
  • Database Driver & Version: N/A

Description:

The swoole server acknowledges a log entry as something else (a request I guess) and routes it to handleStream when the log entry is a valid JSON.

I don't know if there is any other better way to solve it, but when receiving a json before routing it to handleStream, adding a check for the required type key as well at least solves the issue for the format in Monolog\Formatter\JsonFormatter

It would still conflict with other logs that:

  1. Are valid json
  2. Contains the key type

Will send a PR in a few minutes, please take a look

Steps To Reproduce:

Create a laravel project and install octane

composer create-project --prefer-dist laravel/laravel laravel-octane
cd laravel-octane
composer require laravel/octane
php artisan octane:install

Add a log entry to AppServiceProvider so we don't need to call a route or anything just for demonstration purposes:

public function boot()
{
    \Log::debug('a');
}

Run octane (that will call the log when booting the application):

APP_KEY=$(php artisan key:generate --show) LOG_CHANNEL=stderr LOG_STDERR_FORMATTER=Monolog\\Formatter\\JsonFormatter php artisan octane:start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants