@sylo/logger
v0.2.0
Published
Extremely light-weight, unobtrusive & low buy-in logging module interface.
Downloads
654
Maintainers
Keywords
Readme
logger
Extremely light-weight, unobtrusive & low buy-in logging module interface.
interface ILogger {
log(level: Level, message: unknown, ...messages: unknown[]): void;
// derive logger that applies `f` to all inputs
// this enables creating contextualized sub-loggers
local(f: LogMod): typeof this;
// convenience log fns
error(message: unknown, ...messages: unknown[]): void;
warn(message: unknown, ...messages: unknown[]): void;
info(message: unknown, ...messages: unknown[]): void;
debug(message: unknown, ...messages: unknown[]): void;
// short-hand aliases
w(message: unknown, ...messages: unknown[]): void;
d(message: unknown, ...messages: unknown[]): void;
i(message: unknown, ...messages: unknown[]): void;
e(message: unknown, ...messages: unknown[]): void;
}
This package bundles two implementations, however, creating more platform specific backends is a breeze; see existing implementations for reference:
noopLogger
a logger that discards everythingconsoleLogger
a logger that prints via theconsole.log
family of functions
Running unit tests
Run nx test logger
to execute the unit tests via Jest.
Running lint
Run nx lint logger
to execute the lint via ESLint.