From f2579ec65ad84dda317364ecb38eb7ecf6c8c6cd Mon Sep 17 00:00:00 2001 From: Evan Chen Date: Thu, 11 Nov 2021 14:46:16 +0800 Subject: [PATCH] update --- kserver.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kserver.go b/kserver.go index 47254c2..227773c 100644 --- a/kserver.go +++ b/kserver.go @@ -20,10 +20,14 @@ func (k *kserver) GetLogger() *klog.Logger { 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) + if !ok { + status = 500 + } fmt.Fprintf(w, "[%s] %s |%s| %15s %s %s %s\n%s", l.M("KSRV ", klog.FgHiCyan), d.Time.Format("2006/01/02 15:04:05"), - StatusColor(d.Fields["Status"].(int), l), + StatusColor(status, l), d.Fields["IP"], MethodColor(d.Fields["Method"], l), d.Fields["URL"], l.M(d.Message, klog.FgRed),