Skip to content

Commit

Permalink
Add a debug logging flag to the service.
Browse files Browse the repository at this point in the history
This makes it possible to change logging levels from the configuration.

This commit also replaces the double `logging.basicConfig` calls of the
original code; `basicConfig` only has an effect the first time
it's called.
  • Loading branch information
kfindeisen committed Oct 16, 2024
1 parent 0a806c2 commit 8417655
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,8 +494,10 @@ async def main() -> None:
security_protocol = os.environ["SECURITY_PROTOCOL"]

# Logging config
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
logging.basicConfig(stream=sys.stderr, level=logging.WARNING)
if os.environ.get("DEBUG_LOGS") == "true":
logging.basicConfig(sys.stdout, level=logging.DEBUG)
else:
logging.basicConfig(stream=sys.stdout, level=logging.INFO)

conf = yaml.safe_load(Path(instrument_config_file).read_text())
instruments = {inst: InstrumentConfig(conf, inst) for inst in supported_instruments}
Expand Down

0 comments on commit 8417655

Please sign in to comment.