Compare commits

..

No commits in common. "main" and "v1.5.3" have entirely different histories.
main ... v1.5.3

3 changed files with 4 additions and 14 deletions

View File

@ -1,17 +1,5 @@
# Changelog # Changelog
## [1.5.5] - 2026-06-05
- **规范化: Warning 日志行为对齐**:
- ** Convention 对齐**: 移除了 `Warning` 级别日志自动附带堆栈信息(`CallStacks`)的逻辑。
- **性能优化**: 减少了在产生非故障告警时的堆栈获取开销。
- **设计初衷**: 遵循主流日志规范,仅在 `Error` 级别及以上保留自动堆栈,使告警信息更整洁。
## [1.5.4] - 2026-06-05
- **架构重构: 灵活的日志降噪过滤器**:
- **解耦**: 移除了包内针对特定第三方库(如 SugarDB的硬编码过滤逻辑。
- **新 API**: 引入了 `log.AddStdLogFilter(func(string) bool)` 机制。现在业务包可以在启动时注册自定义的过滤规则,实现精准、按需的控制台噪音治理。
- **缺陷修复**: 补充了 `logger.go` 中缺失的 `sync` 包导入。
## [1.5.3] - 2026-06-04 ## [1.5.3] - 2026-06-04
- **功能增强: 标准库日志全量审计**: - **功能增强: 标准库日志全量审计**:
- **实现**: 引入了 `log.RedirectStdLog()` 机制,并在 `DefaultLogger` 初始化时自动启用。该功能会劫持 Go 标准库 `log` 包的所有输出并转发到我们的结构化 Logger。 - **实现**: 引入了 `log.RedirectStdLog()` 机制,并在 `DefaultLogger` 初始化时自动启用。该功能会劫持 Go 标准库 `log` 包的所有输出并转发到我们的结构化 Logger。

View File

@ -6,7 +6,6 @@ import (
"log" "log"
"os" "os"
"strings" "strings"
"sync"
"time" "time"
"apigo.cc/go/cast" "apigo.cc/go/cast"
@ -231,6 +230,7 @@ func (logger *Logger) FillInfo(entry *InfoLog, message string) {
func (logger *Logger) FillWarning(entry *WarningLog, message string) { func (logger *Logger) FillWarning(entry *WarningLog, message string) {
logger.FillBase(&entry.BaseLog, LogTypeWarning) logger.FillBase(&entry.BaseLog, LogTypeWarning)
entry.Warning = message entry.Warning = message
entry.CallStacks = getCallStacks(logger.truncations)
} }
func (logger *Logger) FillError(entry *ErrorLog, message string) { func (logger *Logger) FillError(entry *ErrorLog, message string) {

View File

@ -81,11 +81,13 @@ func (l *InfoLog) Reset() {
type WarningLog struct { type WarningLog struct {
BaseLog BaseLog
Warning string `log:"pos:6,color:yellow,withoutkey:true"` Warning string `log:"pos:6,color:yellow,withoutkey:true"`
CallStacks []string `log:"pos:1001"`
} }
func (l *WarningLog) Reset() { func (l *WarningLog) Reset() {
l.BaseLog.Reset() l.BaseLog.Reset()
l.Warning = "" l.Warning = ""
l.CallStacks = l.CallStacks[:0]
} }
type ErrorLog struct { type ErrorLog struct {