This commit is contained in:
24
Backend/helper/logs/main.go
Normal file
24
Backend/helper/logs/main.go
Normal 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
|
||||
}
|
||||
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user