Simple hierarchical Go logger
- Serializes all logs on a "background" goroutine
- If the output writer is a TTY, use terminal colors (disable by unsetting
FColor
) - Hierarchical;
SubLogger
creates a logger with shared output, level and prefix
func main() {
log.RootLogger.EnableFeatures(log.FMicroseconds)
log.Info("Hello")
log.RootLogger.Level = log.LevelDebug
log.Debug("Wild %#v", Things{})
fooLogger := log.SubLogger("[foo]")
fooLogger.Warn("Danger, Will Robinson")
log.Sync()
}
12:54:34.794802 [info] Hello
12:54:34.794826 [debug] Wild Things{Field:0} (log_test.go:18)
12:54:34.794887 [warn] [foo] Danger, Will Robinson
See documentation or log_test.go
for more details.