diff --git a/internal/bootstrap/db.go b/internal/bootstrap/db.go index c6d8b277..7bd2a30e 100644 --- a/internal/bootstrap/db.go +++ b/internal/bootstrap/db.go @@ -22,7 +22,6 @@ func initOrm() { zapLogger.LogMode(logLevel) zapLogger.SetAsDefault() - // You can use any other database, like MySQL or PostgreSQL. db, err := gorm.Open(sqlite.Open("storage/panel.db"), &gorm.Config{ Logger: zapLogger, SkipDefaultTransaction: true, diff --git a/internal/bootstrap/logger.go b/internal/bootstrap/logger.go index 9bddd359..eeb87260 100644 --- a/internal/bootstrap/logger.go +++ b/internal/bootstrap/logger.go @@ -1,6 +1,8 @@ package bootstrap import ( + "time" + "go.uber.org/zap" "go.uber.org/zap/zapcore" "gopkg.in/natefinch/lumberjack.v2" @@ -10,7 +12,7 @@ import ( func initLogger() { writeSyncer := zapcore.AddSync(&lumberjack.Logger{ - Filename: "storage/app.log", + Filename: "storage/logs/app.log", MaxSize: 10, MaxBackups: 10, MaxAge: 30, @@ -23,7 +25,7 @@ func initLogger() { } config := zap.NewProductionEncoderConfig() - config.EncodeTime = zapcore.TimeEncoderOfLayout("2006-01-02 15:04:05") + config.EncodeTime = zapcore.TimeEncoderOfLayout(time.DateTime) core := zapcore.NewCore( zapcore.NewJSONEncoder(config), writeSyncer, diff --git a/internal/service/cli.go b/internal/service/cli.go index 63798124..76ff1652 100644 --- a/internal/service/cli.go +++ b/internal/service/cli.go @@ -3,6 +3,7 @@ package service import ( "context" "fmt" + "path/filepath" "github.com/go-rat/utils/hash" "github.com/gookit/color" @@ -214,7 +215,7 @@ func (s *CliService) Init(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("已经初始化过了") } - settings := []biz.Setting{{Key: biz.SettingKeyName, Value: "耗子面板"}, {Key: biz.SettingKeyMonitor, Value: "1"}, {Key: biz.SettingKeyMonitorDays, Value: "30"}, {Key: biz.SettingKeyBackupPath, Value: "/www/backup"}, {Key: biz.SettingKeyWebsitePath, Value: "/www/wwwroot"}, {Key: biz.SettingKeyVersion, Value: app.Conf.String("app.version")}} + settings := []biz.Setting{{Key: biz.SettingKeyName, Value: "耗子面板"}, {Key: biz.SettingKeyMonitor, Value: "1"}, {Key: biz.SettingKeyMonitorDays, Value: "30"}, {Key: biz.SettingKeyBackupPath, Value: filepath.Join(app.Root, "backup")}, {Key: biz.SettingKeyWebsitePath, Value: filepath.Join(app.Root, "wwwroot")}, {Key: biz.SettingKeyVersion, Value: app.Conf.String("app.version")}} if err := app.Orm.Create(&settings).Error; err != nil { return fmt.Errorf("初始化失败: %v", err) }