mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Standardize default logging tag value
Use the same default tag value for all loggers that support tags. Signed-off-by: Vincent Demeester <vincent@sbr.pm>
This commit is contained in:
parent
3db23a4eaf
commit
f900e1cf47
6 changed files with 8 additions and 5 deletions
|
@ -65,7 +65,7 @@ func New(ctx logger.Context) (logger.Logger, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
tag, err := loggerutils.ParseLogTag(ctx, "{{.DaemonName}}.{{.ID}}")
|
tag, err := loggerutils.ParseLogTag(ctx, loggerutils.DefaultTemplate)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ func New(ctx logger.Context) (logger.Logger, error) {
|
||||||
containerName := bytes.TrimLeft([]byte(ctx.ContainerName), "/")
|
containerName := bytes.TrimLeft([]byte(ctx.ContainerName), "/")
|
||||||
|
|
||||||
// parse log tag
|
// parse log tag
|
||||||
tag, err := loggerutils.ParseLogTag(ctx, "")
|
tag, err := loggerutils.ParseLogTag(ctx, loggerutils.DefaultTemplate)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ func New(ctx logger.Context) (logger.Logger, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// parse log tag
|
// parse log tag
|
||||||
tag, err := loggerutils.ParseLogTag(ctx, "")
|
tag, err := loggerutils.ParseLogTag(ctx, loggerutils.DefaultTemplate)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,9 @@ import (
|
||||||
"github.com/docker/docker/utils/templates"
|
"github.com/docker/docker/utils/templates"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// DefaultTemplate defines the defaults template logger should use.
|
||||||
|
const DefaultTemplate = "{{.ID}}"
|
||||||
|
|
||||||
// ParseLogTag generates a context aware tag for consistency across different
|
// ParseLogTag generates a context aware tag for consistency across different
|
||||||
// log drivers based on the context of the running container.
|
// log drivers based on the context of the running container.
|
||||||
func ParseLogTag(ctx logger.Context, defaultTemplate string) (string, error) {
|
func ParseLogTag(ctx logger.Context, defaultTemplate string) (string, error) {
|
||||||
|
|
|
@ -131,7 +131,7 @@ func New(ctx logger.Context) (logger.Logger, error) {
|
||||||
nullMessage.SourceType = ctx.Config[splunkSourceTypeKey]
|
nullMessage.SourceType = ctx.Config[splunkSourceTypeKey]
|
||||||
nullMessage.Index = ctx.Config[splunkIndexKey]
|
nullMessage.Index = ctx.Config[splunkIndexKey]
|
||||||
|
|
||||||
tag, err := loggerutils.ParseLogTag(ctx, "{{.ID}}")
|
tag, err := loggerutils.ParseLogTag(ctx, loggerutils.DefaultTemplate)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,7 @@ func rfc5424microformatterWithAppNameAsTag(p syslog.Priority, hostname, tag, con
|
||||||
// the context. Supported context configuration variables are
|
// the context. Supported context configuration variables are
|
||||||
// syslog-address, syslog-facility, syslog-format.
|
// syslog-address, syslog-facility, syslog-format.
|
||||||
func New(ctx logger.Context) (logger.Logger, error) {
|
func New(ctx logger.Context) (logger.Logger, error) {
|
||||||
tag, err := loggerutils.ParseLogTag(ctx, "{{.DaemonName}}/{{.ID}}")
|
tag, err := loggerutils.ParseLogTag(ctx, loggerutils.DefaultTemplate)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue