mirror of
https://github.com/acepanel/panel.git
synced 2026-02-04 06:47:20 +08:00
feat: 日志记录器优化
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user