Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var LevelToSeverity = func(level zerolog.Level) logging.Severity { switch level { case zerolog.DebugLevel: return logging.Debug case zerolog.WarnLevel: return logging.Warning case zerolog.ErrorLevel: return logging.Error case zerolog.FatalLevel: return logging.Alert case zerolog.PanicLevel: return logging.Emergency default: return logging.Info } }
LevelToSeverity converts a zerolog level to the stackdriver severity Stackdriver has more levels than zerolog so we skip some severities. By default we set info when no level is provided.
Functions ¶
func Flatten ¶
func Flatten(value interface{}) string
Flatten transforms a struct into a flattened string, like: a.b.c: 'val', c.d: 'val' Pointer values will translate into memory addresses
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!! IMPORTANT SECURITY NOTE !!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Flatten will place ALL keys of the given structure on the resulted string. This means that ANY sensitive data in the flattened structure WILL be exposed!
func MustParseLevel ¶
MustParseLevel transforms a string in a zerolog level
func SetupLogger ¶
SetupLogger sets the global logger by configuring the global zerolog.Log and also the go's log package.
func SetupLoggerWithContext ¶
func SetupLoggerWithContext(ctx context.Context, config Config, version string, extraLogWriters ...io.Writer) context.Context
SetupLoggerWithContext returns a context enriched with a logger. The logger is created using SetupLogger, what implies that it will be also available globally.