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

Incompatibility with Monolog 3 #108

Open
1 of 3 tasks
guillaumesmo opened this issue Nov 7, 2022 · 10 comments
Open
1 of 3 tasks

Incompatibility with Monolog 3 #108

guillaumesmo opened this issue Nov 7, 2022 · 10 comments
Assignees
Labels

Comments

@guillaumesmo
Copy link
Contributor

guillaumesmo commented Nov 7, 2022

Describe the bug
Support for Monolog v3 has been added in the composer file in v2.0.3: #106

However it seems like the methods are not compatible with the Monolog v3 interfaces:
Fatal error: Declaration of Maxbanton\Cwh\Handler\CloudWatch::write(array $record): void must be compatible with Monolog\Handler\AbstractProcessingHandler::write(Monolog\LogRecord $record): void in .../vendor/maxbanton/cwh/src/Handler/CloudWatch.php on line 164

Please tell about your environment:

  • PHP Version: 8.1.12
  • Operating system (distro): debian
  • Application mode:
    • Web app
    • CLI app
    • Daemon worker
@guillaumesmo
Copy link
Contributor Author

@maxbanton
Copy link
Owner

Hi @guillaumesmo.
I'm working on support of Monolog V3, could you please test cwh package from branch feature/php-8.1?
Something like this
composer require maxbanton/cwh:feature/php-8.1

@guillaumesmo
Copy link
Contributor Author

guillaumesmo commented Nov 9, 2022

@maxbanton, branch feature/php-8.1 seems to work fine with Monolog 3, except one small issue (might be on my side only):
Symfony throws an error when autowiring the CloudWatch class:
Fatal error: Uncaught Symfony\Component\DependencyInjection\Exception\RuntimeException: Unable to dump a service container if a parameter is an object or a resource
after some investigation it seems like this is due to the $level argument which is now an enum, and either it doesn't seem to be supported by Symfony autowiring, or it's a bug.

workaround is to set the $level argument in the service definition

  autowire: true
  class: Maxbanton\Cwh\Handler\CloudWatch
  arguments:
    $level: 100
    $level: !php/enum Monolog\Level::Debug # as of Symfony 6.2

However, I created this issue not because Monolog 3 is not yet supported, but because it has been (mistakenly?) added in the composer of maxbanton/cwh v2.0.3, so that version is actually broken if you don't hardcode Monolog v2 in your composer.json

@holtkamp
Copy link
Contributor

holtkamp commented Nov 9, 2022

#108 (comment) wow, yeah that seems to have been caused by me through #106 😨 , sorry guys!

@mad-briller
Copy link

would be great to see this resolved if possible, i see theres an open pr for php8.1 + monolog v3,
is there anything that needs to be done to get it over the line that i can help with ?

@aglipanci
Copy link

@maxbanton thanks for the package! Any plans to release the feature/php-8.1 in the near future?

@ravewill
Copy link

ravewill commented Aug 7, 2023

@maxbanton any Monolog 3 updates? This is blocking my migration to Laravel 10.

@mad-briller
Copy link

mad-briller commented Aug 7, 2023

an alternative to using this monolog handler is to setup the aws cloudwatch agent on your deployments that records the standard laravel.log output

@ravewill
Copy link

ravewill commented Aug 7, 2023

@mad-briller thanks, but that's not a good option for me. I'm running Dockerised Laravel in ECS - it's designed around having one process running so running a Cloudwatch agent alongside the web server under some kind of supervisor process adds complexity and is a bit of an antipattern.

@ravewill
Copy link

ravewill commented Aug 8, 2023

I switched to the fork phpnexus/cwh. Worked a treat!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants