mirror of
https://github.com/pomerium/pomerium.git
synced 2025-06-26 06:28:18 +02:00
internal/log: add unit tests
Signed-off-by: Bobby DeSimone <bobbydesimone@gmail.com>
This commit is contained in:
parent
1fa45c6ec2
commit
aa0182008f
2 changed files with 61 additions and 0 deletions
34
internal/log/example_test.go
Normal file
34
internal/log/example_test.go
Normal 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!"}
|
||||
//[90m<nil>[0m [1m[31mERR[0m[0m Debug [36mlevel-logging?=[0myep!
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue