Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
6 changes: 6 additions & 0 deletions journalctl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This contradicts the '-f' argument.

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);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason for specifying the output format? The library always converts the stream to JS objects.

if (opts.filter) {
if (!(opts.filter instanceof Array)) opts.filter = [opts.filter];
opts.filter.forEach((f) => args.push(f));
Expand Down