From 26ab04962222b3dcaa78d04b16fbb1740dbfd5f8 Mon Sep 17 00:00:00 2001 From: David Wertenteil Date: Fri, 24 Feb 2023 09:19:43 +0200 Subject: [PATCH] Do not print table when logger level is warn Signed-off-by: David Wertenteil --- core/core/initutils.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/core/core/initutils.go b/core/core/initutils.go index 083c396a..ea26142d 100644 --- a/core/core/initutils.go +++ b/core/core/initutils.go @@ -273,10 +273,15 @@ func getAttackTracksGetter(ctx context.Context, attackTracks, accountID string, // getUIPrinter returns a printer that will be used to print to the program’s UI (terminal) func getUIPrinter(ctx context.Context, verboseMode bool, formatVersion string, attackTree bool, viewType cautils.ViewTypes) printer.IPrinter { - p := printerv2.NewPrettyPrinter(verboseMode, formatVersion, attackTree, viewType) + var p printer.IPrinter + if helpers.ToLevel(logger.L().GetLevel()) >= helpers.WarningLevel { + p = &printerv2.SilentPrinter{} + } else { + p = printerv2.NewPrettyPrinter(verboseMode, formatVersion, attackTree, viewType) - // Since the UI of the program is a CLI (Stdout), it means that it should always print to Stdout - p.SetWriter(ctx, os.Stdout.Name()) + // Since the UI of the program is a CLI (Stdout), it means that it should always print to Stdout + p.SetWriter(ctx, os.Stdout.Name()) + } return p }