Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

Litarnus
Copy link
Contributor

@Litarnus Litarnus commented Sep 15, 2025

Fixes an issue where we use a PSR-3 logger in the LogsAggregator but pass Sentry LogLevel into it, which might lead to errors in different loggers as they expect PSR-3 levels.

Closes #1902

@Litarnus Litarnus self-assigned this Sep 15, 2025
@Litarnus Litarnus marked this pull request as ready for review September 15, 2025 10:26
cursor[bot]

This comment was marked as outdated.

return \Psr\Log\LogLevel::CRITICAL;
case 'info':
default:
return \Psr\Log\LogLevel::INFO;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what's a good default level here but also this shouldn't really occur

@Litarnus Litarnus requested a review from cleptric September 15, 2025 10:49
@cleptric cleptric added the Bug label Sep 15, 2025
@mfb
Copy link
Contributor

mfb commented Sep 15, 2025

The one existential question I have is what does it mean if Sentry is logging a fatal error successfully? Does that mean Sentry is working normally - i.e. it's not really e.g. critical? :)

@cleptric
Copy link
Member

@mfb could you clarify your message above, as it raises some questions we do not fully understand.

@mfb
Copy link
Contributor

mfb commented Sep 16, 2025

If you look at HttpTransport, it logs at info level when an item is sent (whether debug or fatal); warning if rate limit is hit; error if sending fails. I was referring to how you're using a different philosophical approach with SDK logging for log items, by choosing a level based on the payload rather than how the SDK is functioning.

// We check if it's a `LogsLogger` to avoid a infinite loop where the logger is logging the logs it's writing
if ($sdkLogger !== null) {
$sdkLogger->log((string) $log->getLevel(), "Logs item: {$log->getBody()}", $log->attributes()->toSimpleArray());
$sdkLogger->log($log->getPsrLevel(), "Logs item: {$log->getBody()}", $log->attributes()->toSimpleArray());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What (I think) @mfb points out is that we copy the log level from the log item instead of logging always as "DEBUG" or "INFO" and mentioning the log level of the log item in the log message.

This was introduced by me I think, this maybe should be updated to mention the log item level in the log message and set our log level to debug (?).

In addition, the comment above this if is outdated and incorrect :) The LogsLogger never made it in but the comment remains 🙈

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case I did this very by the book 😎

Then maybe the comment could be updated but no other changes are needed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, great - as long as it's by design :)

It's not 100% clear to me but I guess "appropriate" is saying the Sentry log level should be translated to an appropriate level, e.g. log a "fatal" to the console as "critical". I'd also find it reasonable to just print the "fatal" level as part of an "info" log message - either way works for me.

@Litarnus Litarnus requested a review from stayallive September 18, 2025 11:45
@Litarnus Litarnus merged commit ac91687 into master Sep 22, 2025
39 checks passed
@Litarnus Litarnus deleted the martinl/log-level-fix branch September 22, 2025 13:13
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 this pull request may close these issues.

LogsAggregator tries to log to the SDK logger using the Sentry log level rather than a PSR-3 log level
4 participants