Skip to content

Commit

Permalink
new timestamp supported: "ts"
Browse files Browse the repository at this point in the history
  • Loading branch information
janhalfar committed Jan 28, 2021
1 parent 57b8191 commit 194ec82
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ archives:
- format: tar.gz

brews:
- github:
- tap:
owner: foomo
name: homebrew-logfrog
caveats: "logfrog --help"
Expand Down
44 changes: 36 additions & 8 deletions dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package logfrog

import (
"fmt"
"sort"
"strings"

"github.com/fatih/color"
Expand Down Expand Up @@ -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{})
Expand Down
2 changes: 1 addition & 1 deletion printcli.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down

0 comments on commit 194ec82

Please sign in to comment.