summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Schlachter <t480-debian-git@schlachter.ca>2025-11-10 00:24:57 -0500
committerDavid Schlachter <t480-debian-git@schlachter.ca>2025-11-10 00:24:57 -0500
commit40e7a37d582f88267d9f884fd0f14a3e3bc1ca85 (patch)
tree72255bd15d954edae92dd8daa76b41a2eb7244a1
parentf45e4b78478f23450b26f3e45a8461a79c73242c (diff)
Improve logging
-rw-r--r--main.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/main.go b/main.go
index dcf5812..f84cddf 100644
--- a/main.go
+++ b/main.go
@@ -37,21 +37,25 @@ func main() {
if err != nil {
log.Fatalf("getting input file: %s", err)
}
+ log.Printf("Started watching '%s'", p)
c := cron.New()
for {
input, err := readInput(p)
if err != nil {
- log.Printf("reading input: %s", err)
+ log.Printf("Error reading input: %s", err)
+ continue
}
if inputChanged(lastSeenInput, input) {
+ log.Print("Updating task list")
lastSeenInput = input
c.Stop()
c := cron.New()
addJobs(c, input)
c.Start()
+ log.Print("Done updating task list")
}
time.Sleep(time.Minute) // re-read the input file every minute
@@ -155,6 +159,7 @@ func createTask(task string) {
bodyBytes, err := io.ReadAll(resp.Body)
if err != nil {
log.Printf("Failed to read body: %s", err)
+ return
}
log.Printf("Got body: %s", string(bodyBytes))
} else {
@@ -165,5 +170,6 @@ func createTask(task string) {
func addJobs(c *cron.Cron, tasks map[inputLine]struct{}) {
for task := range tasks {
c.AddFunc(task.Schedule, func() { createTask(task.Task) })
+ log.Printf("Added '%s' with recurrence '%s'", task.Task, task.Schedule)
}
}