@@ -24,7 +24,7 @@ const name = "gelf"
2424
2525type gelfLogger struct {
2626 writer * gelf.Writer
27- ctx logger.Context
27+ info logger.Info
2828 hostname string
2929 rawExtra json.RawMessage
3030}
@@ -40,36 +40,36 @@ func init() {
4040
4141// New creates a gelf logger using the configuration passed in on the
4242// context. The supported context configuration variable is gelf-address.
43- func New (ctx logger.Context ) (logger.Logger , error ) {
43+ func New (info logger.Info ) (logger.Logger , error ) {
4444 // parse gelf address
45- address , err := parseAddress (ctx .Config ["gelf-address" ])
45+ address , err := parseAddress (info .Config ["gelf-address" ])
4646 if err != nil {
4747 return nil , err
4848 }
4949
5050 // collect extra data for GELF message
51- hostname , err := ctx .Hostname ()
51+ hostname , err := info .Hostname ()
5252 if err != nil {
5353 return nil , fmt .Errorf ("gelf: cannot access hostname to set source field" )
5454 }
5555
5656 // parse log tag
57- tag , err := loggerutils .ParseLogTag (ctx , loggerutils .DefaultTemplate )
57+ tag , err := loggerutils .ParseLogTag (info , loggerutils .DefaultTemplate )
5858 if err != nil {
5959 return nil , err
6060 }
6161
6262 extra := map [string ]interface {}{
63- "_container_id" : ctx .ContainerID ,
64- "_container_name" : ctx .Name (),
65- "_image_id" : ctx .ContainerImageID ,
66- "_image_name" : ctx .ContainerImageName ,
67- "_command" : ctx .Command (),
63+ "_container_id" : info .ContainerID ,
64+ "_container_name" : info .Name (),
65+ "_image_id" : info .ContainerImageID ,
66+ "_image_name" : info .ContainerImageName ,
67+ "_command" : info .Command (),
6868 "_tag" : tag ,
69- "_created" : ctx .ContainerCreated ,
69+ "_created" : info .ContainerCreated ,
7070 }
7171
72- extraAttrs := ctx .ExtraAttributes (func (key string ) string {
72+ extraAttrs := info .ExtraAttributes (func (key string ) string {
7373 if key [0 ] == '_' {
7474 return key
7575 }
@@ -90,7 +90,7 @@ func New(ctx logger.Context) (logger.Logger, error) {
9090 return nil , fmt .Errorf ("gelf: cannot connect to GELF endpoint: %s %v" , address , err )
9191 }
9292
93- if v , ok := ctx .Config ["gelf-compression-type" ]; ok {
93+ if v , ok := info .Config ["gelf-compression-type" ]; ok {
9494 switch v {
9595 case "gzip" :
9696 gelfWriter .CompressionType = gelf .CompressGzip
@@ -103,7 +103,7 @@ func New(ctx logger.Context) (logger.Logger, error) {
103103 }
104104 }
105105
106- if v , ok := ctx .Config ["gelf-compression-level" ]; ok {
106+ if v , ok := info .Config ["gelf-compression-level" ]; ok {
107107 val , err := strconv .Atoi (v )
108108 if err != nil {
109109 return nil , fmt .Errorf ("gelf: invalid compression level %s, err %v" , v , err )
@@ -113,7 +113,7 @@ func New(ctx logger.Context) (logger.Logger, error) {
113113
114114 return & gelfLogger {
115115 writer : gelfWriter ,
116- ctx : ctx ,
116+ info : info ,
117117 hostname : hostname ,
118118 rawExtra : rawExtra ,
119119 }, nil
0 commit comments