aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/hashicorp/logutils/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/hashicorp/logutils/README.md')
-rw-r--r--vendor/github.com/hashicorp/logutils/README.md36
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
3logutils is a Go package that augments the standard library "log" package
4to make logging a bit more modern, without fragmenting the Go ecosystem
5with new logging packages.
6
7## The simplest thing that could possibly work
8
9Presumably your application already uses the default `log` package. To switch, you'll want your code to look like the following:
10
11```go
12package main
13
14import (
15 "log"
16 "os"
17
18 "github.com/hashicorp/logutils"
19)
20
21func 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
36This 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.