go-logging
go-logging copied to clipboard
Diffrent format / config for diffrent level
Hello, How to make different config / format for each level, e.g. make debug and info with specific properties.
Thank you
https://github.com/op/go-logging/pull/60#issuecomment-159413338
You can easily create your own backend type, e.g:
type MyBackend struct {
backend logging.Backend
}
func (b *MyBackend) Log(level logging.Level, calldepth int, rec *logging.Record) error {
if level == logging.ERROR {
formatted := rec.Formatted(calldepth)
superImportantFunction(formatted)
return nil
} else {
return b.backend.Log(level, calldepth, rec)
}
}