Skip to content

Commit

Permalink
Move json log reading into log file object
Browse files Browse the repository at this point in the history
This allows much of the read logic to be shared for other things,
especially for the new log driver proposed in
moby#33475

The only logic for reads in the json logger is around decoding log
messages, which gets passed into the log file object.

This also helps with implementing compression as it allows us to
simplify locking strategies.

Signed-off-by: Brian Goff <[email protected]>
  • Loading branch information
cpuguy83 committed Nov 4, 2017
1 parent 52d82b4 commit 16f7cd6
Show file tree
Hide file tree
Showing 9 changed files with 501 additions and 471 deletions.
7 changes: 4 additions & 3 deletions daemon/logger/jsonfilelog/jsonfilelog.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ const Name = "json-file"

// JSONFileLogger is Logger implementation for default Docker logging.
type JSONFileLogger struct {
mu sync.RWMutex
mu sync.Mutex
closed bool
writer *loggerutils.RotateFileWriter
writer *loggerutils.LogFile
readers map[*logger.LogWatcher]struct{} // stores the active log followers
}

Expand Down Expand Up @@ -83,7 +83,8 @@ func New(info logger.Info) (logger.Logger, error) {
buf.Reset()
return b, nil
}
writer, err := loggerutils.NewRotateFileWriter(info.LogPath, capval, maxFiles, marshalFunc)

writer, err := loggerutils.NewLogFile(info.LogPath, capval, maxFiles, marshalFunc, decodeFunc)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion daemon/logger/jsonfilelog/jsonfilelog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func BenchmarkJSONFileLoggerLog(b *testing.B) {
}

buf := bytes.NewBuffer(nil)
require.NoError(b, marshalMessage(msg, jsonlogger.(*JSONFileLogger).extra, buf))
require.NoError(b, marshalMessage(msg, nil, buf))
b.SetBytes(int64(buf.Len()))

b.ResetTimer()
Expand Down
Loading

0 comments on commit 16f7cd6

Please sign in to comment.