Disable DEBUG logs unless explicitly enabled
This commit is contained in:
@@ -25,9 +25,10 @@ func (l Level) String() string {
|
||||
}
|
||||
|
||||
var (
|
||||
DB *gorm.DB
|
||||
file *os.File
|
||||
console = log.New(os.Stderr, "", 0)
|
||||
DB *gorm.DB
|
||||
file *os.File
|
||||
console = log.New(os.Stderr, "", 0)
|
||||
SetLevel Level = LevelInfo
|
||||
)
|
||||
|
||||
// AddFile attaches or replaces the file backend
|
||||
@@ -36,7 +37,7 @@ func AddFile(path string) error {
|
||||
file.Close()
|
||||
}
|
||||
|
||||
_, err := os.OpenFile(path, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
|
||||
_, err := os.OpenFile(path, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0o644)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -61,6 +62,9 @@ func Close() error {
|
||||
}
|
||||
|
||||
func logMsg(level Level, format string, args ...any) {
|
||||
if level == LevelDebug && SetLevel != LevelDebug {
|
||||
return
|
||||
}
|
||||
message := fmt.Sprintf(format, args...)
|
||||
now := time.Now()
|
||||
timestamp := now.Format("2006-01-02 15:04:05.000")
|
||||
|
||||
Reference in New Issue
Block a user