sh.log-client

2.10.4 • Public • Published

LogClient

LogClient (or: log-client) is a universal module for nodejs or JavaScript applications in general for distributed logging using various transport methods. The concept of this logger is based on Microsoft.Extensions.Logging.

Install via npm Current Version

npm install sh.log-client

Included Loggers

Currently, this client includes the following loggers:

  • BaseLogger<T> the abstract base-class for all loggers that includes neccessary functionality, only having its log()-method abstract.
    • BaseScope<T> the base-class for scopes
  • ColoredConsoleLogger<T> a logger that outputs to the console's streams (info, warning, error) and is configurable w.r.t. to which level should be logged to which stream. Also supports colors.
  • DevNullLogger<T> a dummy logger that discards all messages and is always enabled
  • InMemoryLogger<T> and InMemoryLogMessage<T> a logger and its message to store log messages in memory. Supports specifying a maximum capacity so that only the newest messages are kept.
  • DualLogger<T, TLog1, TLog2> a logger that forwards all logging-calls to two other loggers without modifying them.
  • WrappedLogger<TLog1, TLog2> a logger that wraps and mimics an original logger (TLog1) and also forwards any logging calls to a 2nd copy-logger (TLog2). This is an extension to the DualLogger.
  • StreamLogger<T> a logger that writes messages to a Writable-stream. Supports different streams per log level.

Included Extras

Currently, these extras are included:

  • LoggerPipe is a Writable stream that encapsulates any of the above loggers and writes (pipes) all chunks to its log-method. This class is useful when a stream shall be piped to a logger (e.g. when having a logger for each of a process' streams).

Write and contribute your own Loggers

Writing an own logger is as simple as extending BaseLogger<T>. Please, submit a pull-request if you want to contribute your own logger to this repository.

Breaking changes since version 2.0.0

The log-client is supposed to be a functionally equivalent implementation of the logging functionalities found in util-dotnet (https://github.com/MrShoenel/util-dotnet). The concept of Transporters has been removed entirely.

Readme

Keywords

Package Sidebar

Install

npm i sh.log-client

Weekly Downloads

6

Version

2.10.4

License

MIT

Unpacked Size

50.6 kB

Total Files

14

Last publish

Collaborators

  • shoenel