-
Notifications
You must be signed in to change notification settings - Fork 695
Implement journald logging driver #1062
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement journald logging driver #1062
Conversation
9edae9d
to
dfb7419
Compare
cmd/nerdctl/run_test.go
Outdated
found := 0 | ||
check := func(log poll.LogT) poll.Result { | ||
c, err := jr.Read(b) | ||
assert.NilError(t, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we verify the content? How is it formatted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed, our scope is to check that the tag is well formated and this is guaranteed with SYSLOG IDENTIFIER
. Other log part are handled in the journald scope
af23936
to
0372a81
Compare
1bb2a52
to
94c079b
Compare
9f3bf9b
to
640e0de
Compare
cmd/nerdctl/run_test.go
Outdated
inspectedContainer := base.InspectContainer(containerName) | ||
found := 0 | ||
check := func(log poll.LogT) poll.Result { | ||
res := icmd.RunCmd(icmd.Command("journalctl", "--no-pager", fmt.Sprintf("SYSLOG_IDENTIFIER=%s", inspectedContainer.ID[:12]))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs something like --since <timestamp>
, otherwise journalctl produces a huge hog
Can we implement |
3ddd2ec
to
759713d
Compare
5a78ae8
to
1b36608
Compare
README.md
Outdated
@@ -694,7 +695,9 @@ Usage: `nerdctl logs [OPTIONS] CONTAINER` | |||
Flags: | |||
- :whale: `--f, --follow`: Follow log output | |||
- :whale: `--since`: Show logs since timestamp (e.g. 2013-01-02T13:23:37Z) or relative (e.g. 42m for 42 minutes) | |||
- for journald log driver logs since relative should be in this format `42 minutes ago` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we just use the same format?
If difficult this flag can be implemented in a separate PR.
cmd/nerdctl/logs.go
Outdated
return jsonfile.Decode(os.Stdout, os.Stderr, reader, timestamps, since, until, logsEOFChan) | ||
case "journald": | ||
var journalctlArgs []string | ||
journalctlArgs = append(journalctlArgs, fmt.Sprintf("SYSLOG_IDENTIFIER=%s", found.Container.ID()[:12])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use a const or at least add a comment line for 12
cmd/nerdctl/logs.go
Outdated
journalctlArgs = append(journalctlArgs, "-f") | ||
} | ||
if since != "" { | ||
journalctlArgs = append(journalctlArgs, "--since", since) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
journalctlArgs = append(journalctlArgs, "--since", since) | |
journalctlArgs = append(journalctlArgs, "--since", since + " ago") |
cmd/nerdctl/logs.go
Outdated
} | ||
return jsonfile.Decode(os.Stdout, os.Stderr, reader, timestamps, since, until, logsEOFChan) | ||
case "journald": | ||
var journalctlArgs []string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add --output=cat
to eliminate extra header
pkg/logging/journald_logger.go
Outdated
|
||
var syslogIdentifier string | ||
if _, ok := journaldLogger.Opts[Tag]; !ok { | ||
syslogIdentifier = config.ID[:12] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a const or at least add a comment line for this magic number
81be1dd
to
16f8c5c
Compare
Signed-off-by: Fahed DORGAA <fahed.dorgaa@gmail.com>
16f8c5c
to
dd8a0ff
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
enhance #1039 with
journald
log driver