Removed logs where possible, for now.

This commit is contained in:
Jesse Malotaux 2025-04-12 15:30:51 +02:00
parent 266110a51f
commit d373237127
5 changed files with 9 additions and 14 deletions

View file

@ -2,7 +2,6 @@ package app
import ( import (
"be/app/helper" "be/app/helper"
"log"
"mime" "mime"
"net/http" "net/http"
"path/filepath" "path/filepath"
@ -31,8 +30,6 @@ func ApiGet(w http.ResponseWriter, r *http.Request) {
file = "../public" + r.URL.Path // request file = "../public" + r.URL.Path // request
} }
log.Println("ApiGet file: ", file)
contentType := mime.TypeByExtension(filepath.Ext(file)) // get content type contentType := mime.TypeByExtension(filepath.Ext(file)) // get content type
if contentType != "" { if contentType != "" {

View file

@ -4,7 +4,6 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"log"
"os" "os"
"regexp" "regexp"
"strings" "strings"
@ -50,19 +49,20 @@ func RunMacroSteps(steps []map[string]interface{}) error {
switch step["type"] { switch step["type"] {
case "key": case "key":
keyCode := step["code"].(string) keyCode := step["code"].(string)
if strings.Contains(keyCode, "|") { if strings.Contains(keyCode, "|") {
keyCode = handleToggleCode(keyCode, step["direction"].(string)) keyCode = handleToggleCode(keyCode, step["direction"].(string))
} }
log.Println("keycode", keyCode, step["direction"].(string))
robotgo.KeyToggle(keyCode, step["direction"].(string)) robotgo.KeyToggle(keyCode, step["direction"].(string))
case "delay": case "delay":
log.Println("delay", step["value"].(float64))
time.Sleep(time.Duration(step["value"].(float64)) * time.Millisecond) time.Sleep(time.Duration(step["value"].(float64)) * time.Millisecond)
default: default:
return errors.New("RunMacroSteps Unknown step type: %v" + fmt.Sprint(step["type"])) return errors.New("RunMacroSteps Unknown step type: %v" + fmt.Sprint(step["type"]))
} }
} }
log.Println("-----")
return nil return nil
} }

View file

@ -16,7 +16,7 @@ func MCRMLogInit() {
} }
// Optionally set log to write to file in addition to standard log output // Optionally set log to write to file in addition to standard log output
// log.SetOutput(logFile) log.SetOutput(logFile)
} }
func MCRMLog(v ...interface{}) { func MCRMLog(v ...interface{}) {

View file

@ -4,7 +4,6 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io" "io"
"log"
"net/http" "net/http"
"os" "os"
"path/filepath" "path/filepath"
@ -40,8 +39,6 @@ func SaveMacro(w http.ResponseWriter, r *http.Request) {
return return
} }
log.Println(simplifiedSteps)
err = os.WriteFile("../macros/"+helper.FormatMacroFileName(newMacro.Name)+".json", stepsJSON, 0644) err = os.WriteFile("../macros/"+helper.FormatMacroFileName(newMacro.Name)+".json", stepsJSON, 0644)
if err != nil { if err != nil {
MCRMLog("SaveMacro WriteFile Error: ", err) MCRMLog("SaveMacro WriteFile Error: ", err)
@ -111,7 +108,9 @@ func PlayMacro(data string, w http.ResponseWriter, r *http.Request) {
} }
macro := req.Macro macro := req.Macro
log.Println("PlayMacro: ", macro)
MCRMLog("Playing Macro: ", macro)
var filename = helper.FormatMacroFileName(macro) var filename = helper.FormatMacroFileName(macro)
var filepath = fmt.Sprintf("../macros/%s.json", filename) var filepath = fmt.Sprintf("../macros/%s.json", filename)

View file

@ -16,13 +16,12 @@ func main() {
} }
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
log.Println("HANDLEFUNC", r.URL.Path)
apiInit(w, r) apiInit(w, r)
}) })
log.Println("Listening on http://localhost:" + helper.EnvGet("MCRM__PORT")) log.Println("Listening on http://localhost:" + helper.EnvGet("MCRM__PORT"))
// helper.OpenBrowser("http://localhost:" + helper.EnvGet("MCRM__PORT")) helper.OpenBrowser("http://localhost:" + helper.EnvGet("MCRM__PORT"))
app.MCRMLog(http.ListenAndServe(":"+helper.EnvGet("MCRM__PORT"), nil)) app.MCRMLog(http.ListenAndServe(":"+helper.EnvGet("MCRM__PORT"), nil))