Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content
This repository has been archived by the owner on Jul 25, 2022. It is now read-only.

Write log files and rotate them using gzip.

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

joseluisq/logger-stream-rotate

Repository files navigation

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