Skip to content

Commit 72238da

Browse files
committed
Improved log management in the TUI
1 parent 0452a6a commit 72238da

File tree

6 files changed

+508
-82
lines changed

6 files changed

+508
-82
lines changed

pkg/tui/app.go

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ func Run(ctx context.Context, conf *config.Config) error {
4040
mode: modeServices,
4141
bucketObjects: make(map[string]*bucketObjectState),
4242
serviceDefinitions: make(map[string]string),
43+
logDetails: make(map[string]string),
4344
}
4445

4546
state.statusView.SetBorder(false)
@@ -215,7 +216,7 @@ func Run(ctx context.Context, conf *config.Config) error {
215216
return nil
216217
}
217218
case 'd', 'D':
218-
if app.GetFocus() == state.serviceTable {
219+
if app.GetFocus() == state.serviceTable && state.modeIsServices() {
219220
state.requestDeletion()
220221
return nil
221222
}
@@ -224,7 +225,7 @@ func Run(ctx context.Context, conf *config.Config) error {
224225
return nil
225226
case 'l', 'L':
226227
if app.GetFocus() == state.serviceTable {
227-
state.showServiceLogs()
228+
state.switchToLogs(ctx)
228229
return nil
229230
}
230231
case '?':
@@ -298,6 +299,14 @@ func (s *uiState) selectCluster(ctx context.Context, name string) {
298299
}
299300
s.lastSelection = ""
300301
s.currentBucketObjectsKey = ""
302+
s.logEntries = nil
303+
s.currentLogsKey = ""
304+
s.currentLogJobKey = ""
305+
s.currentLogService = ""
306+
s.currentLogCluster = ""
307+
if s.mode == modeLogs {
308+
s.mode = modeServices
309+
}
301310
s.currentCluster = name
302311
mode := s.mode
303312
errMsg, blocked := s.failedClusters[name]
@@ -350,6 +359,8 @@ func (s *uiState) refreshCurrent(ctx context.Context) {
350359
}
351360
if mode == modeBuckets {
352361
go s.loadBuckets(ctx, name, true)
362+
} else if mode == modeLogs {
363+
go s.loadLogs(ctx, name, s.currentLogService, true)
353364
} else {
354365
go s.loadServices(ctx, name, true)
355366
}
@@ -385,6 +396,13 @@ func (s *uiState) modeIsBuckets() bool {
385396
return mode == modeBuckets
386397
}
387398

399+
func (s *uiState) modeIsLogs() bool {
400+
s.mutex.Lock()
401+
mode := s.mode
402+
s.mutex.Unlock()
403+
return mode == modeLogs
404+
}
405+
388406
func (s *uiState) focusDetailsPane() {
389407
s.queueUpdate(func() {
390408
s.app.SetFocus(s.detailsView)
@@ -428,6 +446,10 @@ func (s *uiState) handleSelection(row int, immediate bool) {
428446
s.handleBucketSelection(row, immediate)
429447
return
430448
}
449+
if mode == modeLogs {
450+
s.handleLogSelection(row, immediate)
451+
return
452+
}
431453
s.handleServiceSelection(row, immediate)
432454
}
433455

0 commit comments

Comments
 (0)