closed #25, #32
All checks were successful
GoLang Tests / Run Go Tests (push) Successful in 49s

This commit is contained in:
2025-09-04 21:22:26 +02:00
parent 0dd75c2126
commit 9ded540314
18 changed files with 224 additions and 119 deletions

View File

@@ -0,0 +1,24 @@
package logs
import (
"log"
"os"
"time"
)
type FileLog struct {
Logger *log.Logger
Close func() error
}
var Logs map[string]FileLog = make(map[string]FileLog)
func NewAudit() (i *log.Logger, close func() error) {
LOG_FILE := "logs/" + time.Now().Format("2006-01-02") + ".log"
logFile, err := os.OpenFile(LOG_FILE, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
log.Panic(err)
}
return log.New(logFile, "", log.LstdFlags), logFile.Close
}

View File

@@ -16,6 +16,10 @@ func GetMonday(ts time.Time) time.Time {
return ts
}
func IsWeekend(ts time.Time) bool {
return ts.Weekday() == time.Saturday || ts.Weekday() == time.Sunday
}
// Converts duration to string
func FormatDuration(d time.Duration) string {
hours := int(d.Abs().Hours())