Write log files and rotate them using gzip.
- 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.
yarn add logger-stream-rotate --dev
npm install logger-stream-rotate --save-dev
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
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.
This work is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0).
© 2019 Jose Quintana