sh.log-client
v2.10.4
Published
A generic node.js client to log messages cross-platform. Its complement, 'LogCentral', is a .Net-based server that offers various transport mechanisms and collects messages from arbitrary many clients.
Downloads
9
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
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 itslog()
-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 enabledInMemoryLogger<T>
andInMemoryLogMessage<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 aWritable
-stream. Supports different streams per log level.
Included Extras
Currently, these extras are included:
LoggerPipe
is aWritable
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 Transporter
s has been removed entirely.