Git Product home page Git Product logo

logger-stream-rotate's Introduction

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

logger-stream-rotate's People

Contributors

joseluisq avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.