Open maxjeblick opened 6 months ago
Yep, agree. Code2Flow should only call logging.basicConfig()
from its main
entrypoint, not from the code2flow
function, which is documented as programmatic use.
Oh, worse than that, it uses the root logger, so we can't even disable logging for code2flow only with something like this:
logging.getLogger("code2flow").setLevel(logging.CRITICAL + 1)
Code2Flow should get its own logger with logger = logging.getLogger("code2flow")
:slightly_smiling_face:
I was able to disable code2flow.engine
's logging with this:
from unittest.mock import MagicMock
from code2flow import engine
engine.logging = MagicMock()
I implemeted a similar fix using mock.patch.object
contextmanager
https://github.com/maxjeblick/llm-docstring-generator/blob/main/llm_docstring_generator/sorters/code2flow_patched.py#L25
When calling
code2flow
within python (i.e. not via cmd line), the default logging config is overwritten:logging.basicConfig(format="Code2Flow: %(message)s", level=level)
This is a bit annoying, as it requires to reconfigure logging after calling
code2flow
to removeCode2Flow
prefix.