file-timestamp-stream
This module creates stream.Writable to a file which is automatically rotated based on current time and uses strftime template for file names.
Requirements
This module requires ES6 with Node >= 6.
Installation
npm install file-timestamp-stream
Additionally for Typescript:
npm install -D @types/node
Usage
Example:
const FileTimestampStream =
Typescript:
// or
Options
flags
is a string with flags for opened stream (default:'a'
)fs
is a custom fs module (optional)path
is a template for new filenames (default:'out.log'
)
Example:
Basic path based on strftime
parameters:
const stream = path: "%Y-%m-%dT%H.log" flags: "a"
newFilename
This method can be overriden in subclass.
The method generates a filename for new files. By default it returns new filename based on path and current time.
Example:
Properties
Readonly public properties based on contructor's options:
flags
fs
path
Protected properties for custom subclass:
currentFilename
contains last opened filenamestream
contains current fs.WriteStream object
Path template format
Path can contain strftime specifiers.
Warning
This stream have to be closed to free own streams and timers.
License
Copyright (c) 2017-2019 Piotr Roszatycki piotr.roszatycki@gmail.com