Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
fleetctl: add -output to journal
Browse files Browse the repository at this point in the history
this adds the --output flag to journal, which is passed through
to journalctl, so that you can specify its output format.

Fixes #1398

Improved-by: Djalal Harouni <djalal@endocode.com>
  • Loading branch information
royvandewater authored and tixxdz committed Feb 1, 2016
1 parent 189dacf commit 91bd02b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions fleetctl/journal.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ var (
flagLines int
flagFollow bool
flagSudo bool
flagOutput string
cmdJournal = &Command{
Name: "journal",
Summary: "Print the journal of a unit in the cluster to stdout",
Usage: "[--lines=N] [--ssh-port=N] [-f|--follow] <unit>",
Usage: "[--lines=N] [--ssh-port=N] [-f|--follow] [--output=STRING] <unit>",
Run: runJournal,
Description: `Outputs the journal of a unit by connecting to the machine that the unit occupies.
Expand All @@ -47,6 +48,7 @@ func init() {
cmdJournal.Flags.BoolVar(&flagFollow, "f", false, "Shorthand for --follow")
cmdJournal.Flags.IntVar(&sharedFlags.SSHPort, "ssh-port", 22, "Connect to remote hosts over SSH using this TCP port")
cmdJournal.Flags.BoolVar(&flagSudo, "sudo", false, "Execute journal command with sudo")
cmdJournal.Flags.StringVar(&flagOutput, "output", "short", "Change journal output mode (short, short-iso, short-precise, short-monotonic, verbose, export, json, json-pretty, json-sse, cat)")
}

func runJournal(args []string) (exit int) {
Expand All @@ -71,7 +73,7 @@ func runJournal(args []string) (exit int) {
return 1
}

cmd := []string{"journalctl", "--unit", name, "--no-pager", "-n", strconv.Itoa(flagLines)}
cmd := []string{"journalctl", "--unit", name, "--no-pager", "-n", strconv.Itoa(flagLines), "--output", flagOutput}

if flagSudo {
cmd = append([]string{"sudo"}, cmd...)
Expand Down

0 comments on commit 91bd02b

Please sign in to comment.