Skip to content

Commit 78348c0

Browse files
committed
Properly set log level if —verbose flag is passed
There is no need to modify existing loggers since we are defining one logging config. Setting the env var, invalidating the cache, and calling setup_logging again are sufficient to set the log level properly at all levels.
1 parent c9d7e11 commit 78348c0

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

src/lightspeed_stack.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
main() function.
55
"""
66

7-
import logging
87
import os
98
from argparse import ArgumentParser
109

@@ -98,11 +97,8 @@ def main() -> None:
9897

9998
if args.verbose:
10099
os.environ[LIGHTSPEED_STACK_LOG_LEVEL_ENV_VAR] = "DEBUG"
101-
logging.getLogger().setLevel(logging.DEBUG)
102-
for logger_name in logging.Logger.manager.loggerDict:
103-
existing_logger = logging.getLogger(logger_name)
104-
if isinstance(existing_logger, logging.Logger):
105-
existing_logger.setLevel(logging.DEBUG)
100+
setup_logging.cache_clear()
101+
setup_logging()
106102

107103
configuration.load_configuration(args.config_file)
108104
logger.info("Configuration: %s", configuration.configuration)

0 commit comments

Comments
 (0)