体验对齐与生态同步发布(by AI)

This commit is contained in:
AI Engineer 2026-05-05 17:34:04 +08:00
parent 700439e766
commit 05a028bbb3
4 changed files with 16 additions and 3 deletions

View File

@ -1,5 +1,11 @@
# Changelog
## [1.1.1] - 2026-05-05
- **体验对齐**:
- 修复 `viewer.go` 中空错误字符串导致日志类型被跳过显示的 Bug。
- `Log` 方法集成 `fillBase` 自动补全逻辑,对于直接调用 `Log(entry)` 的自定义日志类型,若未设置时间戳则自动填充元数据,无需手动干预。
- **生态同步**: 依赖 `config` 升级至 v1.0.5。
## [1.1.0] - 2026-05-05
- **性能质变**:
- `GetEntry` 改为泛型实现 `GetEntry[T]()`,消除 `reflect.Type` 传参及运行时类型断言。

2
go.mod
View File

@ -4,7 +4,7 @@ go 1.25.0
require (
apigo.cc/go/cast v1.2.6
apigo.cc/go/config v1.0.4
apigo.cc/go/config v1.0.5
apigo.cc/go/shell v1.0.4
)

View File

@ -161,6 +161,11 @@ func NewLogger(conf Config) *Logger {
}
func (logger *Logger) Log(entry LogEntry) {
// 如果是自动生成的 LogType如 Debug/Info/Warning/Error 对应的类型),这里通常已经在方法内 fillBase 了
// 但对于像 discover.Log 这样直接调用 Log(entry) 的,需要在这里补全
if entry.GetBaseLog().LogTime == 0 {
logger.fillBase(entry, "")
}
logger.asyncWrite(entry)
}
@ -201,7 +206,9 @@ func (logger *Logger) fillBase(entry LogEntry, logType string) {
}
base.LogName = logger.config.Name
if logType != "" {
base.LogType = logType
}
base.LogTime = time.Now().UnixNano()
base.TraceId = logger.traceId
base.ImageName = dockerImageName

View File

@ -39,7 +39,7 @@ func Viewable(line string) string {
level := ""
for _, k := range []string{"info", "warning", "error", "debug"} {
if b.Extra[k] != nil {
if v := b.Extra[k]; v != nil && cast.String(v) != "" {
level = k
break
}