3 logutils is a Go package that augments the standard library "log" package
4 to make logging a bit more modern, without fragmenting the Go ecosystem
5 with new logging packages.
7 ## The simplest thing that could possibly work
9 Presumably your application already uses the default `log` package. To switch, you'll want your code to look like the following:
18 "github.com/hashicorp/logutils"
22 filter := &logutils.LevelFilter{
23 Levels: []logutils.LogLevel{"DEBUG", "WARN", "ERROR"},
24 MinLevel: logutils.LogLevel("WARN"),
29 log.Print("[DEBUG] Debugging") // this will not print
30 log.Print("[WARN] Warning") // this will
31 log.Print("[ERROR] Erring") // and so will this
32 log.Print("Message I haven't updated") // and so will this
36 This logs to standard error exactly like go's standard logger. Any log messages you haven't converted to have a level will continue to print as before.