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

convertLevelToSeverity Method behaves incorrectly #78

Open
hulkthedev opened this issue Nov 16, 2022 · 0 comments
Open

convertLevelToSeverity Method behaves incorrectly #78

hulkthedev opened this issue Nov 16, 2022 · 0 comments

Comments

@hulkthedev
Copy link

Hallo,

$engine = \Cake\Log\Log::engine('error');

$engine->debug("Debug thing", ['bla'=>new \Exception('Debug exception')]); // ok
$engine->info("Info thing", ['bla'=>new \Exception('Info exception')]); // ok
$engine->warning("Warn thing", ['bla'=>new \Exception('Warn exception')]); // ok
$engine->error("Error thing", ['bla'=>new \Exception('Error exception')]); // ok

$engine->notice("Notice thing", ['bla'=>new \Exception('Notice exception')]); // error
$engine->critical("Critical thing", ['bla'=>new \Exception('Critical exception')]); // error
$engine->alert("Alert thing", ['bla'=>new \Exception('Alert exception')]); // error
$engine->emergency("Emergency thing", ['bla'=>new \Exception('Emergency exception')]); // error

Error:
"Sentry\\Severity::fromError(): Argument #1 ($severity) must be of type int, string given, called in /app/vendor/connehito/cake-sentry/src/Http/Client.php on line 144"

"notice", "alert", "critical" and "emergency" are log levels as a string which cause a TypeError when passed to the "fromError" method.

Since Sentry does not support these log levels, it tries to set them to the "Error" level (notices as info level), but it fails because the "fromError" method only accepts integers as the level.

With the call
$engine->log(E_NOTICE, "Notice thing", ['bla'=>new \Exception('Notice exception')]);
it works again. The error is logged with info level.

Please adapt the method so that all log levels are mapped correctly, regardless of whether they are strings or integers.
My workaround is now to overwrite the log method and set the log level myself before passing it to the parent method. Not nice.

Thanks

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

No branches or pull requests

1 participant