Skip to content
This repository has been archived by the owner on Jan 23, 2024. It is now read-only.

Commit

Permalink
feat: use different logger in debug mode
Browse files Browse the repository at this point in the history
  • Loading branch information
AH-dark committed Jan 6, 2024
1 parent 835ec4d commit 764394d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion common/logging/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package logging

import (
"context"
"github.com/samber/lo"

"github.com/spf13/viper"
"github.com/uptrace/opentelemetry-go-extra/otelzap"
Expand All @@ -23,7 +24,7 @@ func NewLogger(ctx context.Context, viper *viper.Viper, options []zap.Option) (L
ctx, span := tracer.Start(ctx, "logging.NewLogger")
defer span.End()

zapLogger, err := zap.NewDevelopment(options...)
zapLogger, err := lo.If(viper.GetBool("debug"), zap.NewDevelopment).Else(zap.NewProduction)(options...)
if err != nil {
span.RecordError(err)
otelzap.L().Ctx(ctx).Error("failed to create logger", zap.Error(err))
Expand Down

0 comments on commit 764394d

Please sign in to comment.