Skip to content

Commit 56b095f

Browse files
committed
add verbose
1 parent 249c39c commit 56b095f

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

main.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"context"
55
"encoding/json"
6+
"flag"
67
"fmt"
78
"image/color"
89
"math"
@@ -106,6 +107,10 @@ func (m *myTheme) Size(name fyne.ThemeSizeName) float32 { return theme.Def
106107
func (m *myTheme) Icon(name fyne.ThemeIconName) fyne.Resource { return theme.DefaultTheme().Icon(name) }
107108

108109
func main() {
110+
111+
verbose := flag.Bool("v", false, "enable verbose logging")
112+
flag.Parse()
113+
109114
config, err := GetConfig()
110115
if err != nil {
111116
fmt.Printf("Config error: %v\n", err)
@@ -144,19 +149,31 @@ func main() {
144149
unavailableData = true
145150
icon = canvas.NewText("❓", color.Gray{Y: 180})
146151
statusText = fmt.Sprintf("%s: unknown", metric.Description)
152+
if *verbose {
153+
fmt.Printf("[%s] %s: error - %v\n", time.Now().Format("15:04:05"), metric.Description, err)
154+
}
147155

148156
case val == 1:
149157
icon = canvas.NewText("✅", color.RGBA{0, 255, 0, 255})
150158
statusText = fmt.Sprintf("%s: UP", metric.Description)
159+
if *verbose {
160+
fmt.Printf("[%s] %s: UP (value = %d)\n", time.Now().Format("15:04:05"), metric.Description, val)
161+
}
151162

152163
case val == 0:
153164
downCount++
154165
icon = canvas.NewText("❌", color.RGBA{255, 0, 0, 255})
155166
statusText = fmt.Sprintf("%s: DOWN", metric.Description)
167+
if *verbose {
168+
fmt.Printf("[%s] %s: DOWN (value = %d)\n", time.Now().Format("15:04:05"), metric.Description, val)
169+
}
156170

157171
default:
158172
icon = canvas.NewText("❓", color.Gray{Y: 180})
159173
statusText = fmt.Sprintf("%s: %d", metric.Description, val)
174+
if *verbose {
175+
fmt.Printf("[%s] %s: UNKNOWN (value = %d)\n", time.Now().Format("15:04:05"), metric.Description, val)
176+
}
160177
}
161178

162179
icon.TextSize = 32
@@ -191,7 +208,6 @@ func main() {
191208

192209
stack := container.NewMax(bg, allContent)
193210
w.SetContent(stack)
194-
fmt.Printf("new pull %s", metricLines)
195211
time.Sleep(config.PullPeriod)
196212
}
197213
}()

0 commit comments

Comments
 (0)