summaryrefslogtreecommitdiff
path: root/libpod/container_log.go
diff options
context:
space:
mode:
Diffstat (limited to 'libpod/container_log.go')
-rw-r--r--libpod/container_log.go25
1 files changed, 21 insertions, 4 deletions
diff --git a/libpod/container_log.go b/libpod/container_log.go
index f11db8014..9276b52f4 100644
--- a/libpod/container_log.go
+++ b/libpod/container_log.go
@@ -19,6 +19,16 @@ const (
// zeroes are not trimmed, taken from
// https://github.com/golang/go/issues/19635
logTimeFormat = "2006-01-02T15:04:05.000000000Z07:00"
+
+ // readLogTimeFormat is the format the log lines will be read in
+ readLogTimeFormat = time.RFC3339Nano
+
+ // partialLogType signifies a log line that exceeded the buffer
+ // length and needed to spill into a new line
+ partialLogType = "P"
+
+ // fullLogType signifies a log line is full
+ fullLogType = "F"
)
// LogOptions is the options you can use for logs
@@ -55,9 +65,16 @@ func (r *Runtime) Log(containers []*Container, options *LogOptions, logChannel c
func (c *Container) ReadLog(options *LogOptions, logChannel chan *LogLine) error {
// TODO Skip sending logs until journald logs can be read
// TODO make this not a magic string
- if c.LogDriver() == "journald" {
- return ErrNotImplemented
+ if c.LogDriver() == JournaldLogging {
+ if options.Follow {
+ return errors.Errorf("The follow option with journald logging is not currently supported")
+ }
+ return c.readFromJournal(options, logChannel)
}
+ return c.readFromLogFile(options, logChannel)
+}
+
+func (c *Container) readFromLogFile(options *LogOptions, logChannel chan *LogLine) error {
t, tailLog, err := getLogFile(c.LogPath(), options)
if err != nil {
// If the log file does not exist, this is not fatal.
@@ -196,7 +213,7 @@ func newLogLine(line string) (*LogLine, error) {
if len(splitLine) < 4 {
return nil, errors.Errorf("'%s' is not a valid container log line", line)
}
- logTime, err := time.Parse(time.RFC3339Nano, splitLine[0])
+ logTime, err := time.Parse(readLogTimeFormat, splitLine[0])
if err != nil {
return nil, errors.Wrapf(err, "unable to convert time %s from container log", splitLine[0])
}
@@ -211,7 +228,7 @@ func newLogLine(line string) (*LogLine, error) {
// Partial returns a bool if the log line is a partial log type
func (l *LogLine) Partial() bool {
- if l.ParseLogType == "P" {
+ if l.ParseLogType == partialLogType {
return true
}
return false