2
0
mirror of https://github.com/acepanel/panel.git synced 2026-02-04 07:57:21 +08:00
Files
panel/internal/bootstrap/logger.go
2024-12-10 00:39:16 +08:00

29 lines
526 B
Go

package bootstrap
import (
"log/slog"
"path/filepath"
"github.com/TheTNB/panel/internal/app"
"gopkg.in/natefinch/lumberjack.v2"
)
func initLogger() {
ljLogger := &lumberjack.Logger{
Filename: filepath.Join(app.Root, "panel/storage/logs/app.log"),
MaxSize: 10,
MaxAge: 30,
Compress: true,
}
level := slog.LevelInfo
if app.Conf.Bool("app.debug") {
level = slog.LevelDebug
}
app.Logger = slog.New(slog.NewJSONHandler(ljLogger, &slog.HandlerOptions{
Level: level,
}))
slog.SetDefault(app.Logger)
}