11## log
2- <img align =" right " src =" https://raw.githubusercontent.com/go-playground/log/master/logo.png " >![ Project status] ( https://img.shields.io/badge/version-8.0.0-green.svg )
2+ <img align =" center " src =" https://raw.githubusercontent.com/go-playground/log/master/logo.png " >![ Project status] ( https://img.shields.io/badge/version-8.0.0-green.svg )
33[ ![ Test] ( https://github.com/go-playground/log/actions/workflows/go.yml/badge.svg )] ( https://github.com/go-playground/log/actions/workflows/go.yml )
44[ ![ Coverage Status] ( https://coveralls.io/repos/github/go-playground/log/badge.svg?branch=master )] ( https://coveralls.io/github/go-playground/log?branch=master )
55[ ![ Go Report Card] ( https://goreportcard.com/badge/github.com/go-playground/log )] ( https://goreportcard.com/report/github.com/go-playground/log )
@@ -40,12 +40,15 @@ package main
4040
4141import (
4242 " io"
43+ stdlog " log"
4344
4445 " github.com/go-playground/errors/v5"
4546 " github.com/go-playground/log/v8"
4647)
4748
4849func main () {
50+ log.RedirectGoStdLog (true )
51+
4952 // Trace
5053 defer log.WithTrace ().Info (" time to run" )
5154
@@ -69,8 +72,8 @@ func main() {
6972
7073 // predefined global fields
7174 log.WithDefaultFields (log.Fields {
72- { " program" , " test" } ,
73- { " version" , " 0.1.3" } ,
75+ log. F ( " program" , " test" ) ,
76+ log. F ( " version" , " 0.1.3" ) ,
7477 }...)
7578
7679 log.WithField (" key" , " value" ).Info (" testing default fields" )
@@ -82,6 +85,10 @@ func main() {
8285 )
8386
8487 logger.WithField (" key" , " value" ).Info (" test" )
88+
89+ stdlog.Println (" This was redirected from Go STD output!" )
90+ log.RedirectGoStdLog (false )
91+ stdlog.Println (" This was NOT redirected from Go STD output!" )
8592}
8693```
8794
@@ -172,18 +179,4 @@ Pull requests for new handlers are welcome when they don't pull in dependencies,
172179
173180Package Versioning
174181----------
175- This package strictly adheres to semantic versioning guidelines.
176-
177- Benchmarks
178- ----------
179- ###### Run on Macbook Pro 15-inch 2017 using go version go1.9.4 darwin/amd64
180- NOTE: only putting benchmarks at others request, by no means does the number of allocations
181- make one log library better than another!
182- ``` go
183- go test --bench=. -benchmem=true
184- goos: darwin
185- goarch: arm64
186- pkg: github.com /go -playground/log/v8/benchmarks
187- BenchmarkLogConsoleTenFieldsParallel-8 2392591 503.3 ns/op 648 B /op 12 allocs/op
188- BenchmarkLogConsoleSimpleParallel-8 4595101 269.9 ns/op 56 B /op 2 allocs/op
189- ```
182+ This package strictly adheres to semantic versioning guidelines.
0 commit comments