diff options
Diffstat (limited to 'vendor/github.com/hashicorp/logutils/README.md')
-rw-r--r-- | vendor/github.com/hashicorp/logutils/README.md | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/vendor/github.com/hashicorp/logutils/README.md b/vendor/github.com/hashicorp/logutils/README.md new file mode 100644 index 0000000..49490ea --- /dev/null +++ b/vendor/github.com/hashicorp/logutils/README.md | |||
@@ -0,0 +1,36 @@ | |||
1 | # logutils | ||
2 | |||
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. | ||
6 | |||
7 | ## The simplest thing that could possibly work | ||
8 | |||
9 | Presumably your application already uses the default `log` package. To switch, you'll want your code to look like the following: | ||
10 | |||
11 | ```go | ||
12 | package main | ||
13 | |||
14 | import ( | ||
15 | "log" | ||
16 | "os" | ||
17 | |||
18 | "github.com/hashicorp/logutils" | ||
19 | ) | ||
20 | |||
21 | func main() { | ||
22 | filter := &logutils.LevelFilter{ | ||
23 | Levels: []logutils.LogLevel{"DEBUG", "WARN", "ERROR"}, | ||
24 | MinLevel: logutils.LogLevel("WARN"), | ||
25 | Writer: os.Stderr, | ||
26 | } | ||
27 | log.SetOutput(filter) | ||
28 | |||
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 | ||
33 | } | ||
34 | ``` | ||
35 | |||
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. | ||