This project is part of the @thi.ng/umbrella monorepo.
File output handler for @thi.ng/rstream-log, providing structured, multilevel & hierarchical loggers based on @thi.ng/rstream. Node only package.
This feature was previously part of @thi.ng/rstream-log, but has been extracted to avoid build issues with bundlers. See that package for further usage info.
yarn add @thi.ng/rstream-log @thi.ng/rstream-log-file
import * as log from "@thi.ng/rstream-log";
import { writeFile } from "@thi.ng/rstream-log-file";
const logger = new log.Logger("main");
// add file output w/ post-filtering (only WARN or ERROR levels)
// and formatted as JSON
const writer = logger.transform(log.minLevel(log.Level.WARN), log.formatJSON()).subscribe(writeFile("main.log"));
logger.warn("eek!");
// appended to file:
// {"level":"WARN","id":"main","time":"2018-01-23T09:05:55.647Z","body":["eek!"]}
// optionally, cancel file writer
writer.done();
- Karsten Schmidt
© 2018 Karsten Schmidt // Apache Software License 2.0