Skip to content

Commit

Permalink
fix global field append to other log components
Browse files Browse the repository at this point in the history
  • Loading branch information
JiChenSSG committed Sep 29, 2024
1 parent 5b8126c commit f90d964
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
10 changes: 5 additions & 5 deletions core/logx/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,23 +529,23 @@ func shallLogStat() bool {
// If we check shallLog here, the fmt.Sprint might be called even if the log level is not enabled.
// The caller should check shallLog before calling this function.
func writeDebug(val any, fields ...LogField) {
getWriter().Debug(val, addCaller(fields...)...)
getWriter().Debug(val, combineGlobalFields(addCaller(fields...))...)
}

// writeError writes v into the error log.
// Not checking shallLog here is for performance consideration.
// If we check shallLog here, the fmt.Sprint might be called even if the log level is not enabled.
// The caller should check shallLog before calling this function.
func writeError(val any, fields ...LogField) {
getWriter().Error(val, addCaller(fields...)...)
getWriter().Error(val, combineGlobalFields(addCaller(fields...))...)
}

// writeInfo writes v into info log.
// Not checking shallLog here is for performance consideration.
// If we check shallLog here, the fmt.Sprint might be called even if the log level is not enabled.
// The caller should check shallLog before calling this function.
func writeInfo(val any, fields ...LogField) {
getWriter().Info(val, addCaller(fields...)...)
getWriter().Info(val, combineGlobalFields(addCaller(fields...))...)
}

// writeSevere writes v into severe log.
Expand All @@ -561,7 +561,7 @@ func writeSevere(msg string) {
// If we check shallLog here, the fmt.Sprint might be called even if the log level is not enabled.
// The caller should check shallLog before calling this function.
func writeSlow(val any, fields ...LogField) {
getWriter().Slow(val, addCaller(fields...)...)
getWriter().Slow(val, combineGlobalFields(addCaller(fields...))...)
}

// writeStack writes v into stack log.
Expand All @@ -577,5 +577,5 @@ func writeStack(msg string) {
// If we check shallLog here, the fmt.Sprint might be called even if the log level is not enabled.
// The caller should check shallLog before calling this function.
func writeStat(msg string) {
getWriter().Stat(msg, addCaller()...)
getWriter().Stat(msg, combineGlobalFields(addCaller())...)
}
1 change: 0 additions & 1 deletion core/logx/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,6 @@ func output(writer io.Writer, level string, val any, fields ...LogField) {
}
}

fields = combineGlobalFields(fields)
// +3 for timestamp, level and content
entry := make(logEntry, len(fields)+3)
for _, field := range fields {
Expand Down

0 comments on commit f90d964

Please sign in to comment.