Skip to content

Conversation

cknight
Copy link
Contributor

@cknight cknight commented Apr 8, 2020

This PR brings a number of improvements to the std logger:

  • LogRecord is now immutable
  • Significant updates to README
  • Introduce new RotatingFileHandler
  • Introduce 'x' and 'w' file modes on log creation (in addition to 'a')
  • Fix issue with async log writes for FileHandler by making it synchronous, as the async version was dropping log messages in heavy load scenarios (and even hanging the process)

cc @bartlomieju

Copy link
Contributor

@Drunpy Drunpy left a 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!

@ry ry requested a review from bartlomieju April 8, 2020 22:42
Comment on lines 92 to 97
/** @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).
*/
Copy link
Member

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

Copy link
Contributor Author

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 {
Copy link
Member

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?

Copy link
Contributor Author

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"
);
},
Copy link
Member

Choose a reason for hiding this comment

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

Very nice tests

@cknight
Copy link
Contributor Author

cknight commented Apr 9, 2020

Thanks for the review @bartlomieju. That's my review changes now uploaded.

@bartlomieju bartlomieju merged commit 475a47c into denoland:master Apr 9, 2020
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 21, 2021
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 24, 2021
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 24, 2021
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 24, 2021
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 31, 2021
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 31, 2021
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 31, 2021
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 31, 2021
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Feb 1, 2021
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