From bdb7177091c8d897fc0f11c8bf86e6c661d9e6ec Mon Sep 17 00:00:00 2001 From: shy Date: Sun, 24 Dec 2023 00:18:32 +0800 Subject: [PATCH] opt status --- base/web/serve.go | 6 +++--- option.go | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/base/web/serve.go b/base/web/serve.go index 719e40c2..8ebb0e80 100644 --- a/base/web/serve.go +++ b/base/web/serve.go @@ -95,7 +95,7 @@ func _serve_static(msg *ice.Message, w http.ResponseWriter, r *http.Request) boo } func _serve_handle(key string, cmd *ice.Command, m *ice.Message, w http.ResponseWriter, r *http.Request) { debug := strings.Contains(r.URL.String(), "debug=true") || strings.Contains(r.Header.Get(html.Referer), "debug=true") - m.Options(ice.LOG_TRACEID, r.Header.Get(ice.LOG_TRACEID)) + m.Options(ice.LOG_DEBUG, ice.FALSE, ice.LOG_TRACEID, r.Header.Get(ice.LOG_TRACEID)) _log := func(level string, arg ...ice.Any) *ice.Message { if debug || arg[0] == ice.MSG_CMDS { return m.Logs(strings.Title(level), arg...) @@ -136,10 +136,10 @@ func _serve_handle(key string, cmd *ice.Command, m *ice.Message, w http.Response m.W.Header().Add(strings.ReplaceAll(ice.LOG_TRACEID, ".", "-"), m.Option(ice.LOG_TRACEID)) defer func() { Render(m, m.Option(ice.MSG_OUTPUT), kit.List(m.Optionv(ice.MSG_ARGS))...) }() if cmds, ok := _serve_auth(m, key, kit.Simple(m.Optionv(ice.MSG_CMDS)), w, r); ok { + m.Option(ice.MSG_COST, "") defer func() { kit.If(m.Option(ice.MSG_STATUS) == "", func() { m.StatusTimeCount() }) - m.Cost(kit.Format("%s: %s %v", r.Method, r.URL.String(), m.FormatSize())) - m.Options(ice.MSG_COST, m.FormatCost(), ice.MSG_OPTION, kit.Simple(m.Optionv(ice.MSG_OPTION), ice.MSG_COST)) + m.Cost(kit.Format("%s: %s %v", r.Method, r.URL.String(), m.FormatSize())).Options(ice.MSG_COST, m.FormatCost()) }() m.Option(ice.MSG_OPTS, kit.Simple(m.Optionv(ice.MSG_OPTION), func(k string) bool { return !strings.HasPrefix(k, ice.MSG_SESSID) })) if m.Detailv(m.PrefixKey(), cmds); len(cmds) > 1 && cmds[0] == ctx.ACTION && cmds[1] != ctx.ACTION { diff --git a/option.go b/option.go index 0e948ae2..69c2df1f 100644 --- a/option.go +++ b/option.go @@ -81,9 +81,10 @@ func (m *Message) Status(arg ...Any) *Message { func (m *Message) StatusTime(arg ...Any) *Message { args := []string{} kit.If(m.Option(MSG_DEBUG) == TRUE, func() { args = append(args, SIZE, "") }) + kit.If(m.Option(MSG_DEBUG) == TRUE, func() { args = append(args, kit.MDB_COST, m.FormatCost()) }) kit.If(m.Option(MSG_DEBUG) == TRUE, func() { args = append(args, m.OptionSimple(LOG_TRACEID)...) }) kit.If(m.Option(MSG_USERPOD), func(p string) { args = append(args, SPACE, p) }) - return m.Status(TIME, m.Time(), arg, kit.MDB_COST, m.FormatCost(), args) + return m.Status(TIME, m.Time(), arg, args) } func (m *Message) StatusTimeCount(arg ...Any) *Message { return m.StatusTime(append([]Any{kit.MDB_COUNT, kit.Split(m.FormatSize())[0]}, arg...))