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

Symfony\Component\ErrorHandler\Error\FatalError: Declaration of Maxbanton\Cwh\Handler\CloudWatch::write(array $record): void must be compatible with Monolog\Handler\AbstractProcessingHandler::write(Monolog\LogRecord $record): void in file /maxbanton/cwh/src/Handler/CloudWatch.php on line 164 #46

Open
edenmydev opened this issue Sep 27, 2023 · 1 comment

Comments

@edenmydev
Copy link

edenmydev commented Sep 27, 2023

"laravel/framework": "v10.19.0"
"pagevamp/laravel-cloudwatch-logs":"v1.1.1",
"monolog/monolog": "3.4.0",

I added in logging.php
'cloudwatch' => [
'driver' => 'custom',
'name' => env('CLOUDWATCH_LOG_NAME', ''),
'region' => env('CLOUDWATCH_LOG_REGION', ''),
'credentials' => [
'key' => env('CLOUDWATCH_LOG_KEY', ''),
'secret' => env('CLOUDWATCH_LOG_SECRET', '')
],
'stream_name' => env('CLOUDWATCH_LOG_STREAM_NAME', 'laravel_app'),
'retention' => env('CLOUDWATCH_LOG_RETENTION_DAYS', 14),
'group_name' => env('CLOUDWATCH_LOG_GROUP_NAME', 'laravel_app'),
'version' => env('CLOUDWATCH_LOG_VERSION', 'latest'),
'formatter' => \Monolog\Formatter\JsonFormatter::class,
'batch_size' => env('CLOUDWATCH_LOG_BATCH_SIZE', 10000),
'via' => \Pagevamp\Logger::class,
],

The option 'via' causes to get the error when i run a simple log Symfony\Component\ErrorHandler\Error\FatalError: Declaration of Maxbanton\Cwh\Handler\CloudWatch::write(array $record): void must be compatible with Monolog\Handler\AbstractProcessingHandler::write(Monolog\LogRecord $record): void in file /maxbanton/cwh/src/Handler/CloudWatch.php on line 164

I found that the monolog/monolog version need to be under 3.0.0 to make it works. But laravel/framework v10 requires monolog version to be upper than 3.0.

how can we solve this issue please?

@markinjapan
Copy link

markinjapan commented Oct 4, 2023

FYI the maxbanton/cwh package has been abandoned. I've created a fork phpnexus/cwh and upgraded it to work with monolog/monolog v3 and PHP 8.1.

Simply replace maxbanton/cwh with phpnexus/cwh in the composer.json file, and Maxbanton\Cwh with PhpNexus\Cwh in your code.

Then you'll be able to upgrade monolog/monolog to v3 and laravel/framework to v10.

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

No branches or pull requests

2 participants