From: Thomas Karpiniec Date: Mon, 28 Oct 2024 10:20:58 +0000 (+1100) Subject: Clean up log entries X-Git-Tag: v1.0.0~2 X-Git-Url: https://code.octet-stream.net/broadcaster/commitdiff_plain/8a42be0580469b8fb15fc3369724332f063dca4a?ds=sidebyside;hp=a098a4fcbfe0649cfd9d171e59e822a4bd1b2ec4 Clean up log entries --- diff --git a/radio/main.go b/radio/main.go index 6e31772..eab957a 100644 --- a/radio/main.go +++ b/radio/main.go @@ -55,7 +55,7 @@ func main() { signal.Notify(sig, syscall.SIGINT, syscall.SIGTERM) go func() { sig := <-sig - log.Println("Radio shutting down due to signal", sig) + log.Println("Radio shutting down due to signal:", sig) // Make sure we always stop PTT when program ends ptt.DisengagePTT() os.Exit(0) diff --git a/server/files.go b/server/files.go index b452997..963be99 100644 --- a/server/files.go +++ b/server/files.go @@ -27,15 +27,13 @@ var files AudioFiles func InitAudioFiles(path string) { files.changeWait = make(chan bool) files.path = path - log.Println("initing audio files") files.Refresh() - log.Println("done") } func (r *AudioFiles) Refresh() { entries, err := os.ReadDir(r.path) if err != nil { - log.Println("couldn't read dir", r.path) + log.Println("Couldn't read dir", r.path) return } r.filesMutex.Lock() @@ -44,7 +42,7 @@ func (r *AudioFiles) Refresh() { for _, file := range entries { f, err := os.Open(filepath.Join(r.path, file.Name())) if err != nil { - log.Println("couldn't open", file.Name()) + log.Println("Couldn't open", file.Name()) return } hash := sha256.New() diff --git a/server/main.go b/server/main.go index 69d1ca7..9f6927e 100644 --- a/server/main.go +++ b/server/main.go @@ -413,7 +413,7 @@ func changePasswordPage(w http.ResponseWriter, r *http.Request, user User) { data.ShowForm = false cookie, err := r.Cookie("broadcast_session") if err == nil { - log.Println("clearing other sessions for username", user.Username, "token", cookie.Value) + log.Println("Clearing other sessions for username", user.Username, "token", cookie.Value) db.ClearOtherSessions(user.Username, cookie.Value) } } @@ -642,7 +642,6 @@ func filesPage(w http.ResponseWriter, _ *http.Request, user User) { data := FilesPageData{ Files: files.Files(), } - log.Println("file page data", data) tmpl := template.Must(template.ParseFS(content, "templates/files.html")) err := tmpl.Execute(w, data) if err != nil { @@ -671,7 +670,7 @@ func uploadFile(w http.ResponseWriter, r *http.Request) { f, _ := os.Create(path) defer f.Close() io.Copy(f, file) - log.Println("uploaded file to", path) + log.Println("Uploaded file to", path) files.Refresh() } http.Redirect(w, r, "/files/", http.StatusFound) diff --git a/server/radio_sync.go b/server/radio_sync.go index 66521f8..6eefc8b 100644 --- a/server/radio_sync.go +++ b/server/radio_sync.go @@ -8,7 +8,7 @@ import ( ) func RadioSync(ws *websocket.Conn) { - log.Println("A websocket connected, I think") + log.Println("Radio websocket connected, not yet authenticated") buf := make([]byte, 16384) badRead := false diff --git a/server/session.go b/server/session.go index a097989..1ec3348 100644 --- a/server/session.go +++ b/server/session.go @@ -28,7 +28,6 @@ func currentUser(_ http.ResponseWriter, r *http.Request) (User, error) { func createSessionCookie(w http.ResponseWriter, username string) { sess := generateSession() - log.Println("Generated a random session", sess) expiration := time.Now().Add(365 * 24 * time.Hour) cookie := http.Cookie{Name: "broadcast_session", Value: sess, Expires: expiration, SameSite: http.SameSiteLaxMode} db.InsertSession(username, sess, expiration)