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

fix: ensure loggingLevels is respected #10308

Merged
merged 3 commits into from
Jan 2, 2025
Merged

Conversation

r1tsuu
Copy link
Member

@r1tsuu r1tsuu commented Jan 2, 2025

Issue #10272

Adds logError utility that can be used across the codebase for logging errors

fix: ensure `loggingLevels` is respected, import
@r1tsuu r1tsuu force-pushed the fix/respsect-logging-level branch from 1985601 to 9e71279 Compare January 2, 2025 18:53
@r1tsuu r1tsuu requested a review from DanRibbens January 2, 2025 19:11
Copy link
Contributor

@DanRibbens DanRibbens left a comment

Choose a reason for hiding this comment

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

Looks good. I have just a few nit-picks if you want to improve the logError function but not necessary.

if (level) {
payload.logger[level](
level === 'info'
? { msg: typeof err === 'object' && 'message' in err ? err.message : 'Error' }
Copy link
Contributor

Choose a reason for hiding this comment

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

I always try to avoid double ternaries as a general rule.

import type { Payload } from '../types/index.js'

export const logError = ({ err, payload }: { err: unknown; payload: Payload }): void => {
let level: pino.Level = 'error'
Copy link
Contributor

Choose a reason for hiding this comment

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

The type should be pino.Level | false, if we were in strict mode L15 would error since it doesn't match the loggingLevels type from the config.

@r1tsuu r1tsuu enabled auto-merge (squash) January 2, 2025 21:39
@r1tsuu r1tsuu merged commit 2e58a4a into main Jan 2, 2025
68 checks passed
@r1tsuu r1tsuu deleted the fix/respsect-logging-level branch January 2, 2025 21:42
r1tsuu added a commit that referenced this pull request Jan 2, 2025
Issue #10272

Adds `logError` utility that can be used across the codebase for logging
errors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants