From 9bd5226e76dff4bdf31bef8baced3fee1ee8e147 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Wed, 17 Nov 2021 14:45:24 -0500 Subject: [PATCH] Only adjust logging in debug mode if not noisy enough already --- tractor/_root.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tractor/_root.py b/tractor/_root.py index 7731488..506c682 100644 --- a/tractor/_root.py +++ b/tractor/_root.py @@ -4,6 +4,7 @@ Root actor runtime ignition(s). from contextlib import asynccontextmanager from functools import partial import importlib +import logging import os from typing import Tuple, Optional, List, Any import typing @@ -87,8 +88,17 @@ async def open_root_actor( # for use of ``await tractor.breakpoint()`` enable_modules.append('tractor._debug') + # if debug mode get's enabled *at least* use that level of + # logging for some informative console prompts. if loglevel is None: - loglevel = 'pdb' + if ( + logging.getLevelName( + # lul, need the upper case for the -> int map? + # sweet "dynamic function behaviour" stdlib... + log.get_loglevel().upper() + ) > logging.getLevelName('PDB') + ): + loglevel = 'PDB' elif debug_mode: raise RuntimeError(