diff --git a/src/bfabric/cli_formatting.py b/src/bfabric/cli_formatting.py index f558b86a..ea3dfc8f 100644 --- a/src/bfabric/cli_formatting.py +++ b/src/bfabric/cli_formatting.py @@ -18,6 +18,9 @@ class HostnameHighlighter(RegexHighlighter): def setup_script_logging(debug: bool = False) -> None: """Sets up the logging for the command line scripts.""" + setup_flag_key = "BFABRICPY_SCRIPT_LOGGING_SETUP" + if os.environ.get(setup_flag_key, "0") == "1": + return logger.remove() if not (debug or os.environ.get("BFABRICPY_DEBUG")): logger.add(sys.stderr, filter="bfabric", level="INFO", format="{level} {message}") @@ -25,3 +28,4 @@ def setup_script_logging(debug: bool = False) -> None: else: logger.add(sys.stderr, filter="bfabric", level="DEBUG") logger.add(sys.stderr, filter="__main__", level="DEBUG") + os.environ[setup_flag_key] = "1"