An open API service indexing awesome lists of open source software.

https://github.com/mrshoenel/js-log-client

A generic node.js client to log messages cross-platform. Since v2.0.0, it is supposed to be functionally equal to the logging in util-dotnet.
https://github.com/mrshoenel/js-log-client

logging nodejs remote

Last synced: about 2 months ago
JSON representation

A generic node.js client to log messages cross-platform. Since v2.0.0, it is supposed to be functionally equal to the logging in util-dotnet.

Awesome Lists containing this project

README

          

# 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](https://img.shields.io/npm/v/sh.log-client.svg)](https://www.npmjs.com/package/sh.log-client)
`npm install sh.log-client`

## Included Loggers
Currently, this client includes the following loggers:
* __`BaseLogger`__ the abstract base-class for all loggers that includes neccessary functionality, only having its `log()`-method abstract.
* __`BaseScope`__ the base-class for scopes
* __`ColoredConsoleLogger`__ 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`__ a dummy logger that discards all messages and is always enabled
* __`InMemoryLogger`__ and __`InMemoryLogMessage`__ 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`__ a logger that forwards all logging-calls to two other loggers without modifying them.
* __`WrappedLogger`__ 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`__ 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`. 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 `Transporter`s has been removed entirely.