Skip to content

Commit

Permalink
missing file
Browse files Browse the repository at this point in the history
  • Loading branch information
edznux-dd committed Oct 10, 2024
1 parent d2f62a3 commit 7c90d9c
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions pkg/telemetry/log/formatter.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package log

import (
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)

func newTextFormatterConfig(cfg *Config) zap.Config {
var zc zap.Config

zc = zap.NewProductionConfig()

if cfg.useColour {
zc.EncoderConfig.EncodeLevel = zapcore.CapitalColorLevelEncoder
}
zc.EncoderConfig.CallerKey = ""
zc.EncoderConfig.FunctionKey = ""
zc.EncoderConfig.ConsoleSeparator = " "
zc.EncoderConfig.EncodeTime = zapcore.TimeEncoderOfLayout("15:04:05")
zc.EncoderConfig.EncodeDuration = zapcore.StringDurationEncoder
zc.Level.SetLevel(cfg.logLevel.zapLevel())
zc.Encoding = cfg.formatter

// we don't want zap stacktraces because they are incredibly noisy
zc.DisableStacktrace = true
return zc
}

func newJSONFormatterConfig(cfg *Config) zap.Config {
var zc zap.Config
zc = zap.NewProductionConfig()
// We want log.Duration("duration", ...) to naturally map to Datadog's 'duration' standard attribute.
// Datadog displays it nicely and uses it as a default measure for trace search.
// See https://docs.datadoghq.com/logs/log_configuration/attributes_naming_convention/#performance
// The spec requires that it be encoded in nanoseconds (default is seconds).
zc.EncoderConfig.EncodeDuration = zapcore.NanosDurationEncoder
zc.Level.SetLevel(cfg.logLevel.zapLevel())
zc.Encoding = cfg.formatter
// we don't want zap stacktraces because they are incredibly noisy
zc.DisableStacktrace = true
return zc
}

0 comments on commit 7c90d9c

Please sign in to comment.