diff --git a/README.md b/README.md index b96c79d..b7464dd 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,11 @@ The optional object `opts` can have the following properties: * `all`: Show all fields in full, even if they include unprintable characters or are very long. (cf. man journalctl, option '-a') * `lines`: Show the most recent journal events and limit the number of events shown (cf. man journalctl, option '-n') * `since`: Start showing entries on or newer than the specified date (cf. man journalctl, option '-S') + * `until`: Stop showing entries on or older than the specified date (cf. man journalctl, option '-U') + * `utc`: Print timestamps in Coordinated Universal Time (UTC) (cf. man journalctl, option '--utc') + * `output`: Specify the output format (cf. man journalctl, option '-o') + * Supported formats: 'json', 'json-pretty', 'short', 'short-iso', 'short-monotonic', 'verbose', 'export', 'json-sse' + ### Event: 'event' diff --git a/journalctl.js b/journalctl.js index d4d375e..b5d8c11 100644 --- a/journalctl.js +++ b/journalctl.js @@ -3,6 +3,8 @@ const EventEmitter = require('events'); const util = require('util'); const JSONStream = require('./json-stream.js'); +const supportedOutputFormats = ['json', 'json-pretty', 'short', 'short-iso', 'short-monotonic', 'verbose', 'export', 'json-sse']; + function Journalctl (opts) { EventEmitter.call(this); @@ -12,8 +14,12 @@ function Journalctl (opts) { if (opts.all) args.push('-a'); if (opts.lines) args.push('-n', opts.lines); if (opts.since) args.push('-S', opts.since); + if (opts.until) args.push('-U', opts.until); + if (opts.reverse) args.push('-r'); + if (opts.utc) args.push('--utc'); if (opts.identifier) args.push('-t', opts.identifier); if (opts.unit) args.push('-u', opts.unit); + if (opts.output && supportedOutputFormats.includes(opts.output)) args.push('-o', opts.output); if (opts.filter) { if (!(opts.filter instanceof Array)) opts.filter = [opts.filter]; opts.filter.forEach((f) => args.push(f));