pomerium/internal/log/example_test.go
Bobby DeSimone aa0182008f
internal/log: add unit tests
Signed-off-by: Bobby DeSimone <bobbydesimone@gmail.com>
2019-09-28 13:38:44 -07:00

34 lines
727 B
Go
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 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!
}