Only adjust logging in debug mode if not noisy enough already

agpl
Tyler Goodlet 2021-11-17 14:45:24 -05:00
parent e899cc42bf
commit 9bd5226e76
1 changed files with 11 additions and 1 deletions

View File

@ -4,6 +4,7 @@ Root actor runtime ignition(s).
from contextlib import asynccontextmanager from contextlib import asynccontextmanager
from functools import partial from functools import partial
import importlib import importlib
import logging
import os import os
from typing import Tuple, Optional, List, Any from typing import Tuple, Optional, List, Any
import typing import typing
@ -87,8 +88,17 @@ async def open_root_actor(
# for use of ``await tractor.breakpoint()`` # for use of ``await tractor.breakpoint()``
enable_modules.append('tractor._debug') 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: 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: elif debug_mode:
raise RuntimeError( raise RuntimeError(