diff --git a/.goreleaser.yml b/.goreleaser.yml index 7848542..59b3bdf 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -15,7 +15,7 @@ archives: - format: tar.gz brews: - - github: + - tap: owner: foomo name: homebrew-logfrog caveats: "logfrog --help" diff --git a/dump.go b/dump.go index 3ff31ed..57cf848 100644 --- a/dump.go +++ b/dump.go @@ -2,6 +2,7 @@ package logfrog import ( "fmt" + "sort" "strings" "github.com/fatih/color" @@ -37,22 +38,49 @@ func dump(left func(line int), v interface{}, indent int, label string, line int case nil: fmt.Println("null") case LogData: - for k, value := range v.(LogData) { - dump(left, value, indent+1, k+": ", line+1) + value := v.(LogData) + keys := make([]string, len(value)) + i := 0 + for k := range value { + keys[i] = k + i++ + } + sort.Strings(keys) + for _, k := range keys { + keyValue := value[k] + dump(left, keyValue, indent+1, k+": ", line+1) } case map[string]interface{}: - if len(v.(map[string]interface{})) > 0 { + value := v.(map[string]interface{}) + if len(value) > 0 { fmt.Println() } - for k, value := range v.(map[string]interface{}) { - dump(left, value, indent+1, k+": ", line+1) + keys := make([]string, len(value)) + i := 0 + for k := range value { + keys[i] = k + i++ + } + sort.Strings(keys) + for _, k := range keys { + keyValue := value[k] + dump(left, keyValue, indent+1, k+": ", line+1) } case map[string]string: - if len(v.(map[string]string)) > 0 { + value := v.(map[string]string) + if len(value) > 0 { fmt.Println() } - for k, value := range v.(map[string]string) { - dump(left, value, indent+1, k+": ", line+1) + keys := make([]string, len(value)) + i := 0 + for k := range value { + keys[i] = k + i++ + } + sort.Strings(keys) + for _, k := range keys { + keyValue := value[k] + dump(left, keyValue, indent+1, k+": ", line+1) } case []interface{}: sliceValue := v.([]interface{}) diff --git a/printcli.go b/printcli.go index b07b4aa..5a024cc 100644 --- a/printcli.go +++ b/printcli.go @@ -156,7 +156,7 @@ func (p *Printer) block(label string, lastLabel string, logData LogData) { // extract some data logLevel := strings.ToLower(extract(logData, "level", "Level", "logLevel")) - logTime := extract(logData, "time", "timestamp", "Timestamp") + logTime := extract(logData, "time", "timestamp", "Timestamp", "ts") logMsg := strings.Trim(extract(logData, "msg", "Message", "message"), "\n") logStack := extract(logData, "stack")