update
parent
f2579ec65a
commit
0f342edffa
2
go.mod
2
go.mod
|
@ -2,7 +2,7 @@ module kumoly.io/lib/ksrv
|
|||
|
||||
go 1.17
|
||||
|
||||
require kumoly.io/lib/klog v0.0.4
|
||||
require kumoly.io/lib/klog v0.0.8
|
||||
|
||||
require (
|
||||
github.com/mattn/go-isatty v0.0.14 // indirect
|
||||
|
|
2
go.sum
2
go.sum
|
@ -12,3 +12,5 @@ kumoly.io/lib/klog v0.0.3 h1:DpJ6i9Y5I4DCEBb7j5oaAPc9tUTB9rDHE2J4bqmsYJY=
|
|||
kumoly.io/lib/klog v0.0.3/go.mod h1:Snm+c1xRrh/RbXsxQf7UGYbAJGPcIa6bEEN+CmzJh7M=
|
||||
kumoly.io/lib/klog v0.0.4 h1:Ev9G/zvLt/C8Q1yWfYoUcXVJWgPMjpqHPat2WKyOPIM=
|
||||
kumoly.io/lib/klog v0.0.4/go.mod h1:Snm+c1xRrh/RbXsxQf7UGYbAJGPcIa6bEEN+CmzJh7M=
|
||||
kumoly.io/lib/klog v0.0.8 h1:6hTfDlZh7KGnPrd2tUrauCKRImSnyyN9DHXpey3Czn8=
|
||||
kumoly.io/lib/klog v0.0.8/go.mod h1:Snm+c1xRrh/RbXsxQf7UGYbAJGPcIa6bEEN+CmzJh7M=
|
||||
|
|
11
kserver.go
11
kserver.go
|
@ -21,6 +21,14 @@ func New() *kserver {
|
|||
l := klog.Sub("KSRV")
|
||||
l.SetPrinter(func(w io.Writer, d *klog.Ldata, l2 *klog.Logger) {
|
||||
status, ok := d.Fields["Status"].(int)
|
||||
msg := d.Message
|
||||
if msg != "" {
|
||||
msg = l.M(msg, klog.FgRed)
|
||||
}
|
||||
stack := d.Stack
|
||||
if stack != "" {
|
||||
stack = l.M(stack, klog.FgRed)
|
||||
}
|
||||
if !ok {
|
||||
status = 500
|
||||
}
|
||||
|
@ -30,8 +38,7 @@ func New() *kserver {
|
|||
StatusColor(status, l),
|
||||
d.Fields["IP"],
|
||||
MethodColor(d.Fields["Method"], l),
|
||||
d.Fields["URL"], l.M(d.Message, klog.FgRed),
|
||||
l.M(d.Stack, klog.FgRed),
|
||||
d.Fields["URL"], msg, stack,
|
||||
)
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in New Issue