summaryrefslogtreecommitdiff
path: root/vendor/github.com/op/go-logging/examples/example.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/op/go-logging/examples/example.go')
-rw-r--r--vendor/github.com/op/go-logging/examples/example.go49
1 files changed, 0 insertions, 49 deletions
diff --git a/vendor/github.com/op/go-logging/examples/example.go b/vendor/github.com/op/go-logging/examples/example.go
deleted file mode 100644
index 9f4ddee..0000000
--- a/vendor/github.com/op/go-logging/examples/example.go
+++ /dev/null
@@ -1,49 +0,0 @@
-package main
-
-import (
- "os"
-
- "github.com/op/go-logging"
-)
-
-var log = logging.MustGetLogger("example")
-
-// Example format string. Everything except the message has a custom color
-// which is dependent on the log level. Many fields have a custom output
-// formatting too, eg. the time returns the hour down to the milli second.
-var format = logging.MustStringFormatter(
- `%{color}%{time:15:04:05.000} %{shortfunc} ▶ %{level:.4s} %{id:03x}%{color:reset} %{message}`,
-)
-
-// Password is just an example type implementing the Redactor interface. Any
-// time this is logged, the Redacted() function will be called.
-type Password string
-
-func (p Password) Redacted() interface{} {
- return logging.Redact(string(p))
-}
-
-func main() {
- // For demo purposes, create two backend for os.Stderr.
- backend1 := logging.NewLogBackend(os.Stderr, "", 0)
- backend2 := logging.NewLogBackend(os.Stderr, "", 0)
-
- // For messages written to backend2 we want to add some additional
- // information to the output, including the used log level and the name of
- // the function.
- backend2Formatter := logging.NewBackendFormatter(backend2, format)
-
- // Only errors and more severe messages should be sent to backend1
- backend1Leveled := logging.AddModuleLevel(backend1)
- backend1Leveled.SetLevel(logging.ERROR, "")
-
- // Set the backends to be used.
- logging.SetBackend(backend1Leveled, backend2Formatter)
-
- log.Debugf("debug %s", Password("secret"))
- log.Info("info")
- log.Notice("notice")
- log.Warning("warning")
- log.Error("err")
- log.Critical("crit")
-}