1
0
Fork 0
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:
Vincent Demeester 2016-06-04 12:38:12 +02:00
parent 3db23a4eaf
commit f900e1cf47
No known key found for this signature in database
GPG key ID: 083CC6FD6EB699A3
6 changed files with 8 additions and 5 deletions

View file

@ -65,7 +65,7 @@ func New(ctx logger.Context) (logger.Logger, error) {
return nil, err
}
tag, err := loggerutils.ParseLogTag(ctx, "{{.DaemonName}}.{{.ID}}")
tag, err := loggerutils.ParseLogTag(ctx, loggerutils.DefaultTemplate)
if err != nil {
return nil, err
}

View file

@ -58,7 +58,7 @@ func New(ctx logger.Context) (logger.Logger, error) {
containerName := bytes.TrimLeft([]byte(ctx.ContainerName), "/")
// parse log tag
tag, err := loggerutils.ParseLogTag(ctx, "")
tag, err := loggerutils.ParseLogTag(ctx, loggerutils.DefaultTemplate)
if err != nil {
return nil, err
}

View file

@ -50,7 +50,7 @@ func New(ctx logger.Context) (logger.Logger, error) {
}
// parse log tag
tag, err := loggerutils.ParseLogTag(ctx, "")
tag, err := loggerutils.ParseLogTag(ctx, loggerutils.DefaultTemplate)
if err != nil {
return nil, err
}

View file

@ -7,6 +7,9 @@ import (
"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
// log drivers based on the context of the running container.
func ParseLogTag(ctx logger.Context, defaultTemplate string) (string, error) {

View file

@ -131,7 +131,7 @@ func New(ctx logger.Context) (logger.Logger, error) {
nullMessage.SourceType = ctx.Config[splunkSourceTypeKey]
nullMessage.Index = ctx.Config[splunkIndexKey]
tag, err := loggerutils.ParseLogTag(ctx, "{{.ID}}")
tag, err := loggerutils.ParseLogTag(ctx, loggerutils.DefaultTemplate)
if err != nil {
return nil, err
}

View file

@ -90,7 +90,7 @@ func rfc5424microformatterWithAppNameAsTag(p syslog.Priority, hostname, tag, con
// the context. Supported context configuration variables are
// syslog-address, syslog-facility, syslog-format.
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 {
return nil, err
}