-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Log improvements and new log handler #4674
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
Conversation
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.
Great contrib, wonderful docs!
std/log/handlers.ts
Outdated
/** @deprecated - `this._writer.write()` is an async call. Under heavy load | ||
* testing has shown a significant loss of log messages being written. Also, | ||
* if the process terminates while writing a log, that log message is also | ||
* lost. It is recommended that handlers override this method with a | ||
* synchronous implementation (see FileHandler). | ||
*/ |
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.
Just remove this method completely, no need to mark it as deprecated
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.
As the WriteHandler
class is abstract, I've removed the @deprecated
comment and changed this log method to be abstract too. This will generate compile errors for anyone currently subclassing WriterHandler
with a custom implementation rather than if I removed it entirely, which would cause log()
fall back to BaseHandler
with a noop log method which could confuse or cause issues.
this._writer = this._file; | ||
} | ||
|
||
log(msg: string): void { |
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.
Just an idea - support both log
and logSync
methods?
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.
Yes, I considered this too. This definitely needs more thought though as I think the async implementation isn't straightforward, at least to get something robust which can handle high throughput. Something for another PR I think.
Error, | ||
"maxBackupCount cannot be less than 1" | ||
); | ||
}, |
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.
Very nice tests
Thanks for the review @bartlomieju. That's my review changes now uploaded. |
This PR brings a number of improvements to the std logger:
cc @bartlomieju