Added optional flags to init gcp logger metadata
Signed-off-by: Vladimir Pouzanov <farcaller@google.com>
This commit is contained in:
parent
a9a8d807f0
commit
71f2999764
1 changed files with 10 additions and 1 deletions
|
@ -21,6 +21,9 @@ const (
|
|||
logLabelsKey = "labels"
|
||||
logEnvKey = "env"
|
||||
logCmdKey = "gcp-log-cmd"
|
||||
logZoneKey = "gcp-meta-zone"
|
||||
logNameKey = "gcp-meta-name"
|
||||
logIDKey = "gcp-meta-id"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -142,6 +145,12 @@ func New(ctx logger.Context) (logger.Logger, error) {
|
|||
Name: instanceName,
|
||||
ID: instanceID,
|
||||
}
|
||||
} else if ctx.Config[logZoneKey] != "" || ctx.Config[logNameKey] != "" || ctx.Config[logIDKey] != "" {
|
||||
l.instance = &instanceInfo{
|
||||
Zone: ctx.Config[logZoneKey],
|
||||
Name: ctx.Config[logNameKey],
|
||||
ID: ctx.Config[logIDKey],
|
||||
}
|
||||
}
|
||||
|
||||
// The logger "overflows" at a rate of 10,000 logs per second and this
|
||||
|
@ -163,7 +172,7 @@ func New(ctx logger.Context) (logger.Logger, error) {
|
|||
func ValidateLogOpts(cfg map[string]string) error {
|
||||
for k := range cfg {
|
||||
switch k {
|
||||
case projectOptKey, logLabelsKey, logEnvKey, logCmdKey:
|
||||
case projectOptKey, logLabelsKey, logEnvKey, logCmdKey, logZoneKey, logNameKey, logIDKey:
|
||||
default:
|
||||
return fmt.Errorf("%q is not a valid option for the gcplogs driver", k)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue