Skip to content

Commit

Permalink
Display per-device log on web UI.
Browse files Browse the repository at this point in the history
  • Loading branch information
udhos committed Dec 7, 2016
1 parent f178e67 commit 0262c8f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
2 changes: 1 addition & 1 deletion dev/errlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func errlog(logger hasPrintf, result FetchResult, pathPrefix string, debug bool)
defer f.Close()

// load lines
lines, lineErr := loadLines(f, 5)
lines, lineErr := loadLines(f, 9)
if openErr != nil {
logger.Printf("errlog: could not load lines: '%s': %v", path, lineErr)
return
Expand Down
33 changes: 27 additions & 6 deletions jazigo/web_ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,12 @@ func buildDeviceWindow(jaz *app, e gwu.Event, devID string) string {
propPanel.Add(propText)

showPanel := gwu.NewPanel()
logPanel := gwu.NewPanel()

panel.Add(gwu.NewLabel("Files"), filesPanel) // tab 0
panel.Add(gwu.NewLabel("View Config"), showPanel) // tab 1
panel.Add(gwu.NewLabel("Properties"), propPanel) // tab 2
panel.Add(gwu.NewLabel("Error Log"), gwu.NewLabel("Error Log")) // tab 3
panel.Add(gwu.NewLabel("Files"), filesPanel) // tab 0
panel.Add(gwu.NewLabel("View Config"), showPanel) // tab 1
panel.Add(gwu.NewLabel("Properties"), propPanel) // tab 2
panel.Add(gwu.NewLabel("Error Log"), logPanel) // tab 3

const tabShow = 1 // index

Expand All @@ -169,10 +170,29 @@ func buildDeviceWindow(jaz *app, e gwu.Event, devID string) string {
jaz.logger.Printf("buildDeviceWindow: could find last config for device: %v", lastErr)
}

loadView := func(e gwu.Event, show string) {
loadLog := func(e gwu.Event) {

showPanel.Clear()
logPath := dev.ErrlogPath(jaz.logPathPrefix, devID)
logPanel.Clear()
logPanel.Add(gwu.NewLabel("File: " + logPath))

b, readErr := store.FileRead(logPath)
if readErr != nil {
logPanel.Add(gwu.NewLabel(fmt.Sprintf("Could not read '%s': %v", logPath, readErr)))
}

text := string(b)

logBox := gwu.NewTextBox("")
logBox.SetRows(30)
logBox.SetCols(100)
logBox.SetText(text)
logPanel.Add(logBox)
e.MarkDirty(logPanel)
}

loadView := func(e gwu.Event, show string) {
showPanel.Clear()
showPanel.Add(gwu.NewLabel("File: " + show))

jaz.logger.Printf("FIXME web_ui loadView: limit number of lines read from file")
Expand Down Expand Up @@ -287,6 +307,7 @@ func buildDeviceWindow(jaz *app, e gwu.Event, devID string) string {
propButtonSave.SetEnabled(userIsLogged(e.Session()))
fileList(e) // build file list
resetProp(e) // build file properties
loadLog(e) // load log
e.MarkDirty(win)
}

Expand Down

0 comments on commit 0262c8f

Please sign in to comment.