1.0.3 • Published 9 years ago

php-errorlog-parser v1.0.3

Weekly downloads
1
License
MIT
Repository
github
Last release
9 years ago

PHP Error Log Parser

Parse PHP error log

Installation

$ npm install -save php-errorlog-parser

Usage

var Parser = require('php-errorlog-parser');
var fs = require('fs');

var parser = new Parser(0);
parser.addListener('record', function (record) {
    console.log('parsed record', record);
});

var content = fs.readFileSync('/var/log/php_errors.log');
content.toString().split("\n").forEach(function(line) {
    parser.addLine(line);
});

methods

constructor(threshold)

parameter: threshold

Wait time for accept continuous line input, in milli seconds.

threshold stands for multi line parsing. If a bunch of lines come within threashold, the parser can parse them together.

addLine(line)

Add new line to the parser.

parameter: line

New line string.

The parser expect that line has no CR nor LF in its tail.

events

record

Emitted when a parsed record is formed.

parameter: record
keytypedescription
timeDatelog timestamp
levelstringlog level
linesarraylog lines
stacktracearray/nullstrace trace lines

error

Emmited when an error occured

parameger: error

Error description.

License

MIT