forked from x/icebergs
opt log.debug
This commit is contained in:
parent
15da224680
commit
40f562ae7a
@ -86,6 +86,7 @@ const (
|
||||
RELOAD = "reload"
|
||||
RESTART = "restart"
|
||||
|
||||
DELAY = "delay"
|
||||
BEGIN = "begin"
|
||||
START = "start"
|
||||
OPEN = "open"
|
||||
|
@ -48,6 +48,7 @@ func init() {
|
||||
}},
|
||||
RESTART: {Hand: func(m *ice.Message, arg ...string) { m.Cmd(gdb.SIGNAL, gdb.RESTART) }},
|
||||
STOP: {Hand: func(m *ice.Message, arg ...string) { m.Cmd(gdb.SIGNAL, gdb.STOP) }},
|
||||
DELAY: {Hand: func(m *ice.Message, arg ...string) { m.Sleep(arg[0]).Cmdy(arg[1:]) }},
|
||||
}, Hand: func(m *ice.Message, arg ...string) {
|
||||
if len(arg) == 0 {
|
||||
m.Cmdy(RUNTIME, BOOTINFO)
|
||||
|
73
base/log/debug.go
Normal file
73
base/log/debug.go
Normal file
@ -0,0 +1,73 @@
|
||||
package log
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
const DEBUG = "debug"
|
||||
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
DEBUG: {Name: "debug level=watch,bench,watch,error,trace offset filter auto doc", Help: "后台日志", Actions: ice.Actions{
|
||||
"doc": {Help: "文档", Hand: func(m *ice.Message, arg ...string) { m.ProcessOpen("https://pkg.go.dev/std") }},
|
||||
}, Hand: func(m *ice.Message, arg ...string) {
|
||||
offset := kit.Int(kit.Select("0", arg, 1))
|
||||
switch arg[0] {
|
||||
case "bench", ERROR, "trace":
|
||||
m.Cmd(nfs.CAT, ice.VAR_LOG+arg[0]+".log", func(line string, index int) {
|
||||
if len(arg) > 2 && !strings.Contains(line, arg[2]) || index < offset {
|
||||
return
|
||||
}
|
||||
ls := strings.SplitN(line, ice.SP, 6)
|
||||
m.Push(mdb.TIME, ls[0]+ice.SP+ls[1])
|
||||
m.Push(mdb.ID, ls[2])
|
||||
m.Push("ship", ls[3])
|
||||
|
||||
i := strings.LastIndex(ls[5], ice.SP)
|
||||
if strings.HasPrefix(ls[5][i+1:], "base") || strings.HasPrefix(ls[5][i+1:], "core") || strings.HasPrefix(ls[5][i+1:], "misc") {
|
||||
m.Push(nfs.PATH, ice.USR_ICEBERGS)
|
||||
m.Push(nfs.FILE, strings.TrimSpace(strings.Split(ls[5][i:], ice.DF)[0]))
|
||||
m.Push(nfs.LINE, strings.TrimSpace(strings.Split(ls[5][i:], ice.DF)[1]))
|
||||
ls[5] = ls[5][:i]
|
||||
} else if strings.HasPrefix(ls[5][i+1:], "usr/icebergs/") {
|
||||
m.Push(nfs.PATH, ice.USR_ICEBERGS)
|
||||
m.Push(nfs.FILE, strings.TrimPrefix(strings.TrimSpace(strings.Split(ls[5][i:], ice.DF)[0]), ice.USR_ICEBERGS))
|
||||
m.Push(nfs.LINE, strings.TrimSpace(strings.Split(ls[5][i:], ice.DF)[1]))
|
||||
ls[5] = ls[5][:i]
|
||||
} else {
|
||||
m.Push(nfs.PATH, ice.USR_ICEBERGS)
|
||||
m.Push(nfs.FILE, "init.go")
|
||||
m.Push(nfs.LINE, "90")
|
||||
}
|
||||
m.Push(ctx.ACTION, ls[4])
|
||||
m.Push(mdb.TEXT, ls[5])
|
||||
})
|
||||
case WATCH:
|
||||
m.Cmd(nfs.CAT, ice.VAR_LOG+arg[0]+".log", func(line string, index int) {
|
||||
if len(arg) > 2 && !strings.Contains(line, arg[2]) || index < offset {
|
||||
return
|
||||
}
|
||||
ls := strings.SplitN(line, ice.SP, 6)
|
||||
m.Push(mdb.TIME, ls[0]+ice.SP+ls[1])
|
||||
m.Push(mdb.ID, ls[2])
|
||||
m.Push("ship", ls[3])
|
||||
|
||||
i := strings.LastIndex(ls[5], ice.SP)
|
||||
m.Push(nfs.PATH, ice.USR_ICEBERGS)
|
||||
m.Push(nfs.FILE, strings.TrimSpace(strings.Split(ls[5][i:], ice.DF)[0]))
|
||||
m.Push(nfs.LINE, strings.TrimSpace(strings.Split(ls[5][i:], ice.DF)[1]))
|
||||
|
||||
m.Push(ctx.ACTION, ls[4])
|
||||
m.Push(mdb.TEXT, ls[5][:i])
|
||||
})
|
||||
}
|
||||
m.StatusTimeCountTotal(offset + m.Length())
|
||||
}},
|
||||
})
|
||||
}
|
1
conf.go
1
conf.go
@ -144,6 +144,7 @@ const ( // DIR
|
||||
SRC_MAIN_GO = "src/main.go"
|
||||
SRC_VERSION_GO = "src/version.go"
|
||||
SRC_BINPACK_GO = "src/binpack.go"
|
||||
SRC_WEBVIEW_GO = "src/webview.go"
|
||||
SRC_RELAY_GO = "src/relay.go"
|
||||
README_MD = "README.md"
|
||||
MAKEFILE = "Makefile"
|
||||
|
@ -10,6 +10,7 @@ import (
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
"shylinux.com/x/icebergs/base/web"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
@ -74,9 +75,13 @@ func _js_show(m *ice.Message, arg ...string) {
|
||||
m.StatusTimeCount()
|
||||
}
|
||||
func _js_exec(m *ice.Message, arg ...string) {
|
||||
if arg[2] == "usr/volcanos/" && strings.HasPrefix(arg[1], "plugin/local/") {
|
||||
if arg[2] == ice.USR_VOLCANOS {
|
||||
if strings.HasPrefix(arg[1], "plugin/local/") {
|
||||
key := "web." + strings.Replace(strings.TrimSuffix(strings.TrimPrefix(arg[1], "plugin/local/"), ".js"), ice.PS, ice.PT, -1)
|
||||
ctx.ProcessCommand(m, kit.Select(ice.CAN_PLUGIN, key), kit.Simple())
|
||||
} else {
|
||||
m.EchoIFrame(web.MergeURL2(m, "/chat/cmd/web.code.vimer", "debug", "true"))
|
||||
}
|
||||
return
|
||||
}
|
||||
ctx.DisplayBase(m, path.Join("/require", path.Join(arg[2], arg[1])))
|
||||
|
@ -63,6 +63,10 @@ func init() {
|
||||
switch arg[0] {
|
||||
case ctx.INDEX:
|
||||
m.Cmdy(ctx.COMMAND, mdb.SEARCH, ctx.COMMAND, ice.OptionFields(ctx.INDEX))
|
||||
case ctx.ARGS:
|
||||
if m.Option(ctx.INDEX) != "" {
|
||||
m.Cmdy(m.Option(ctx.INDEX))
|
||||
}
|
||||
case nfs.PATH:
|
||||
m.Cmdy(INNER, mdb.INPUTS, arg).Cut("path,size,time")
|
||||
case nfs.FILE:
|
||||
@ -159,13 +163,18 @@ func init() {
|
||||
m.Cmdy(AUTOGEN, nfs.MODULE, arg)
|
||||
}},
|
||||
COMPILE: {Help: "编译", Hand: func(m *ice.Message, arg ...string) {
|
||||
const app, _app = "usr/publish/contexts.app", "Contents/MacOS/contexts"
|
||||
isWebview := func() bool { return strings.HasSuffix(os.Args[0], _app) }
|
||||
cmds := []string{COMPILE, ice.SRC_MAIN_GO, ice.BIN_ICE_BIN}
|
||||
if strings.HasSuffix(os.Args[0], "contexts.app/Contents/MacOS/contexts") {
|
||||
m.Option(cli.ENV, "CGO_ENABLED", "1", cli.HOME, kit.Env(cli.HOME), cli.PATH, kit.Path("usr/local/go/bin")+ice.DF+kit.Env(cli.PATH))
|
||||
cmds = []string{COMPILE, "src/webview.go", "usr/publish/contexts.app/Contents/MacOS/contexts"}
|
||||
if isWebview() {
|
||||
m.Option(cli.ENV, "CGO_ENABLED", "1", cli.HOME, kit.Env(cli.HOME), cli.PATH, kit.Path(ice.USR_LOCAL_GO_BIN)+ice.DF+kit.Env(cli.PATH))
|
||||
cmds = []string{COMPILE, ice.SRC_WEBVIEW_GO, path.Join(app, _app)}
|
||||
}
|
||||
if msg := m.Cmd(cmds); cli.IsSuccess(msg) {
|
||||
m.Cmd(UPGRADE, cli.RESTART)
|
||||
if isWebview() {
|
||||
m.Go(func() { m.Cmd(cli.SYSTEM, "./bin/ice.bin", cli.FOREVER, cli.DELAY, "300ms", cli.SYSTEM, cli.OPEN, app) })
|
||||
}
|
||||
m.Go(func() { m.Sleep("10ms").Cmd(UPGRADE, cli.RESTART) })
|
||||
} else {
|
||||
_vimer_make(m, nfs.PWD, msg)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user