@@ -15,17 +15,17 @@ import (
1515)
1616
1717func (app * Application ) getLogLevelStyle (
18- logEntries source. LazyLogEntries ,
18+ renderedRows []table. Row ,
1919 baseStyle lipgloss.Style ,
2020 rowID int ,
2121) lipgloss.Style {
22- if rowID < 0 || rowID >= logEntries . Len ( ) {
22+ if rowID < 0 || rowID >= len ( renderedRows ) {
2323 return baseStyle
2424 }
2525
26- entry := logEntries . Entries [rowID ]. LogEntry ( logEntries . Seeker , app . Config )
26+ row := renderedRows [rowID ]
2727
28- color := getColorForLogLevel (app .getLogLevelFromLogEntry ( entry ))
28+ color := getColorForLogLevel (app .getLogLevelFromLogRow ( row ))
2929 if color == "" {
3030 return baseStyle
3131 }
@@ -62,8 +62,8 @@ func getColorForLogLevel(level source.Level) lipgloss.Color {
6262 }
6363}
6464
65- func (app * Application ) getLogLevelFromLogEntry ( logEntry source. LogEntry ) source.Level {
66- return source .Level (getFieldByKind (app .Config , config .FieldKindLevel , logEntry ))
65+ func (app * Application ) getLogLevelFromLogRow ( row table. Row ) source.Level {
66+ return source .Level (getCellByKind (app .Config , config .FieldKindLevel , row ))
6767}
6868
6969func (app * Application ) handleErrorOccuredMsg (msg events.ErrorOccuredMsg ) (tea.Model , tea.Cmd ) {
@@ -97,13 +97,13 @@ func (app *Application) handleOpenJSONRowRequestedMsg(
9797
9898func (app * Application ) handleKeyMsg (msg tea.KeyMsg ) tea.Cmd {
9999 switch {
100- case key .Matches (msg , defaultKeys .Exit ):
100+ case key .Matches (msg , app . keys .Exit ):
101101 return tea .Quit
102- case key .Matches (msg , defaultKeys .Filter ):
102+ case key .Matches (msg , app . keys .Filter ):
103103 return events .FilterKeyClicked
104- case key .Matches (msg , defaultKeys .Open ):
104+ case key .Matches (msg , app . keys .Open ):
105105 return events .EnterKeyClicked
106- case key .Matches (msg , defaultKeys .ToggleViewArrow ):
106+ case key .Matches (msg , app . keys .ToggleViewArrow ):
107107 return events .ArrowRightKeyClicked
108108 default :
109109 return nil
@@ -151,24 +151,31 @@ func removeClearSequence(value string) string {
151151 return strings .ReplaceAll (value , "\x1b [0" , "\x1b [39" )
152152}
153153
154- func getFieldByKind (
154+ func getCellByKind (
155155 cfg * config.Config ,
156156 kind config.FieldKind ,
157- logEntry source. LogEntry ,
157+ row table. Row ,
158158) string {
159- for i , f := range cfg .Fields {
160- if f .Kind != kind {
161- continue
162- }
159+ index := getIndexByKind (cfg , kind )
163160
164- if i >= len (logEntry .Fields ) {
165- return "-"
166- }
161+ if index < 0 || index >= len (row ) {
162+ return "-"
163+ }
164+
165+ return row [index ]
166+ }
167167
168- return logEntry .Fields [i ]
168+ func getIndexByKind (
169+ cfg * config.Config ,
170+ kind config.FieldKind ,
171+ ) int {
172+ for i , f := range cfg .Fields {
173+ if f .Kind == kind {
174+ return i
175+ }
169176 }
170177
171- return ""
178+ return - 1
172179}
173180
174181func batched [T any ](m T , cmd tea.Cmd ) func (batch []tea.Cmd ) (T , []tea.Cmd ) {
0 commit comments