internal/log: add unit tests

Signed-off-by: Bobby DeSimone <bobbydesimone@gmail.com>
This commit is contained in:
Bobby DeSimone 2019-09-28 13:38:44 -07:00
parent 1fa45c6ec2
commit aa0182008f
No known key found for this signature in database
GPG key ID: AEE4CF12FE86D07E
2 changed files with 61 additions and 0 deletions

View file

@ -0,0 +1,34 @@
// Adapted from https://golang.org/src/log/example_test.go
// Copyright 2013 The Go Authors. See 3RD-PARTY file for license.
package log_test
import (
"bytes"
"fmt"
stdlog "log"
"os"
"github.com/pomerium/pomerium/internal/log"
"github.com/rs/zerolog"
)
func ExampleLogger() {
log.Logger = zerolog.New(os.Stdout).With().Str("level-logging?", "yep!").Logger()
var (
buf bytes.Buffer
logger = stdlog.New(&log.StdLogWrapper{Logger: &log.Logger}, "", 0)
)
logger.Print("Hello logger!")
log.SetDebugMode()
logger.Print("Debug")
fmt.Print(&buf)
// Output:
// {"level":"error","level-logging?":"yep!","message":"Hello logger!"}
//<nil> ERR Debug level-logging?=yep!
}