refactor: 后端日志系统重构
- 新增模块化日志器(pkg/logger/module.go) - 新增 GORM 日志适配器 - 统一日志入口,移除所有 zap.L() 全局 logger 调用 - 字段标准化 - 启动阶段使用结构化日志 - 更新所有相关测试
This commit is contained in:
25
backend/pkg/logger/module_test.go
Normal file
25
backend/pkg/logger/module_test.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package logger
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func TestWithModule(t *testing.T) {
|
||||
baseLogger := zap.NewNop()
|
||||
moduleLogger := WithModule(baseLogger, "handler.proxy")
|
||||
|
||||
assert.NotNil(t, moduleLogger)
|
||||
}
|
||||
|
||||
func TestWithModuleMultiple(t *testing.T) {
|
||||
baseLogger := zap.NewNop()
|
||||
|
||||
logger1 := WithModule(baseLogger, "handler.proxy")
|
||||
logger2 := WithModule(baseLogger, "provider.client")
|
||||
|
||||
assert.NotNil(t, logger1)
|
||||
assert.NotNil(t, logger2)
|
||||
}
|
||||
Reference in New Issue
Block a user