Conversation
…le between debug and info. Unit test also added.
Barecheck - Code coverage reportTotal: 96.56%Your code coverage diff: 0.04% ▴ Uncovered files and lines
|
Co-authored-by: Julian Stirling <julian@julianstirling.co.uk>
| config_json = json.dumps( | ||
| {"things": {"my_thing": {"cls": "tests.test_logs.ThingWithDebugInit"}}} | ||
| ) | ||
|
|
There was a problem hiding this comment.
A bit belt and braces. But It wasn't clear to me whether caplog respects the loggers configuration. It does. This has been tested locally and passes (assuming I format the suggestion correctly)
| # Run without --debug and capture logs | |
| with caplog.at_level(logging.DEBUG, logger="labthings_fastapi.things"): | |
| serve_from_cli(["--json", config_json], dry_run=True) | |
| # There are no logs | |
| assert len(caplog.messages) == 0 | |
|
|
||
| @classmethod | ||
| def from_config(cls, config: ThingServerConfig) -> Self: | ||
| def from_config(cls, config: ThingServerConfig, debug: bool = False) -> Self: |
There was a problem hiding this comment.
Does it make sense to put debug into the config file? I can see arguments either way. I think we will want to retain the --debug flag either way.
There was a problem hiding this comment.
If the answer is "yes", I think it's absolutely fine for that to mean "yes in a future PR"...
There was a problem hiding this comment.
I think a command line flag is more normal for debug mode. I can see the OFM may want to do something else at some point as we have a service. But as there is an argument to "from_config" a downstream application can always add what they want there
Add --debug argument to CLI to make the THING LOGGER level configurable between debug and info. Unit test also added.
Closes #281
Tested on a microscope as part of https://gitlab.com/openflexure/openflexure-microscope-server/-/merge_requests/523