Logging API

Last modified by Manuel Leduc on 2024/03/11 14:39

 Cristal
 Design
 Active
 
 

https://forum.xwiki.org/t/choice-of-logging-api/14217

Description

A logging API is useful for accurate error reporting. Especially as the logs won't be on the server, but on the user's client (i.e., browser or electron instance).

API Requirements

The minimal need is to have the following logging levels:

  • Debug
  • Info
  • Warning
  • Error

Existing Libraries

Architecture

The suggested architecture is to define our own logging API, but to delegate the actual implementation to the selected library.

That was, we can more easily switch from one library to another if needed.

The main constraint is that we need to be careful not to define our API with operations specific to a given implementation

Design decisions

  • While browsers have the ability to filter logs, do we have the possibility to also skip at log time:
    • based on the logger location (e.g., its module)?
    • based on the log level?

Criteria

  • Library size
  • Maintainers
  • Support for browsers (i.e., not node only)
  • Can log in a human-readable format (i.e., not json only)
  • Support for typescript
  • Support for named loggers (i.e., ability to create new logger with specific log levels)
  • Support for formatting. Excluded as Javascript/Typescript have support for formatting at language level.

Choice

LibraryConclusionSizeMaintainerLicenseFor BrowserHuman-ReadableTypescriptSupport for Named Logger
Pino 12k2 main maintainers, last release on Feb. 2024MITaccept yesaccept yesaccept yeserror we would need to implement it ourselves
LogLevel 8k (minified)error Mainly one contributor, last release Jan. 2024
Looks well documented and stable.
MITaccept yesaccept yesaccept yesaccept yes
Browser API 0 (bundled)accept supported by all browsers we supportbundled in browsersaccept yesaccept yesaccept yeserror We would need to implement it ourselves
Roarr

cancel Not free

error Does very little as the concrete way to log is to be defined manually, the library is mostly providing high-level abstractions that we probably don't need, or would redefine in our own API

20k (minified)error Mainly one contributor, last release on Nov. 2023.cancel not freeaccept yesaccept yesaccept yeserror partial, can be custom-made using the “context” metadata
Winstoncancel No Good support for browsers  MITcancel no   
Bunyancancel No good support for browsers  MITcancel no   
Npmlogcancel No browser support   cancel   
 

 

Get Connected