@@ -49,12 +49,12 @@ const (
49
49
50
50
type Driver interface {
51
51
Init (dataStore , ns , id string ) error
52
- PreProcess (dataStore string , config * logging.Config ) error
52
+ PreProcess (ctx context. Context , dataStore string , config * logging.Config ) error
53
53
Process (stdout <- chan string , stderr <- chan string ) error
54
54
PostProcess () error
55
55
}
56
56
57
- type DriverFactory func (map [string ]string ) (Driver , error )
57
+ type DriverFactory func (map [string ]string , string ) (Driver , error )
58
58
type LogOptsValidateFunc func (logOptMap map [string ]string ) error
59
59
60
60
var drivers = make (map [string ]DriverFactory )
@@ -81,28 +81,28 @@ func Drivers() []string {
81
81
return ss
82
82
}
83
83
84
- func GetDriver (name string , opts map [string ]string ) (Driver , error ) {
84
+ func GetDriver (name string , opts map [string ]string , address string ) (Driver , error ) {
85
85
driverFactory , ok := drivers [name ]
86
86
if ! ok {
87
87
return nil , fmt .Errorf ("unknown logging driver %q: %w" , name , errdefs .ErrNotFound )
88
88
}
89
- return driverFactory (opts )
89
+ return driverFactory (opts , address )
90
90
}
91
91
92
92
func init () {
93
- RegisterDriver ("none" , func (opts map [string ]string ) (Driver , error ) {
93
+ RegisterDriver ("none" , func (opts map [string ]string , address string ) (Driver , error ) {
94
94
return & NoneLogger {}, nil
95
95
}, NoneLogOptsValidate )
96
- RegisterDriver ("json-file" , func (opts map [string ]string ) (Driver , error ) {
96
+ RegisterDriver ("json-file" , func (opts map [string ]string , address string ) (Driver , error ) {
97
97
return & JSONLogger {Opts : opts }, nil
98
98
}, JSONFileLogOptsValidate )
99
- RegisterDriver ("journald" , func (opts map [string ]string ) (Driver , error ) {
100
- return & JournaldLogger {Opts : opts }, nil
99
+ RegisterDriver ("journald" , func (opts map [string ]string , address string ) (Driver , error ) {
100
+ return & JournaldLogger {Opts : opts , Address : address }, nil
101
101
}, JournalLogOptsValidate )
102
- RegisterDriver ("fluentd" , func (opts map [string ]string ) (Driver , error ) {
102
+ RegisterDriver ("fluentd" , func (opts map [string ]string , address string ) (Driver , error ) {
103
103
return & FluentdLogger {Opts : opts }, nil
104
104
}, FluentdLogOptsValidate )
105
- RegisterDriver ("syslog" , func (opts map [string ]string ) (Driver , error ) {
105
+ RegisterDriver ("syslog" , func (opts map [string ]string , address string ) (Driver , error ) {
106
106
return & SyslogLogger {Opts : opts }, nil
107
107
}, SyslogOptsValidate )
108
108
}
@@ -121,9 +121,10 @@ func Main(argv2 string) error {
121
121
122
122
// LogConfig is marshalled as "log-config.json"
123
123
type LogConfig struct {
124
- Driver string `json:"driver"`
125
- Opts map [string ]string `json:"opts,omitempty"`
126
- LogURI string `json:"-"`
124
+ Driver string `json:"driver"`
125
+ Opts map [string ]string `json:"opts,omitempty"`
126
+ LogURI string `json:"-"`
127
+ Address string `json:"address"`
127
128
}
128
129
129
130
// LogConfigFilePath returns the path of log-config.json
@@ -149,7 +150,7 @@ func LoadLogConfig(dataStore, ns, id string) (LogConfig, error) {
149
150
}
150
151
151
152
func loggingProcessAdapter (ctx context.Context , driver Driver , dataStore string , config * logging.Config ) error {
152
- if err := driver .PreProcess (dataStore , config ); err != nil {
153
+ if err := driver .PreProcess (ctx , dataStore , config ); err != nil {
153
154
return err
154
155
}
155
156
@@ -215,7 +216,7 @@ func loggerFunc(dataStore string) (logging.LoggerFunc, error) {
215
216
if err != nil {
216
217
return err
217
218
}
218
- driver , err := GetDriver (logConfig .Driver , logConfig .Opts )
219
+ driver , err := GetDriver (logConfig .Driver , logConfig .Opts , logConfig . Address )
219
220
if err != nil {
220
221
return err
221
222
}
0 commit comments