File tree Expand file tree Collapse file tree 6 files changed +48
-3
lines changed Expand file tree Collapse file tree 6 files changed +48
-3
lines changed Original file line number Diff line number Diff line change @@ -315,7 +315,7 @@ func (container *Container) StartLogger(cfg containertypes.LogConfig) (logger.Lo
315315 if err != nil {
316316 return nil , fmt .Errorf ("Failed to get logging factory: %v" , err )
317317 }
318- ctx := logger.Context {
318+ cctx := logger.CommonContext {
319319 Config : cfg .Config ,
320320 ContainerID : container .ID ,
321321 ContainerName : container .Name ,
@@ -328,6 +328,7 @@ func (container *Container) StartLogger(cfg containertypes.LogConfig) (logger.Lo
328328 ContainerLabels : container .Config .Labels ,
329329 DaemonName : "docker" ,
330330 }
331+ ctx := configurePlatformLogger (cctx , container )
331332
332333 // Set logging file for "json-logger"
333334 if cfg .Type == jsonfilelog .Name {
Original file line number Diff line number Diff line change 1+ package container
2+
3+ import (
4+ "github.com/docker/docker/daemon/logger"
5+ )
6+
7+ // configurePlatformLogger takes a logger.CommonContext and adds any
8+ // OS-specific information that is exclusive to a logger.Context.
9+ func configurePlatformLogger (ctx logger.CommonContext , container * Container ) logger.Context {
10+ return logger.Context {
11+ CommonContext : ctx ,
12+ ContainerCGroup : * container .Spec .Linux .CgroupsPath ,
13+ }
14+ }
Original file line number Diff line number Diff line change 1+ // +build !linux
2+
3+ package container
4+
5+ // configurePlatformLogger takes a logger.CommonContext and adds any
6+ // OS-specific information that is exclusive to a logger.Context.
7+ func configurePlatformLogger (ctx logger.CommonContext , container * Container ) logger.Context {
8+ return logger .Context (ctx )
9+ }
Original file line number Diff line number Diff line change 77 "time"
88)
99
10- // Context provides enough information for a logging driver to do its function.
11- type Context struct {
10+ // CommonContext provides almost enough information for a logging driver to do
11+ // its function, but not anything that's OS-specific.
12+ type CommonContext struct {
1213 Config map [string ]string
1314 ContainerID string
1415 ContainerName string
Original file line number Diff line number Diff line change 1+ package logger
2+
3+ // Context provides enough information for a logging driver to do its function.
4+ type Context struct {
5+ // These fields are shared across all definitions.
6+ CommonContext
7+ // Fields below this point are platform-specific.
8+ ContainerCGroup string
9+ }
10+
11+ // CGroup returns the name of the container's cgroup.
12+ func (ctx * Context ) CGroup () (string , error ) {
13+ return ctx .ContainerCGroup , nil
14+ }
Original file line number Diff line number Diff line change 1+ // +build !linux
2+
3+ package logger
4+
5+ // Context provides enough information for a logging driver to do its function.
6+ type Context CommonContext
You can’t perform that action at this time.
0 commit comments