http writes moved to 'log'

This commit is contained in:
Jeff Carr 2024-11-07 05:15:54 -06:00
parent 66bd2481ae
commit a95bed236f
3 changed files with 28 additions and 38 deletions

View File

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

57
http.go
View File

@ -16,15 +16,6 @@ func cleanURL(url string) string {
return url
}
// send stuff to the socket and stdout
func msg(w http.ResponseWriter, a ...any) {
if w == nil {
log.Info(a)
} else {
fmt.Fprintln(w, a)
}
}
func okHandler(w http.ResponseWriter, r *http.Request) {
var route string
route = cleanURL(r.URL.Path)
@ -63,11 +54,11 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
for loop.Scan() {
repo := loop.Repo()
tempWin.View.ShowRepo(repo)
log.Info("UnmergedRepo: "+repo.Name())
log.Info("UnmergedRepo: " + repo.Name())
}
case "/doRelease":
buttonDisable()
if doRelease(w) {
if doRelease() {
buttonEnable()
log.Info("doRelease() worked")
} else {
@ -81,10 +72,10 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
} else {
log.Info("findNext() did not find a repo. You might be finished?")
}
log.Info("repo: "+me.release.repo.String())
log.Info("name: "+me.release.version.String())
log.Info("notes: "+me.release.notes.String())
log.Info("status: "+me.release.status.String())
log.Info("repo: " + me.release.repo.String())
log.Info("name: " + me.release.version.String())
log.Info("notes: " + me.release.notes.String())
log.Info("status: " + me.release.status.String())
if me.current == nil {
log.Info("findNext() == nil")
@ -97,9 +88,9 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
me.repos.View.ScanRepositories()
case "/setCurrentRepo":
log.Info("repo: "+repoName)
log.Info("version: "+version)
log.Info("comment: "+comment)
log.Info("repo: " + repoName)
log.Info("version: " + version)
log.Info("comment: " + comment)
repo := me.repos.View.FindRepoByName(repoName)
if repo == nil {
@ -109,12 +100,12 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
setCurrentRepo(repo, "HTTP", "doRelease() ?")
case "/IncrementRevisonVersion":
log.Info("repo: "+repoName)
log.Info("version: "+version)
log.Info("repo: " + repoName)
log.Info("version: " + version)
me.current.Status.IncrementRevisionVersion(comment)
case "/IncrementMinorVersion":
log.Info("repo: "+repoName)
log.Info("version: "+version)
log.Info("repo: " + repoName)
log.Info("version: " + version)
me.current.Status.IncrementMinorVersion("trying minor")
case "/setAllBranchesToMaster":
@ -127,15 +118,15 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
}
return
case "/setTargetVersion":
log.Info("repo: "+repoName)
log.Info("version: "+version)
log.Info("repo: " + repoName)
log.Info("version: " + version)
if me.current == nil {
log.Info("me.current == nil")
return
}
me.current.Status.SetTargetVersion(version)
case "/setAllTargetVersions":
log.Info("version: "+version)
log.Info("version: " + version)
loop := me.repos.View.ReposSortByName()
for loop.Scan() {
@ -155,17 +146,17 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
log.Info("FindRepoByName() returned nil")
return
}
log.Info("whitelisted "+repo.Name())
log.Info("whitelisted " + repo.Name())
if whitelist == "false" {
repo.Status.Whitelist = false
} else {
repo.Status.Whitelist = true
}
case "/showNext":
log.Info("gui repo: "+me.release.repo.String())
log.Info("gui name: "+me.release.version.String())
log.Info("gui notes: "+me.release.notes.String())
log.Info("gui status: "+me.release.status.String())
log.Info("gui repo: " + me.release.repo.String())
log.Info("gui name: " + me.release.version.String())
log.Info("gui notes: " + me.release.notes.String())
log.Info("gui status: " + me.release.status.String())
log.Info("")
if me.current == nil {
log.Info("me.current == nil")
@ -218,9 +209,9 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
log.Info(repolist.ReleaseReportHeader())
log.Info(me.current.StandardReleaseHeader())
case "/list":
me.repos.View.PrintReport(w, readonly, onlydirty, perfect)
me.repos.View.PrintReport(readonly, onlydirty, perfect)
case "/releaseList":
me.repos.View.PrintReleaseReport(w, readonly, perfect)
me.repos.View.PrintReleaseReport(readonly, perfect)
case "/quit":
log.Info("Got URL /quit")
os.Exit(0)
@ -254,7 +245,7 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
}
default:
log.Info("BAD URL = "+route)
log.Info("BAD URL = " + route)
}
}

View File

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