From 8dde69e1511abe95789ea116ec41f94181b5c49a Mon Sep 17 00:00:00 2001 From: Eric Brown Date: Fri, 24 Jun 2022 15:55:40 -0700 Subject: [PATCH] Avoid redundant message if debug on Only print the message to use "--debug" if debug logging not already turned on. Closes #883 Signed-off-by: Eric Brown --- bandit/core/manager.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bandit/core/manager.py b/bandit/core/manager.py index 4e07517f2..fe20a2dc6 100644 --- a/bandit/core/manager.py +++ b/bandit/core/manager.py @@ -331,12 +331,13 @@ def _parse_file(self, fname, fdata, new_files_list): new_files_list.remove(fname) except Exception as e: LOG.error( - "Exception occurred when executing tests against " - '%s. Run "bandit --debug %s" to see the full ' - "traceback.", + "Exception occurred when executing tests against %s.", fname, fname, ) + if not LOG.isEnabledFor(logging.DEBUG): + LOG.error('Run "bandit --debug %s" to see the full traceback.') + self.skipped.append((fname, "exception while scanning file")) new_files_list.remove(fname) LOG.debug(" Exception string: %s", e)