-
Notifications
You must be signed in to change notification settings - Fork 434
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): topicLogger for headers #5586
Conversation
@@ -5,25 +5,20 @@ | |||
|
|||
import * as vscode from 'vscode' | |||
|
|||
/** define log topics */ | |||
type LogTopic = 'Unknown' | 'Test' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type LogTopic = 'Unknown' | 'Test' | |
type LogTopic = 'unknown' | 'test' |
* Used as a wrapper around the logger interface for appending messages | ||
* Also more compatible with future change | ||
*/ | ||
abstract class baseLogger implements Logger { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WinstonToolkitLogger
is referenced in only a few isolated places--it's already "encapsulated". The logger interface is essentially getLogger()
, and already abstracts logging for the codebase.
Our base logger is winstonToolkitLogger.ts
, but it has a misleading name. At present it happens to use winston as the "backend", but that can always be changed in the future without any accruing costs / tech debt. Whereas in the meantime, adding extra indirection (in the form of 2 new classes, TopicLogger
and baseLogger
) is a permanent cost that may never pay off.
To summarize, the near-term steps we can take are:
- rename
winstonToolkitLogger.ts
totoolkitLogger.ts
. - add
addTopicToMessage
to it.
In the future if we need other logger implementations, those can be added at near-zero cost because callers are already using the getLogger()
abstraction.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this Base class can apply to the existing loggers NullLogger
, ConsoleLogger
, and the WinstonLogger. Would it make sense to have them all the implement this abstract class? This will allow us to drop each of their duplicated info(), debug(),...
methods
Winston logger would still have the addTopicToMessage()
method as Justin suggested
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure that makes sense
Problem
Log message can appear in output channels(such as Amazon Q Logs as shown), IDE Debug console, or write to pre-defined log file destinations. They come from all parts of our services and can amount to large and lengthy chunks quickly.
We don’t have a reliable way to identify log messages from various services and modules of our product. Some messages might have headers while others don’t, and the existing headers are hard-coded on a message by message basis, with no checks for consistency.
Solution
License: I confirm that my contribution is made under the terms of the Apache 2.0 license.