Skip to content

Commit

Permalink
removed copying from logger creation
Browse files Browse the repository at this point in the history
Signed-off-by: Mikhail Avramenko <avramenkomihail15@gmail.com>
  • Loading branch information
Mixaster995 committed Nov 1, 2021
1 parent 9ddfbf2 commit eaceefe
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions pkg/tools/log/logruslogger/logruslogger.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,7 @@ func (s *logrusLogger) WithField(key, value interface{}) log.Logger {

// New - creates a logruslogger and returns it
func New(ctx context.Context) log.Logger {
copyFields := map[string]interface{}{}
for k, v := range log.Fields(ctx) {
copyFields[k] = v
}
entry := logrus.WithFields(copyFields)
entry := logrus.WithFields(log.Fields(ctx))
entry.Logger.SetFormatter(newFormatter())

newLog := &logrusLogger{
Expand All @@ -201,11 +197,7 @@ func New(ctx context.Context) log.Logger {
// FromSpan - creates a new logruslogger from context, operation and span
// and returns context with it, logger, and a function to defer
func FromSpan(ctx context.Context, span opentracing.Span, operation string) (context.Context, log.Logger, func()) {
copyFields := map[string]interface{}{}
for k, v := range log.Fields(ctx) {
copyFields[k] = v
}
entry := logrus.WithFields(copyFields)
entry := logrus.WithFields(log.Fields(ctx))
entry.Logger.SetFormatter(newFormatter())
entry.Logger.SetLevel(logrus.TraceLevel)

Expand Down

0 comments on commit eaceefe

Please sign in to comment.