Compare commits
1 Commits
46da048856
...
0f342edffa
Author | SHA1 | Date |
---|---|---|
Evan Chen | 0f342edffa |
2
go.mod
2
go.mod
|
@ -2,7 +2,7 @@ module kumoly.io/lib/ksrv
|
||||||
|
|
||||||
go 1.17
|
go 1.17
|
||||||
|
|
||||||
require kumoly.io/lib/klog v0.0.4
|
require kumoly.io/lib/klog v0.0.8
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/mattn/go-isatty v0.0.14 // indirect
|
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.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 h1:Ev9G/zvLt/C8Q1yWfYoUcXVJWgPMjpqHPat2WKyOPIM=
|
||||||
kumoly.io/lib/klog v0.0.4/go.mod h1:Snm+c1xRrh/RbXsxQf7UGYbAJGPcIa6bEEN+CmzJh7M=
|
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 := klog.Sub("KSRV")
|
||||||
l.SetPrinter(func(w io.Writer, d *klog.Ldata, l2 *klog.Logger) {
|
l.SetPrinter(func(w io.Writer, d *klog.Ldata, l2 *klog.Logger) {
|
||||||
status, ok := d.Fields["Status"].(int)
|
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 {
|
if !ok {
|
||||||
status = 500
|
status = 500
|
||||||
}
|
}
|
||||||
|
@ -30,8 +38,7 @@ func New() *kserver {
|
||||||
StatusColor(status, l),
|
StatusColor(status, l),
|
||||||
d.Fields["IP"],
|
d.Fields["IP"],
|
||||||
MethodColor(d.Fields["Method"], l),
|
MethodColor(d.Fields["Method"], l),
|
||||||
d.Fields["URL"], l.M(d.Message, klog.FgRed),
|
d.Fields["URL"], msg, stack,
|
||||||
l.M(d.Stack, klog.FgRed),
|
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue