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