try switching log() to http writes

This commit is contained in:
Jeff Carr 2024-11-07 01:25:12 -06:00
parent 2de5fd7955
commit 3c1b670663
3 changed files with 13 additions and 8 deletions

View File

@ -2,6 +2,7 @@
package main package main
import ( import (
"net/http"
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
@ -11,8 +12,8 @@ import (
"go.wit.com/log" "go.wit.com/log"
) )
func doRelease() bool { func doRelease(w http.ResponseWriter) bool {
log.Info("doRelease() on", me.current.Name()) msg(w, "doRelease() on", me.current.Name())
// double check release version logic // double check release version logic
if me.release.releaseVersionB.String() != "release version "+me.release.version.String() { if me.release.releaseVersionB.String() != "release version "+me.release.version.String() {
log.Warn("something went wrong with the release.version:", me.release.version.String()) log.Warn("something went wrong with the release.version:", me.release.version.String())

12
http.go
View File

@ -17,14 +17,18 @@ func cleanURL(url string) string {
} }
// send stuff to the socket and stdout // send stuff to the socket and stdout
func msg(w http.ResponseWriter, s string) { func msg(w http.ResponseWriter, a ...any) {
log.Info(s) if w == nil {
fmt.Fprintln(w, s) log.Info(a)
} else {
fmt.Fprintln(w, a)
}
} }
func okHandler(w http.ResponseWriter, r *http.Request) { func okHandler(w http.ResponseWriter, r *http.Request) {
var route string var route string
route = cleanURL(r.URL.Path) route = cleanURL(r.URL.Path)
log.HttpMode(w)
// common http args that can be set // common http args that can be set
repoName := r.URL.Query().Get("repo") repoName := r.URL.Query().Get("repo")
@ -62,7 +66,7 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
} }
case "/doRelease": case "/doRelease":
buttonDisable() buttonDisable()
if doRelease() { if doRelease(w) {
buttonEnable() buttonEnable()
msg(w, "doRelease() worked") msg(w, "doRelease() worked")
} else { } else {

View File

@ -60,7 +60,7 @@ func createReleaseBox(box *gui.Node) {
me.release.releaseVersionB = me.release.grid.NewButton("release version", func() { me.release.releaseVersionB = me.release.grid.NewButton("release version", func() {
buttonDisable() buttonDisable()
if doRelease() { if doRelease(nil) {
buttonEnable() buttonEnable()
log.Info("doRelease() worked") log.Info("doRelease() worked")
} else { } else {
@ -146,7 +146,7 @@ func createReleaseBox(box *gui.Node) {
// incase something, somewhere, goes wrong // incase something, somewhere, goes wrong
duration := repolist.TimeFunction(func() { duration := repolist.TimeFunction(func() {
for n := 0; n <= len(me.repos.View.AllRepos()); n++ { for n := 0; n <= len(me.repos.View.AllRepos()); n++ {
if doRelease() { if doRelease(nil) {
log.Info("doRelease() worked") log.Info("doRelease() worked")
} else { } else {
if me.release.status.String() == "ALL DONE?" { if me.release.status.String() == "ALL DONE?" {