implemented more logging functionality
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user