-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(otelzap): withoptions(zap.fields(...)) will keep fields with logger
- Loading branch information
Showing
3 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package otelzap | ||
|
||
import ( | ||
"go.uber.org/zap" | ||
"go.uber.org/zap/zapcore" | ||
) | ||
|
||
// fieldExtractorCore copy zapcore.Fields from With method to extraFields list | ||
type fieldExtractorCore struct { | ||
extraFields *[]zap.Field | ||
} | ||
|
||
var _ zapcore.Core = (*fieldExtractorCore)(nil) | ||
|
||
// With adds structured context to the Core. | ||
func (fe *fieldExtractorCore) With(fs []zapcore.Field) zapcore.Core { | ||
*fe.extraFields = append(*fe.extraFields, fs...) | ||
return nil | ||
} | ||
|
||
// Check stub | ||
func (*fieldExtractorCore) Check(zapcore.Entry, *zapcore.CheckedEntry) *zapcore.CheckedEntry { | ||
return nil | ||
} | ||
|
||
// Write stub | ||
func (*fieldExtractorCore) Write(zapcore.Entry, []zapcore.Field) error { | ||
return nil | ||
} | ||
|
||
// Sync stub | ||
func (*fieldExtractorCore) Sync() error { | ||
return nil | ||
} | ||
|
||
// Enabled stub | ||
func (*fieldExtractorCore) Enabled(zapcore.Level) bool { | ||
return false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters