1.0.0-rc1 • Published 5 years ago

logger-stream-rotate v1.0.0-rc1

Weekly downloads
1
License
(MIT OR Apache-2....
Repository
github
Last release
5 years ago

logger-stream-rotate

Build Status npm npm JavaScript Style Guide

Write log files and rotate them using gzip.

Features

  • Output logs to time-rotated log files.
  • Optionally gzip logs once they are no longer current.
  • Dates are expressed in UTC only.
  • Stream pipe functionality coming soon.

Install

Yarn

yarn add logger-stream-rotate --dev

NPM

npm install logger-stream-rotate --save-dev

Usage

import { Logger } from "logger-stream-rotate"

// Logger supports log a file name format like "YYYY-MM-DD hh:mm:ss" with an optional separator
const logger = Logger("./app-%YYYY-%MM-%DD.log", " | ")

logger.write(
    // string or array of strings are supported which will be concatenated by ` | ` in one line
    ["Log entry part 1", "another log entry part 2", "etc..."],
    () => console.log("callback when current log entry was finished!")
)

// Log file content: `app-2019-09-17.log`
// 2019-10-17T07:47:35.096Z | 1571298455096 | Log entry part 1 | another log entry part 2 | etc...

An example file is located at sample/sample.ts

Contributions

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in current work by you, as defined in the Apache-2.0 license, shall be dual licensed as described below, without any additional terms or conditions.

Feel free to send some Pull request or issue.

License

This work is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0).

© 2019 Jose Quintana