Options
All
  • Public
  • Public/Protected
  • All
Menu

@thi.ng/rstream-log-file

rstream-log-file

npm versionnpm downloads Twitter Follow

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

About

File output handler for structured, multilevel & hierarchical loggers based on @thi.ng/rstream. This is a support package for @thi.ng/rstream-log.

Status

STABLE - used in production

Installation

yarn add @thi.ng/rstream-log-file
// ES module
<script type="module" src="https://unpkg.com/@thi.ng/rstream-log-file?module" crossorigin></script>

// UMD
<script src="https://unpkg.com/@thi.ng/rstream-log-file/lib/index.umd.js" crossorigin></script>

Package sizes (gzipped, pre-treeshake): ESM: 129 bytes / CJS: 182 bytes / UMD: 300 bytes

Dependencies

API

Generated API docs

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();

Authors

Karsten Schmidt

License

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

Generated using TypeDoc