Skip to content

Commit

Permalink
完善日志问题
Browse files Browse the repository at this point in the history
  • Loading branch information
azhai committed Jun 16, 2023
1 parent 4ce35e7 commit 24ba3a4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
4 changes: 2 additions & 2 deletions tests/log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
)

var (
cfg = logging.SingleFileConfig("info", "access.log")
logger = logging.NewLogger(cfg, "./logs")
cfg = logging.SingleFileConfig("info", "./logs/access.log")
logger = logging.NewLogger(cfg, "")
)

func NowTime() string {
Expand Down
4 changes: 2 additions & 2 deletions utils/logging/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,10 @@ func GetAbsPath(dir, file string, onlyFile bool) string {
if dir == "" && strings.HasPrefix(file, "std") {
return file
}
if strings.Contains(file, "%s") {
if strings.Contains(dir, "%s") {
file = fmt.Sprintf(dir, file)
} else {
file = fmt.Sprintf("%s/%s", dir, strings.TrimPrefix(file, "/"))
file = filepath.Join(dir, file)
}
u, err := url.Parse(file)
isFile := u.Scheme == "" || u.Scheme == "file"
Expand Down
6 changes: 2 additions & 4 deletions xquery/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package xquery

import (
"fmt"
"path/filepath"

"github.com/azhai/xgen/utils/logging"
"go.uber.org/zap"
Expand All @@ -19,9 +18,8 @@ type XormLogger struct {
// NewXormLogger 创建日志
func NewXormLogger(filename string) *XormLogger {
xl := &XormLogger{level: log.LOG_INFO, showSQL: true}
dirname, basename := filepath.Dir(filename), filepath.Base(filename)
cfg := logging.SingleFileConfig("info", basename)
xl.SugaredLogger = logging.NewLogger(cfg, dirname)
cfg := logging.SingleFileConfig("info", filename)
xl.SugaredLogger = logging.NewLogger(cfg, "")
return xl
}

Expand Down

0 comments on commit 24ba3a4

Please sign in to comment.