From deddfc9457789b83849b234ba23bd863430838bf Mon Sep 17 00:00:00 2001 From: shy Date: Thu, 22 Feb 2024 14:37:12 +0800 Subject: [PATCH] add some --- base/log/bench.go | 13 +++++++++++++ base/log/log.go | 12 +++++++----- core/code/autogen.go | 9 +++++---- 3 files changed, 25 insertions(+), 9 deletions(-) create mode 100644 base/log/bench.go diff --git a/base/log/bench.go b/base/log/bench.go new file mode 100644 index 00000000..1a5542ac --- /dev/null +++ b/base/log/bench.go @@ -0,0 +1,13 @@ +package log + +import ( + ice "shylinux.com/x/icebergs" +) + +const BENCH = "bench" + +func init() { + Index.MergeCommands(ice.Commands{ + BENCH: {Help: "记录", Hand: func(m *ice.Message, arg ...string) {}}, + }) +} diff --git a/base/log/log.go b/base/log/log.go index 943a72f8..1284aea1 100644 --- a/base/log/log.go +++ b/base/log/log.go @@ -29,6 +29,9 @@ func (f *Frame) Begin(m *ice.Message, arg ...string) { } func (f *Frame) Start(m *ice.Message, arg ...string) { mdb.Confm(m, FILE, nil, func(k string, v ice.Map) { + if mdb.Conf(m, k, kit.Keym(mdb.DISABLE)) == ice.TRUE { + return + } if f, p, e := logs.CreateFile(kit.Format(v[nfs.PATH])); e == nil { m.Logs(nfs.SAVE, nfs.FILE, p) v[FILE] = bufio.NewWriter(f) @@ -72,9 +75,6 @@ const ( YELLOW = "yellow" RED = "red" ) -const ( - BENCH = "bench" -) const ( FILE = "file" VIEW = "view" @@ -103,7 +103,7 @@ var Index = &ice.Context{Name: LOG, Help: "日志模块", Configs: ice.Configs{ SHOW: {Name: SHOW, Help: "日志分流", Value: kit.Dict()}, }, Commands: ice.Commands{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { - ice.Info.Load(m, TAIL) + ice.Info.Load(m) mdb.Confm(m, FILE, nil, func(key string, value ice.Map) { kit.For(value[mdb.LIST], func(index int, k string) { m.Conf(SHOW, kit.Keys(k, FILE), key) }) }) @@ -111,7 +111,9 @@ var Index = &ice.Context{Name: LOG, Help: "日志模块", Configs: ice.Configs{ kit.For(value[mdb.LIST], func(index int, k string) { m.Conf(SHOW, kit.Keys(k, VIEW), key) }) }) }}, - ice.CTX_EXIT: {Hand: func(m *ice.Message, arg ...string) { ice.Info.Save(m, TAIL) }}, + ice.CTX_EXIT: {Hand: func(m *ice.Message, arg ...string) { + ice.Info.Save(m) + }}, }} func init() { ice.Index.Register(Index, &Frame{}, TAIL) } diff --git a/core/code/autogen.go b/core/code/autogen.go index 8cb13457..010961ac 100644 --- a/core/code/autogen.go +++ b/core/code/autogen.go @@ -143,14 +143,15 @@ func init() { m.Option(nfs.FILE, path.Join(m.Option(mdb.ZONE), kit.Keys(m.Option(mdb.NAME), GO))) m.Option(mdb.TEXT, kit.Format("`name:\"list %s\" help:\"%s\"`", _autogen_list(m), m.Option(mdb.HELP))) defer m.Go(func() { _autogen_version(m.Spawn()) }) - if p := path.Join(ice.SRC, kit.ExtChange(m.Option(nfs.FILE), SHY)); !nfs.Exists(m, p) { - _autogen_source(m, kit.ExtChange(path.Join(ice.SRC, m.Option(cli.MAIN)), SHY), p) - _autogen_script(m, p) - } if p := path.Join(ice.SRC, m.Option(nfs.FILE)); !nfs.Exists(m, p) { _autogen_import(m, path.Join(ice.SRC, m.Option(cli.MAIN)), m.Option(mdb.ZONE), _autogen_mod(m, ice.GO_MOD)) _autogen_module(m, p) } + return + if p := path.Join(ice.SRC, kit.ExtChange(m.Option(nfs.FILE), SHY)); !nfs.Exists(m, p) { + _autogen_source(m, kit.ExtChange(path.Join(ice.SRC, m.Option(cli.MAIN)), SHY), p) + _autogen_script(m, p) + } }}, DEVPACK: {Help: "开发", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(WEBPACK, mdb.REMOVE) }}, WEBPACK: {Help: "打包", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(WEBPACK, mdb.CREATE) }},