@thi.ng/rstream-log-file
TypeScript icon, indicating that this package has built-in type declarations

2.1.116 • Public • Published

@thi.ng/rstream-log-file

npm version npm downloads Mastodon Follow

[!NOTE] This is one of 190 standalone projects, maintained as part of the @thi.ng/umbrella monorepo and anti-framework.

🚀 Please help me to work full-time on these projects by sponsoring me on GitHub. Thank you! ❤️

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

Search or submit any issues for this package

Installation

yarn add @thi.ng/rstream-log-file

ES module import:

<script type="module" src="https://cdn.skypack.dev/@thi.ng/rstream-log-file"></script>

Skypack documentation

For Node.js REPL:

const rstreamLogFile = await import("@thi.ng/rstream-log-file");

Package sizes (brotli'd, pre-treeshake): ESM: 109 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

If this project contributes to an academic publication, please cite it as:

@misc{thing-rstream-log-file,
  title = "@thi.ng/rstream-log-file",
  author = "Karsten Schmidt",
  note = "https://thi.ng/rstream-log-file",
  year = 2017
}

License

© 2017 - 2024 Karsten Schmidt // Apache License 2.0

Dependents (0)

Package Sidebar

Install

npm i @thi.ng/rstream-log-file

Weekly Downloads

117

Version

2.1.116

License

Apache-2.0

Unpacked Size

20.9 kB

Total Files

6

Last publish

Collaborators

  • thi.ng