Skip to content

Commit

Permalink
added caller to record attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
suniastar committed Oct 21, 2024
1 parent 1c56a7c commit 70a4c4f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions bridges/otelzap/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,13 @@ func (o *Core) Write(ent zapcore.Entry, fields []zapcore.Field) error {
r.SetSeverityText(ent.Level.String())

r.AddAttributes(o.attr...)
if ent.Caller.Defined {
r.AddAttributes(
log.String("file", ent.Caller.File),
log.Int("line", ent.Caller.Line),
log.String("function", ent.Caller.Function),
)
}
if len(fields) > 0 {
ctx, attrbuf := convertField(fields)
if ctx != nil {
Expand Down

0 comments on commit 70a4c4f

Please sign in to comment.