parent
ee76277266
commit
59b6c178a4
13
README.md
13
README.md
|
@ -78,4 +78,17 @@ BenchmarkStackSTD-12 105280 11347 ns/op 3596
|
|||
BenchmarkStackSTDStr-12 234535 5109 ns/op 2755 B/op 27 allocs/op
|
||||
BenchmarkStackCust-12 14764 80228 ns/op 171553 B/op 60 allocs/op
|
||||
BenchmarkStackCustStr-12 15417 78187 ns/op 171262 B/op 61 allocs/op
|
||||
|
||||
v0.0.8
|
||||
go test -bench . -run none --benchmem
|
||||
goos: linux
|
||||
goarch: amd64
|
||||
pkg: kumoly.io/lib/klog
|
||||
cpu: AMD Ryzen 9 5900X 12-Core Processor
|
||||
BenchmarkDefault-12 41521 28847 ns/op 13488 B/op 209 allocs/op
|
||||
BenchmarkSub1-12 37726 31813 ns/op 14256 B/op 269 allocs/op
|
||||
BenchmarkStackSTD-12 119014 10006 ns/op 3308 B/op 19 allocs/op
|
||||
BenchmarkStackSTDStr-12 306621 3798 ns/op 2466 B/op 20 allocs/op
|
||||
BenchmarkStackCust-12 16908 71334 ns/op 170968 B/op 54 allocs/op
|
||||
BenchmarkStackCustStr-12 16702 70945 ns/op 170969 B/op 54 allocs/op
|
||||
```
|
12
log.go
12
log.go
|
@ -67,13 +67,17 @@ func DefaultPrinter() Printer {
|
|||
if l.System != "" {
|
||||
sys = fmt.Sprintf("(%s)", l.System)
|
||||
}
|
||||
fields := []byte{}
|
||||
fields := ""
|
||||
if d.Fields != nil {
|
||||
b, err := json.Marshal(d.Fields)
|
||||
if err != nil {
|
||||
fields = b
|
||||
fields = l.M(string(b), FgHiGreen)
|
||||
}
|
||||
}
|
||||
stack := ""
|
||||
if d.Stack != "" {
|
||||
stack = l.M(d.Stack, FgRed)
|
||||
}
|
||||
switch d.Level {
|
||||
case Lerror:
|
||||
level = l.M("ERROR", FgHiRed)
|
||||
|
@ -89,8 +93,8 @@ func DefaultPrinter() Printer {
|
|||
_, err := fmt.Fprintf(w, "%s [%s]%s%s %s%s\n%s",
|
||||
d.Time.Format("2006/01/02 15:04:05"),
|
||||
level, l.M(sys, FgHiCyan),
|
||||
caller, d.Message, l.M(fields, FgHiGreen),
|
||||
l.M(d.Stack, FgRed),
|
||||
caller, d.Message, fields,
|
||||
stack,
|
||||
)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
|
|
Loading…
Reference in New Issue