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

Refactor logging #61

Merged
merged 7 commits into from
Nov 13, 2024
Merged

Refactor logging #61

merged 7 commits into from
Nov 13, 2024

Conversation

main-kun
Copy link
Contributor

  • Adds NodekitLogger interface to remove direct dependency on pino.Logger and allow creating context with other loggers
  • Adds PinoLogger as a default logger implementation
  • Adds logWarn method to AppContext to support warn level logging
  • Cleans up logError to match logWarn

@melikhov-dev
Copy link
Contributor

This is fine for refactoring, but I don't see an API for initializing Nodekit with another logger.
Can you add test for this case?

src/index.ts Outdated Show resolved Hide resolved
}
}

trace(message: string): void;
Copy link
Contributor

Choose a reason for hiding this comment

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

do we use trace and debug somewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

#60 - will be used here. We're gonna have to merge this one first and rebase the opentracing one on top of this.


export interface NodekitLogger {
info(message: string): void;
info(extra: Dict | undefined, message: string): void;
Copy link
Contributor

@resure resure Nov 12, 2024

Choose a reason for hiding this comment

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

Shouldn't message be first argument (for consistency with context class loggers)? Or it would be better to be consistent with pino logger class methods?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The intention was to be consistent with pino first. I think it makes sense to do this rather than reorder the arguments of every call to the logger.

@resure
Copy link
Contributor

resure commented Nov 12, 2024

You probably should coordinate this PR with #60 and decide what should be merged first.

@main-kun
Copy link
Contributor Author

main-kun commented Nov 12, 2024

You probably should coordinate this PR with #60 and decide what should be merged first.

Yea, we discussed it and agreed that this one should be merged first.

@main-kun
Copy link
Contributor Author

@melikhov-dev I've added a config option for passing a ready-made logger and added tests for it. Please take a look again.

@melikhov-dev
Copy link
Contributor

@main-kun LGTM

@main-kun main-kun merged commit dfeae88 into main Nov 13, 2024
4 checks passed
@main-kun main-kun deleted the compatibility-alignment branch November 13, 2024 11:15
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

Successfully merging this pull request may close these issues.

3 participants