ssm-browse: added structed log view
This commit is contained in:
parent
9752bb41bc
commit
b3d0fbfe29
11 changed files with 546 additions and 0 deletions
7
internal/slog-view/controllers/events.go
Normal file
7
internal/slog-view/controllers/events.go
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
package controllers
|
||||
|
||||
import "github.com/lmika/awstools/internal/slog-view/models"
|
||||
|
||||
type NewLogFile *models.LogFile
|
||||
|
||||
type ViewLogLineFullScreen *models.LogLine
|
||||
47
internal/slog-view/controllers/logfile.go
Normal file
47
internal/slog-view/controllers/logfile.go
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
package controllers
|
||||
|
||||
import (
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
"github.com/lmika/awstools/internal/common/ui/events"
|
||||
"github.com/lmika/awstools/internal/slog-view/models"
|
||||
"github.com/lmika/awstools/internal/slog-view/services/logreader"
|
||||
"sync"
|
||||
)
|
||||
|
||||
type LogFileController struct {
|
||||
logReader *logreader.Service
|
||||
|
||||
// state
|
||||
mutex *sync.Mutex
|
||||
filename string
|
||||
logFile *models.LogFile
|
||||
}
|
||||
|
||||
func NewLogFileController(logReader *logreader.Service, filename string) *LogFileController {
|
||||
return &LogFileController{
|
||||
logReader: logReader,
|
||||
filename: filename,
|
||||
mutex: new(sync.Mutex),
|
||||
}
|
||||
}
|
||||
|
||||
func (lfc *LogFileController) ReadLogFile() tea.Cmd {
|
||||
return func() tea.Msg {
|
||||
logFile, err := lfc.logReader.Open(lfc.filename)
|
||||
if err != nil {
|
||||
return events.Error(err)
|
||||
}
|
||||
|
||||
return NewLogFile(logFile)
|
||||
}
|
||||
}
|
||||
|
||||
func (lfc *LogFileController) ViewLogLineFullScreen(line *models.LogLine) tea.Cmd {
|
||||
if line == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return func() tea.Msg {
|
||||
return ViewLogLineFullScreen(line)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue