Fix escape characters in trace command (#2822)
This commit is contained in:
committed by
Nitish Tiwari
parent
1818191dca
commit
ab3e70ae9f
+10
-4
@@ -181,9 +181,14 @@ func shortTrace(ti madmin.TraceInfo) shortTraceMsg {
|
||||
}
|
||||
|
||||
func (s shortTraceMsg) JSON() string {
|
||||
traceJSONBytes, e := json.MarshalIndent(s, "", " ")
|
||||
fatalIf(probe.NewError(e), "Unable to marshal into JSON.")
|
||||
return string(traceJSONBytes)
|
||||
buf := &bytes.Buffer{}
|
||||
enc := json.NewEncoder(buf)
|
||||
enc.SetIndent("", " ")
|
||||
// Disable escaping special chars to display XML tags correctly
|
||||
enc.SetEscapeHTML(false)
|
||||
|
||||
fatalIf(probe.NewError(enc.Encode(s)), "Unable to marshal into JSON.")
|
||||
return buf.String()
|
||||
}
|
||||
|
||||
func (s shortTraceMsg) String() string {
|
||||
@@ -247,7 +252,8 @@ func (t traceMessage) JSON() string {
|
||||
enc.SetIndent("", " ")
|
||||
// Disable escaping special chars to display XML tags correctly
|
||||
enc.SetEscapeHTML(false)
|
||||
enc.Encode(trc)
|
||||
fatalIf(probe.NewError(enc.Encode(trc)), "Unable to marshal into JSON.")
|
||||
|
||||
// strip off extra newline added by json encoder
|
||||
return strings.TrimSuffix(buf.String(), "\n")
|
||||
}
|
||||
|
||||
@@ -29,10 +29,6 @@ var commandsTree = trie.NewTrie()
|
||||
|
||||
// Collection of mc flags currently supported
|
||||
var globalFlags = []cli.Flag{
|
||||
cli.BoolFlag{
|
||||
Name: "autocompletion",
|
||||
Usage: "install auto-completion for your shell",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "config-dir, C",
|
||||
Value: mustGetMcConfigDir(),
|
||||
|
||||
+6
-1
@@ -39,7 +39,12 @@ import (
|
||||
|
||||
var (
|
||||
// global flags for mc.
|
||||
mcFlags = []cli.Flag{}
|
||||
mcFlags = []cli.Flag{
|
||||
cli.BoolFlag{
|
||||
Name: "autocompletion",
|
||||
Usage: "install auto-completion for your shell",
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
// Help template for mc
|
||||
|
||||
Reference in New Issue
Block a user