mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-01-18 18:56:24 +00:00
Add journald format flag
Change-type: minor Signed-off-by: Cameron Diver <cameron@balena.io>
This commit is contained in:
parent
2d924b83fc
commit
48bccd34db
@ -1185,7 +1185,7 @@ Unsuccessful response:
|
||||
Added in supervisor version v10.2.0
|
||||
|
||||
Retrieve a stream to the journald logs on device. This is
|
||||
equivalent to running `journalctl -o export`. Options
|
||||
equivalent to running `journalctl --no-pager`. Options
|
||||
supported are:
|
||||
|
||||
##### all: boolean
|
||||
@ -1203,6 +1203,11 @@ Show the most recent `count` events, equivalent to
|
||||
Show journal logs from `unit` only, equivalent to
|
||||
`journalctl --unit=<unit>`.
|
||||
|
||||
##### format
|
||||
The format which will be streamed from journalctl, formats
|
||||
are described here:
|
||||
https://www.freedesktop.org/software/systemd/man/journalctl.html#-o
|
||||
|
||||
Fields should be provided via POST body in JSON format.
|
||||
|
||||
From an application container (with systemd installed):
|
||||
|
@ -539,8 +539,9 @@ export function createV2Api(router: Router, applications: ApplicationManager) {
|
||||
const follow = checkTruthy(req.body.follow) || false;
|
||||
const count = checkInt(req.body.count, { positive: true }) || undefined;
|
||||
const unit = req.body.unit;
|
||||
const format = req.body.format || 'short';
|
||||
|
||||
const journald = spawnJournalctl({ all, follow, count, unit });
|
||||
const journald = spawnJournalctl({ all, follow, count, unit, format });
|
||||
res.status(200);
|
||||
journald.stdout.pipe(res);
|
||||
res.on('close', () => {
|
||||
|
@ -8,13 +8,12 @@ export function spawnJournalctl(opts: {
|
||||
follow: boolean;
|
||||
count?: number;
|
||||
unit?: string;
|
||||
format: string;
|
||||
}): ChildProcess {
|
||||
const args = [
|
||||
// The directory we want to run the chroot from
|
||||
constants.rootMountPoint,
|
||||
'journalctl',
|
||||
'-o',
|
||||
'export',
|
||||
];
|
||||
if (opts.all) {
|
||||
args.push('-a');
|
||||
@ -30,6 +29,8 @@ export function spawnJournalctl(opts: {
|
||||
args.push('-n');
|
||||
args.push(opts.count.toString());
|
||||
}
|
||||
args.push('-o');
|
||||
args.push(opts.format);
|
||||
|
||||
log.debug('Spawning journald with: chroot ', args.join(' '));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user