Skip to content

Commit

Permalink
logger: remove log scope debug message
Browse files Browse the repository at this point in the history
  • Loading branch information
bobheadxi committed Sep 18, 2023
1 parent 40c57b6 commit 67bc23a
Showing 1 changed file with 1 addition and 20 deletions.
21 changes: 1 addition & 20 deletions logger.go
Expand Up @@ -2,7 +2,6 @@ package log

import (
"fmt"
"sync"

"go.uber.org/zap"
"go.uber.org/zap/zapcore"
Expand Down Expand Up @@ -138,39 +137,21 @@ type zapAdapter struct {

var _ Logger = &zapAdapter{}

// createdScopes tracks the scopes that have been created so far.
var createdScopes sync.Map

func (z *zapAdapter) Scoped(scope string, description string) Logger {
var newFullScope string
if z.fullScope == "" {
newFullScope = scope
} else {
newFullScope = createScope(z.fullScope, scope)
}
scopedLogger := &zapAdapter{
return &zapAdapter{
// name -> scope in OT
Logger: z.Logger.Named(scope),
rootLogger: z.rootLogger.Named(scope),

fullScope: newFullScope,
attributes: z.attributes,
}
if len(description) > 0 {
if _, alreadyLogged := createdScopes.LoadOrStore(newFullScope, struct{}{}); !alreadyLogged {
callerSkip := 1 // Logger.Scoped() -> Logger.Debug()
if z.fromPackageScoped {
callerSkip += 1 // log.Scoped() -> Logger.Scoped() -> Logger.Debug()
}
scopedLogger.
AddCallerSkip(callerSkip).
Debug("logger.scoped",
zap.Namespace("scope"),
zap.String("name", scope),
zap.String("desc", description))
}
}
return scopedLogger
}

func (z *zapAdapter) With(fields ...Field) Logger {
Expand Down

0 comments on commit 67bc23a

Please sign in to comment.