Emit rotate events and rotate files based on interval. Rotate event handlers are called "rotater-tots" or just tots. Tots get passed a readable stream the log file path and the data passed in when the log was asociated.
Emit rotate events for log files based on interval. Rotate event handlers are called "rotator-tots" or just tots. Tots get passed a (readable stream, the log file path, and the data passed in when the log was asociated).
var rotator = require'rotator';var tot = rotator;totaddFile'./some.log'iferr throw err; // oh no could not find the log or somthingconsole.log'log scheduled for rotation!';;toton'rotate'// stop writing to the log// also upload it to s3? content-length is fs.stat.size// rs.pipe ....;toton'rotated'console.logrs'was old and needed to be rotated. copied to 'path;// prints "./some.log was old and needed to be rotated. copied to ./20120914_some.log";
- the rotate interval for all files on this tot defaults to 1 day
- the max size of the file before it is rotated. defauls to 5gb
- gzip = true
- rotated files are by default gzipped
- how often to check if any logs need to be rotated. defaults to 1 minute.
- how often to poll size. i did not want to install watchers because we should not really need to check this so often.
returns an EventEmitter
- add a file to be rotated
- remove a path from the rotate list
- creates day timestamp from UTC YMD overload this function to change the format.
- path the file path you want to rotate
- cb callback
- the file path that must not be rotated until stream close
- the stream that must close
- rotate(rs ReadabeStream,p file path, data)
- rotated(p file path,data)
- all active rotates are done
- rotate-error(err Error, p file path, data)
- rotate-empty(p path,data);
Data Object data objects are passed to events. this is the data associated with each file.
let me know if you have victory