implemented more logging functionality

This commit is contained in:
Gregory Wells
2026-03-24 20:06:06 -04:00
parent d4512e9cce
commit 92f7c0f127
3 changed files with 56 additions and 15 deletions

View File

@@ -1,6 +1,7 @@
package main
import (
"net/http"
"os"
"astraltech.xyz/accountmanager/src/logging"
@@ -29,3 +30,29 @@ func ReadRequiredFile(path string) []byte {
logging.Infof("Successfully read file at %s", path)
return data
}
func Mkdir(path string, perm os.FileMode) error {
logging.Infof("Making directory %s", path)
err := os.Mkdir(path, perm)
if err != nil {
logging.Errorf("Failed to make %s directory", path)
logging.Error(err.Error())
return err
}
return nil
}
func CreateFile(path string) (*os.File, error) {
logging.Infof("Creating %s", path)
file, err := os.Create(path)
if err != nil {
logging.Errorf("Faile to create %s", path)
logging.Error(err.Error())
}
return file, nil
}
func HandleFunc(path string, handler func(http.ResponseWriter, *http.Request)) {
logging.Infof("Handling %s", path)
http.HandleFunc(path, handler)
}