v1.8Getting started
Quick start (v1)
Callback-style parsing and the object-mode stream of version 1.
One line#
const sverlo = require('sverlo');
const parser = sverlo.parser({ format: 'nginx' });
parser.parse('10.0.0.7 - - [01/Oct/2026:09:14:07 +0000] "GET / HTTP/1.1" 200 512 "-" "curl/8"', (err, rec) => {
if (err) return console.error(err.message);
console.log(rec.severity, rec.message, rec.data.status);
});The callback is called synchronously. If the line is not recognised, an Error arrives as the first argument.
Stream#
const fs = require('fs');
const stream = fs.createReadStream('access.log').pipe(sverlo.createStream({ format: 'nginx' }));
stream.on('data', (rec) => { if (rec.data.status >= 500) console.log(rec.time, rec.data.path); });
stream.on('error', (e) => console.error(e));The stream runs in object mode. Backpressure is supported, but the stream has no for await iterator, so use events.
Moving to v2
The same code on version 2 is shorter and has no callbacks. Compare with the v2 quick start.