Skip to content

Commit

Permalink
Fixed streaming bugs on tailed local files, and ui refresh for TAB key.
Browse files Browse the repository at this point in the history
  • Loading branch information
aurc committed Aug 15, 2022
1 parent bdaf25a commit ed29d32
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
20 changes: 19 additions & 1 deletion internal/config/adpatative_log_confiig.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand All @@ -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)
}
}
Expand Down Expand Up @@ -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 {
Expand Down
13 changes: 7 additions & 6 deletions internal/loggo/log_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion internal/reader/file_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit ed29d32

Please sign in to comment.