1
0
mirror of https://shylinux.com/x/icebergs synced 2025-04-29 02:29:22 +08:00

opt status

This commit is contained in:
IT 老营长 @云轩领航-创始人 2023-12-24 00:18:32 +08:00
parent 0ef623ae25
commit bdb7177091
2 changed files with 5 additions and 4 deletions

View File

@ -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) { 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") 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 { _log := func(level string, arg ...ice.Any) *ice.Message {
if debug || arg[0] == ice.MSG_CMDS { if debug || arg[0] == ice.MSG_CMDS {
return m.Logs(strings.Title(level), arg...) 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)) 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))...) }() 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 { if cmds, ok := _serve_auth(m, key, kit.Simple(m.Optionv(ice.MSG_CMDS)), w, r); ok {
m.Option(ice.MSG_COST, "")
defer func() { defer func() {
kit.If(m.Option(ice.MSG_STATUS) == "", func() { m.StatusTimeCount() }) 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.Cost(kit.Format("%s: %s %v", r.Method, r.URL.String(), m.FormatSize())).Options(ice.MSG_COST, m.FormatCost())
m.Options(ice.MSG_COST, m.FormatCost(), ice.MSG_OPTION, kit.Simple(m.Optionv(ice.MSG_OPTION), ice.MSG_COST))
}() }()
m.Option(ice.MSG_OPTS, kit.Simple(m.Optionv(ice.MSG_OPTION), func(k string) bool { return !strings.HasPrefix(k, ice.MSG_SESSID) })) 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 { if m.Detailv(m.PrefixKey(), cmds); len(cmds) > 1 && cmds[0] == ctx.ACTION && cmds[1] != ctx.ACTION {

View File

@ -81,9 +81,10 @@ func (m *Message) Status(arg ...Any) *Message {
func (m *Message) StatusTime(arg ...Any) *Message { func (m *Message) StatusTime(arg ...Any) *Message {
args := []string{} 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, 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_DEBUG) == TRUE, func() { args = append(args, m.OptionSimple(LOG_TRACEID)...) })
kit.If(m.Option(MSG_USERPOD), func(p string) { args = append(args, SPACE, p) }) 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 { func (m *Message) StatusTimeCount(arg ...Any) *Message {
return m.StatusTime(append([]Any{kit.MDB_COUNT, kit.Split(m.FormatSize())[0]}, arg...)) return m.StatusTime(append([]Any{kit.MDB_COUNT, kit.Split(m.FormatSize())[0]}, arg...))