diff --git a/internal/config/adpatative_log_confiig.go b/internal/config/adpatative_log_confiig.go index c707da1..eb8bfb0 100644 --- a/internal/config/adpatative_log_confiig.go +++ b/internal/config/adpatative_log_confiig.go @@ -50,6 +50,9 @@ func MakeConfigFromSample(sample []map[string]interface{}, mergeWith ...Key) (*C } else if logType.Contains(k) { keyMap[k] = logType.keyConfig(k) continue + } else if traceId.Contains(k) { + keyMap[k] = traceId.keyConfig(k) + continue } else if message.Contains(k) { keyMap[k] = message.keyConfig(k) continue @@ -78,6 +81,7 @@ func MakeConfigFromSample(sample []map[string]interface{}, mergeWith ...Key) (*C var orderedKeys []string orderedKeys = append(orderedKeys, timestamp.Keys()...) orderedKeys = append(orderedKeys, logType.Keys()...) + orderedKeys = append(orderedKeys, traceId.Keys()...) orderedKeys = append(orderedKeys, message.Keys()...) orderedKeys = append(orderedKeys, errorKey.Keys()...) for _, v := range orderedKeys { @@ -88,7 +92,7 @@ func MakeConfigFromSample(sample []map[string]interface{}, mergeWith ...Key) (*C var sk []string for k := range keyMap { - if !timestamp.Contains(k) && !message.Contains(k) && !logType.Contains(k) && !errorKey.Contains(k) { + if !timestamp.Contains(k) && !message.Contains(k) && !traceId.Contains(k) && !logType.Contains(k) && !errorKey.Contains(k) { sk = append(sk, k) } } @@ -156,6 +160,20 @@ var ( } }, } + traceId = preBakedRule{ + keyMatchesAny: map[string]bool{"traceId": true}, + keyConfig: func(keyName string) *Key { + return &Key{ + Name: keyName, + Type: TypeDateTime, + MaxWidth: 32, + Color: Color{ + Foreground: "olive", + Background: "black", + }, + } + }, + } logType = preBakedRule{ keyMatchesAny: map[string]bool{"level": true, "severity": true}, keyConfig: func(keyName string) *Key { diff --git a/internal/loggo/log_view.go b/internal/loggo/log_view.go index 7073812..9a7a6b7 100644 --- a/internal/loggo/log_view.go +++ b/internal/loggo/log_view.go @@ -142,6 +142,12 @@ func (l *LogView) makeUIComponents() { SetFixed(1, 1). SetSeparator(tview.Borders.Vertical). SetContent(l.data) + l.table. + SetFocusFunc(func() { + if l.isJsonViewShown() { + l.updateBottomBarMenu() + } + }) l.table.SetSelectedFunc(selection). SetBackgroundColor(color.ColorBackgroundField) l.table.SetSelectionChangedFunc(func(row, column int) { @@ -260,12 +266,7 @@ func (l *LogView) makeLayoutsWithJsonView() { go func() { time.Sleep(10 * time.Millisecond) l.updateBottomBarMenu() - }() - }) - l.jsonView.textView.SetBlurFunc(func() { - go func() { - time.Sleep(10 * time.Millisecond) - l.updateBottomBarMenu() + l.app.Draw() }() }) l.app.SetFocus(l.table) diff --git a/internal/reader/file_reader.go b/internal/reader/file_reader.go index 9896f5d..977fee5 100644 --- a/internal/reader/file_reader.go +++ b/internal/reader/file_reader.go @@ -36,7 +36,7 @@ type fileStream struct { func (s *fileStream) StreamInto() error { var err error - s.tail, err = tail.TailFile(s.fileName, tail.Config{Follow: true}) + s.tail, err = tail.TailFile(s.fileName, tail.Config{Follow: true, Poll: true}) if err != nil { return err }