Need private packages and team management tools?Check out npm Teams »

@thi.ng/rstream-log

3.1.18 • Public • Published

rstream-log

npm version npm downloads Twitter Follow

This project is part of the @thi.ng/umbrella monorepo.

About

Structured, multilevel & hierarchical loggers based on @thi.ng/rstream.

This package provides extensible, multi-level & multi-hierarchy logging infrastructure, with logged values transformable via @thi.ng/transducers. Several built-in transformers are provided.

The Logger class provided by this package implements the @thi.ng/api ILogger interface and uses LogLevel enums to configure levels / filtering.

Status

STABLE - used in production

Support packages

Installation

yarn add @thi.ng/rstream-log

Package sizes (gzipped, pre-treeshake): ESM: 736 bytes / CJS: 863 bytes / UMD: 917 bytes

Dependencies

API

Generated API docs

import { LogLevel } from "@thi.ng/api";
import * as log from "@thi.ng/rstream-log";
 
const logger = new log.Logger("main");
// or with min level
const logger = new log.Logger("main", LogLevel.DEBUG);
 
// add console output w/ string formatter (a transducer)
logger.subscribe(log.writeConsole(), log.formatString());
 
logger.debug("hello world");
// [DEBUG] [main] 2018-01-20T09:04:05.198Z hello world
 
logger.warn("eek");
// [WARN] [main] 2018-01-20T09:04:16.913Z eek
 
// each logger instance is a rstream StreamMerge instance
// allowing to form logger hierarchies
 
const mod1 = new log.Logger("module-1", LogLevel.INFO);
// pipe mod1 into main logger
logger.add(mod1);
 
import { postWorker } from "@thi.ng/rstream";
// additionally send messages from this logger to worker
mod1.subscribe(postWorker("log-worker.js"));
 
mod1.info("hi from sub-module");
 
// only shown in console:
// [INFO] [module-1] 2018-01-20T09:05:21.198Z hi from sub-module

TODO

Authors

Karsten Schmidt

License

© 2017 - 2020 Karsten Schmidt // Apache Software License 2.0

Install

npm i @thi.ng/rstream-log

DownloadsWeekly Downloads

158

Version

3.1.18

License

Apache-2.0

Unpacked Size

35.7 kB

Total Files

21

Last publish

Collaborators

  • avatar