-
Notifications
You must be signed in to change notification settings - Fork 678
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
Use log timestamps from docker logs. #401
base: master
Are you sure you want to change the base?
Changes from 1 commit
d0e8c0f
c49aff9
0caaeee
f00a3c2
41f0437
18772e0
a783720
5e7a964
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -212,7 +212,7 @@ func (p *LogsPump) pumpLogs(event *docker.APIEvents, backlog bool, inactivityTim | |
|
||
// RawTerminal with container Tty=false injects binary headers into | ||
// the log stream that show up as garbage unicode characters | ||
rawTerminal := false | ||
rawTerminal := false | ||
if allowTTY && container.Config.Tty { | ||
rawTerminal = true | ||
} | ||
|
@@ -235,6 +235,7 @@ func (p *LogsPump) pumpLogs(event *docker.APIEvents, backlog bool, inactivityTim | |
Since: sinceTime.Unix(), | ||
InactivityTimeout: inactivityTimeout, | ||
RawTerminal: rawTerminal, | ||
Timestamps: true, | ||
}) | ||
if err != nil { | ||
debug("pump.pumpLogs():", id, "stopped with error:", err) | ||
|
@@ -361,10 +362,15 @@ func newContainerPump(container *docker.Container, stdout, stderr io.Reader) *co | |
} | ||
return | ||
} | ||
logMessage, logTime, err := parseLogLine(line) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
if err != nil { | ||
debug("pump.newContainerPump():", normalID(container.ID), ", failed to parse log line:", err) | ||
continue | ||
} | ||
cp.send(&Message{ | ||
Data: strings.TrimSuffix(line, "\n"), | ||
Data: logMessage, | ||
Container: container, | ||
Time: time.Now(), | ||
Time: logTime, | ||
gbolo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Source: source, | ||
}) | ||
} | ||
|
@@ -396,3 +402,12 @@ func (cp *containerPump) remove(logstream chan *Message) { | |
defer cp.Unlock() | ||
delete(cp.logstreams, logstream) | ||
} | ||
|
||
func parseLogLine(line string) (string, time.Time, error) { | ||
logEntry := strings.SplitN(strings.TrimSuffix(line, "\n"), " ", 2) | ||
logTime, err := time.Parse(time.RFC3339Nano, logEntry[0]) | ||
if err != nil { | ||
return "", time.Time{}, err | ||
} | ||
return logEntry[1], logTime, nil | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there is no guarantee that |
||
} |
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.
set this to true only if this feature is enabled