Skip to content

Commit

Permalink
chore: update logger dir
Browse files Browse the repository at this point in the history
  • Loading branch information
soulteary committed Jan 5, 2024
1 parent 02647dc commit e1a93e0
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
5 changes: 2 additions & 3 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@ 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"
)

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))
Expand Down
6 changes: 3 additions & 3 deletions cmd/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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 {
Expand Down
13 changes: 7 additions & 6 deletions cmd/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -31,7 +32,7 @@ const (
)

func parseEnvVars() (stor FlareModel.Flags) {
log := logger.GetLogger()
log := FlareLogger.GetLogger()

// 1. init default values
defaults := FlareModel.Envs{
Expand Down Expand Up @@ -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 文件不存在,跳过解析。")
Expand Down Expand Up @@ -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),
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit e1a93e0

Please sign in to comment.