TypeScript library of the journalctl tool included in Linux distributions.
import or require the module and create a new instance:
import Journalctl from '@mahsumurebe/journalctl';
const Journalctl = require('@mahsumurebe/journalctl');
const journalctl = new Journalctl([opts])
The optional object object
can be have the following properties.
identifier
: Show entries with the specified syslog identifierunits
: Show logs from the specified unit(s)userUnits
: Show logs from the specified user unit(s)all
: Show all fields, including long and unprintablelines
: Show entries with the specified syslog identifiersince
: Show entries not older than the specified dateutc
: Express time in Coordinated Universal Time (UTC)
It is triggered at each log event and returns the object event that describes the event.
journalctl.on('event', (event: IJournalEvent) => {
console.log(event);
})
Stops journalctl stream.
journalctl.stop();