From e1a93e09ad6b791d4a01044ad336b7a17ac56556 Mon Sep 17 00:00:00 2001 From: Su Yang Date: Fri, 5 Jan 2024 20:28:54 +0800 Subject: [PATCH] chore: update logger dir --- cmd/cmd.go | 5 ++--- cmd/daemon.go | 6 +++--- cmd/flags.go | 13 +++++++------ {pkg => internal}/logger/gin-handler.go | 0 {pkg => internal}/logger/handler.go | 0 {pkg => internal}/logger/logger.go | 0 6 files changed, 12 insertions(+), 12 deletions(-) rename {pkg => internal}/logger/gin-handler.go (100%) rename {pkg => internal}/logger/handler.go (100%) rename {pkg => internal}/logger/logger.go (100%) diff --git a/cmd/cmd.go b/cmd/cmd.go index d55f528..10ce42a 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -3,9 +3,8 @@ package cmd import ( "log/slog" - "github.com/soulteary/flare/pkg/logger" - FlareData "github.com/soulteary/flare/internal/data" + FlareLogger "github.com/soulteary/flare/internal/logger" FlareState "github.com/soulteary/flare/internal/state" ) @@ -13,7 +12,7 @@ func Parse() { envs := parseEnvFile(parseEnvVars()) flags := parseCLI(envs) - log := logger.GetLogger() + log := FlareLogger.GetLogger() log.Info("程序服务端口", slog.Int(_KEY_PORT, flags.Port)) log.Info("页面请求合并", slog.Bool(_KEY_MINI_REQUEST, flags.EnableMinimumRequest)) log.Info("启用离线模式", slog.Bool(_KEY_ENABLE_OFFLINE, flags.EnableOfflineMode)) diff --git a/cmd/daemon.go b/cmd/daemon.go index ae8af78..59a0b59 100644 --- a/cmd/daemon.go +++ b/cmd/daemon.go @@ -12,8 +12,8 @@ import ( "github.com/gin-contrib/gzip" "github.com/gin-gonic/gin" - "github.com/soulteary/flare/pkg/logger" + FlareLogger "github.com/soulteary/flare/internal/logger" FlareModel "github.com/soulteary/flare/internal/model" FlareState "github.com/soulteary/flare/internal/state" @@ -45,9 +45,9 @@ func startDaemon(AppFlags *FlareModel.Flags) { ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) defer stop() - log := logger.GetLogger() + log := FlareLogger.GetLogger() router := gin.New() - router.Use(logger.New(log)) + router.Use(FlareLogger.New(log)) router.Use(gin.Recovery()) if !AppFlags.DisableLoginMode { diff --git a/cmd/flags.go b/cmd/flags.go index 7f3078c..c7d7ff5 100644 --- a/cmd/flags.go +++ b/cmd/flags.go @@ -9,12 +9,13 @@ import ( "strings" env "github.com/caarlos0/env/v6" - FlareData "github.com/soulteary/flare/internal/data" - FlareModel "github.com/soulteary/flare/internal/model" "github.com/soulteary/flare/internal/version" - "github.com/soulteary/flare/pkg/logger" flags "github.com/spf13/pflag" "gopkg.in/ini.v1" + + FlareData "github.com/soulteary/flare/internal/data" + FlareLogger "github.com/soulteary/flare/internal/logger" + FlareModel "github.com/soulteary/flare/internal/model" ) const ( @@ -31,7 +32,7 @@ const ( ) func parseEnvVars() (stor FlareModel.Flags) { - log := logger.GetLogger() + log := FlareLogger.GetLogger() // 1. init default values defaults := FlareModel.Envs{ @@ -100,7 +101,7 @@ func initAccountFromEnvVars( } func parseEnvFile(baseFlags FlareModel.Flags) FlareModel.Flags { - log := logger.GetLogger() + log := FlareLogger.GetLogger() if _, err := os.Stat(".env"); os.IsNotExist(err) { log.Debug("默认的 .env 文件不存在,跳过解析。") @@ -311,7 +312,7 @@ func excuteCLI(cliFlags *FlareModel.Flags, options *flags.FlagSet) (exit bool) { func getVersion(echo bool) string { programVersion := fmt.Sprintf("Flare v%s-%s %s/%s BuildDate=%s", version.Version, strings.ToUpper(version.Commit), runtime.GOOS, runtime.GOARCH, version.BuildDate) if echo { - log := logger.GetLogger() + log := FlareLogger.GetLogger() log.Info("Flare - 🏂 Challenge all bookmarking apps and websites directories, Aim to Be a best performance monster.") log.Info("程序信息:", slog.String("version", version.Version), diff --git a/pkg/logger/gin-handler.go b/internal/logger/gin-handler.go similarity index 100% rename from pkg/logger/gin-handler.go rename to internal/logger/gin-handler.go diff --git a/pkg/logger/handler.go b/internal/logger/handler.go similarity index 100% rename from pkg/logger/handler.go rename to internal/logger/handler.go diff --git a/pkg/logger/logger.go b/internal/logger/logger.go similarity index 100% rename from pkg/logger/logger.go rename to internal/logger/logger.go