diff --git a/python/xoscar/backends/indigen/pool.py b/python/xoscar/backends/indigen/pool.py index 9f151a0e..dd9a08ef 100644 --- a/python/xoscar/backends/indigen/pool.py +++ b/python/xoscar/backends/indigen/pool.py @@ -241,6 +241,8 @@ def _start_sub_pool( logging_conf = conf["logging_conf"] or {} if isinstance(logging_conf, configparser.RawConfigParser): logging.config.fileConfig(logging_conf) + elif logging_conf.get("dict"): + logging.config.dictConfig(logging_conf["dict"]) elif logging_conf.get("file"): logging.config.fileConfig(logging_conf["file"]) elif logging_conf.get("level"): diff --git a/python/xoscar/backends/indigen/tests/test_pool.py b/python/xoscar/backends/indigen/tests/test_pool.py index 1d82e41e..a79a5d3d 100644 --- a/python/xoscar/backends/indigen/tests/test_pool.py +++ b/python/xoscar/backends/indigen/tests/test_pool.py @@ -844,6 +844,36 @@ def get_pid(self): assert len({await ref.get_pid() for ref in refs}) == 2 +# equivalent to test-logging.conf +DICT_CONFIG = { + "version": 1, + "disable_existing_loggers": False, + "formatters": { + "formatter": { + "format": "%(asctime)s %(name)-12s %(process)d %(levelname)-8s %(message)s", + }, + }, + "handlers": { + "stream_handler": { + "class": "logging.StreamHandler", + "formatter": "formatter", + "stream": "ext://sys.stderr", + }, + }, + "loggers": { + "": { + "level": "WARN", + "handlers": ["stream_handler"], + }, + "xoscar.backends.indigen.tests": { + "level": "DEBUG", + "handlers": ["stream_handler"], + "propagate": False, + }, + }, +} + + @pytest.mark.asyncio @pytest.mark.parametrize( "logging_conf", @@ -855,6 +885,7 @@ def get_pid(self): }, {"level": logging.DEBUG}, {"level": logging.DEBUG, "format": "%(asctime)s %(message)s"}, + {"dict": DICT_CONFIG}, ], ) async def test_logging_config(logging_conf):