oranch
v0.0.11
Published
Log tracking module with node
Downloads
21
Readme
oranch
Log file tracker using in node. Installing and using easily as npm module. npm
Get starting
Install
$ npm install oranch
Usage
Create oranch object
To create oranch object, you should give some options as below. Default is cron scheduling.
schedule
: Oranch read logfile at fixed interval decided by this parameter. Written in crontab format.logfile
: Oranch read this file.task
: When log matching is induced, this task will be called.jobType
: If you want to use watch file API, setwatch
or with cron scheduler setcron
.match
: Log matching is conditioned by this regular expression.endMatch
: With this options you can finish job when this tag matchesoffset
: If you want to off defaultalready
files, oranch starts reading as you like by this offset.onComplete
: When oranch stops, this function will be called.
These are all required parameters.
If your tracking is unfrequent, you should use watchFile API in node. watchFile API calls your task funcion in the case of updating logfile. So it will be more efficient unfrequent case.
In order to start tracking log, please call start
.
oranch.start();
When you want to stop oranch log tracking, call stop
.
oranch.stop();
Example
var Oranch = require('oranch').Oranch;
var options = {
'schedule' : '* * * * * *',
'logfile' : '/path/to/somelogfile.log',
'match' : /WARN/,
'jobType' : 'cron',
'task' : function (line) {
// Write down what you want when WARN log is induced.
},
'onComplete' : function () {
// Write down what you want when Oranch stops
}
};
var oranch = new Oranch(options);
oranch.start();