Fix escape characters in trace command (#2822)

This commit is contained in:
Harshavardhana
2019-07-13 09:07:34 +05:30
committed by Nitish Tiwari
parent 1818191dca
commit ab3e70ae9f
3 changed files with 16 additions and 9 deletions
+10 -4
View File
@@ -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")
}
-4
View File
@@ -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
View File
@@ -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