Documentation ¶
Index ¶
- func IsRedactLogEnabled() bool
- func LogPanic()
- func RedactBytes(arg []byte) []byte
- func RedactString(arg string) string
- func RedactStringer(arg fmt.Stringer) fmt.Stringer
- func SetRedactLog(enabled bool)
- func SetupLogger(logConfig log.Config, logger **zap.Logger, logProps **log.ZapProperties, ...) error
- func StringToZapLogLevel(level string) zapcore.Level
- func ZapRedactByteString(key string, arg []byte) zap.Field
- func ZapRedactString(key, arg string) zap.Field
- func ZapRedactStringer(key string, arg fmt.Stringer) zap.Field
- type FileLogConfig
- type LogConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsRedactLogEnabled ¶
func IsRedactLogEnabled() bool
IsRedactLogEnabled indicates whether the log desensitization is enabled
func LogPanic ¶
func LogPanic()
LogPanic logs the panic reason and stack, then exit the process. Commonly used with a `defer`.
func RedactBytes ¶
RedactBytes receives []byte argument and return omitted information if redact log enabled
func RedactString ¶
RedactString receives string argument and return omitted information if redact log enabled
func RedactStringer ¶
RedactStringer receives stringer argument and return omitted information if redact log enabled
func SetupLogger ¶
func SetupLogger(logConfig log.Config, logger **zap.Logger, logProps **log.ZapProperties, enabled ...bool) error
SetupLogger setup the logger.
func StringToZapLogLevel ¶
StringToZapLogLevel translates log level string to log level.
func ZapRedactByteString ¶
ZapRedactByteString receives []byte argument and return omitted information zap.Field if redact log enabled
func ZapRedactString ¶
ZapRedactString receives string argument and return omitted information in zap.Field if redact log enabled
Types ¶
type FileLogConfig ¶
type FileLogConfig struct { // Log filename, leave empty to disable file log. Filename string `toml:"filename" json:"filename"` // Max size for a single file, in MB. MaxSize int `toml:"max-size" json:"max-size"` // Max log keep days, default is never deleting. MaxDays int `toml:"max-days" json:"max-days"` // Maximum number of old log files to retain. MaxBackups int `toml:"max-backups" json:"max-backups"` }
FileLogConfig serializes file log related config in toml/json.
type LogConfig ¶
type LogConfig struct { // Log level. Level string `toml:"level" json:"level"` // Log format. one of json, text, or console. Format string `toml:"format" json:"format"` // Disable automatic timestamps in output. DisableTimestamp bool `toml:"disable-timestamp" json:"disable-timestamp"` // File log config. File FileLogConfig `toml:"file" json:"file"` }
LogConfig serializes log related config in toml/json.