Skip to content

Commit

Permalink
fix: filter tyber log in test
Browse files Browse the repository at this point in the history
Signed-off-by: gfanton <8671905+gfanton@users.noreply.github.com>
  • Loading branch information
gfanton committed Mar 18, 2022
1 parent f53541e commit bdbc41c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion go/internal/testutil/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"berty.tech/berty/v2/go/internal/logutil"
)

const defaultLoggingFilters = "info+:bty.test* error+:*,-ipfs*"
const defaultLoggingFilters = "info+:bty.test* error+:*,-ipfs*,-*.tyber"

var (
logFilters = flag.String("log-filters", defaultLoggingFilters, "log namespaces")
Expand Down
10 changes: 6 additions & 4 deletions go/pkg/tyber/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ import (
"go.uber.org/zap"
)

const tyberLogNS = "tyber"

func LogError(ctx context.Context, logger *zap.Logger, text string, err error, mutators ...StepMutator) error {
if logger == nil {
return err
}

logger.Error(
logger.Named(tyberLogNS).Error(
text,
FormatStepLogFields(ctx, []Detail{{Name: "Error", Description: err.Error()}}, mutators...)...,
)
Expand All @@ -25,13 +27,13 @@ func LogFatalError(ctx context.Context, logger *zap.Logger, text string, err err
}

func LogTraceEnd(ctx context.Context, logger *zap.Logger, text string, mutators ...StepMutator) {
logger.Debug(text, FormatStepLogFields(ctx, []Detail{}, append(mutators, EndTrace)...)...)
logger.Named(tyberLogNS).Debug(text, FormatStepLogFields(ctx, []Detail{}, append(mutators, EndTrace)...)...)
}

func LogTraceStart(ctx context.Context, logger *zap.Logger, text string) {
logger.Debug(text, FormatTraceLogFields(ctx)...)
logger.Named(tyberLogNS).Debug(text, FormatTraceLogFields(ctx)...)
}

func LogStep(ctx context.Context, logger *zap.Logger, text string, mutators ...StepMutator) {
logger.Debug(text, FormatStepLogFields(ctx, []Detail{}, mutators...)...)
logger.Named(tyberLogNS).Debug(text, FormatStepLogFields(ctx, []Detail{}, mutators...)...)
}

0 comments on commit bdbc41c

Please sign in to comment.