Documentation
¶
Overview ¶
Package golog provides a standardized way to initialize github.com/rs/zerolog based loggers.
Index ¶
Constants ¶
const CensoredFieldPlaceholder = "***"
CensoredFieldPlaceholder is the default value used to replace censored fields.
Variables ¶
var Default zerolog.Logger
Default is the default global logger.
Functions ¶
func SetLogLevel ¶
func SetLogLevel(l string)
SetLogLevel sets the log level for all logger instances. NOTE: Can be called at any time to change the log level.
func SetTimeFormat ¶
func SetTimeFormat(format string)
SetTimeFormat sets the time format for all logger instances. NOTE: Must be called before `New` to take effect.
func WithCensoredSecretFields ¶ added in v1.1.0
WithCensoredSecretFields returns a logger context with all fields of struct v that have a `secret:"true"` tag censored and replaced with CensoredFieldPlaceholder. Nested structs are supported. The rootName is used as a prefix for all field names.
Example:
type Config struct {
Username string `json:"username"`
Password string `json:"password" secret:"true"`
}
cfg := Config{Username: "admin", Password: "s3cr3t"}
ctx := WithCensoredSecretFields(logger.With(), "config", cfg)
logger := ctx.Logger()
This will log:
{"config.Username":"admin","config.Password":"***"}
Types ¶
This section is empty.