From ca064bcc17c11b0d19cb1c02f1fa1496dbb13a69 Mon Sep 17 00:00:00 2001 From: shylinux Date: Thu, 30 Mar 2023 08:34:49 +0800 Subject: [PATCH] opt some --- base/log/debug.go | 10 +++++++++- base/yac/stack.go | 25 +++++++++++++------------ 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/base/log/debug.go b/base/log/debug.go index 5ddcb6eb..210fa16f 100644 --- a/base/log/debug.go +++ b/base/log/debug.go @@ -15,8 +15,13 @@ const DEBUG = "debug" func init() { Index.MergeCommands(ice.Commands{ - DEBUG: {Name: "debug level=error,bench,debug,error,watch offset filter auto doc", Help: "后台日志", Actions: ice.Actions{ + DEBUG: {Name: "debug level=error,bench,debug,error,watch offset filter auto reset doc", Help: "后台日志", Actions: ice.Actions{ "doc": {Help: "文档", Hand: func(m *ice.Message, arg ...string) { m.ProcessOpen("https://pkg.go.dev/std") }}, + "reset": {Help: "文档", Hand: func(m *ice.Message, arg ...string) { + m.Cmd(nfs.CAT, ice.VAR_LOG+arg[0]+".log", func(line string, index int) { + m.ProcessRewrite("offset", index+2) + }) + }}, }, Hand: func(m *ice.Message, arg ...string) { offset, stats := kit.Int(kit.Select("0", arg, 1)), map[string]int{} switch arg[0] { @@ -26,6 +31,9 @@ func init() { return } ls := strings.SplitN(line, ice.SP, 6) + if len(ls) < 6 { + return + } m.Push(mdb.TIME, ls[0]+ice.SP+ls[1]).Push(mdb.ID, ls[2]) i := strings.LastIndex(ls[5], ice.SP) if strings.HasPrefix(ls[5][i+1:], ice.BASE) || strings.HasPrefix(ls[5][i+1:], ice.CORE) || strings.HasPrefix(ls[5][i+1:], ice.MISC) { diff --git a/base/yac/stack.go b/base/yac/stack.go index dc28773b..a640b669 100644 --- a/base/yac/stack.go +++ b/base/yac/stack.go @@ -10,10 +10,21 @@ import ( kit "shylinux.com/x/toolkits" ) +const ( + EXPR = "expr" + OPS = "(,){;}!=<>+-*/" + OPEN = "(" + FIELD = "," + CLOSE = ")" + BEGIN = "{" + SPLIT = ";" + END = "}" + DISABLE = -1 +) + var level = map[string]int{ "++": 100, - "*": 30, "/": 30, - "+": 20, "-": 20, + "+": 20, "-": 20, "*": 30, "/": 30, "<": 10, ">": 10, "<=": 10, ">=": 10, "==": 10, "!=": 10, "(": 2, ")": 2, "=": 1, @@ -306,16 +317,6 @@ func _parse_rest(split string, arg ...string) ([]string, []string) { } const ( - OPS = "{()}+-*/;" - EXPR = "expr" - BEGIN = "{" - SPLIT = ";" - FIELD = "," - OPEN = "(" - CLOSE = ")" - END = "}" - DISABLE = -1 - PWD = "pwd" CMD = "cmd" LET = "let"