Coder Social home page Coder Social logo

rotating-writable's Introduction

Rotating Writable

Rotating Writable is an hourly, auto-rotating writable stream, where the suffix might be 2016-4-29-15. It's built to implement a logger compatible with Amazon Elastic Beanstalk's Enhanced Health Checking.

By default, Rotating Writable opens files as append. It passes options through to fs.createWriteStream, so set the flags as you please to change.

Rotating Writable also defaults to application.log as a filename, if the specified path is found to be a directory. This might be a mis-feature.

Install

npm install rotating-writable

Use

Rotating Writable should fairly transparently substitute in for fs.createWriteStream, but instead of returning the stream, it will return a function which returns the current stream: all operations should call the getter and issue their writes to the current stream instance.

Example

A trivial application might look like-

var rotating = require("rotating-writable")
rotating().write("application starting")
setTimeout(function(){
	rotating().write("application ending")
	rotating.end("application finished")
}, 500)

Caution

Creating a rotating writable issues a fs.statSync. It is not expected that apps need to keep creating rotating writables. If you do have this use case, please submit a PR, perhaps an option to skip this

rotating-writable's People

Contributors

rektide avatar

Watchers

 avatar James Cloos 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.