diff options
| author | Frederick Muriuki Muriithi | 2025-10-27 19:16:18 -0500 |
|---|---|---|
| committer | Frederick Muriuki Muriithi | 2025-10-27 19:16:18 -0500 |
| commit | 4345a81d92484ff5951d87feeec6bd749ab667fe (patch) | |
| tree | b97d4198e5c493f5d4df6bfc8d3f7ee2a9d664b8 | |
| parent | 51688d31004f8f7453d8190927b9c11503a453c0 (diff) | |
| download | genenetwork3-4345a81d92484ff5951d87feeec6bd749ab667fe.tar.gz | |
Improve logging for the asynchronous background tasks.
| -rw-r--r-- | gn3/commands.py | 5 | ||||
| -rw-r--r-- | sheepdog/worker.py | 5 |
2 files changed, 8 insertions, 2 deletions
diff --git a/gn3/commands.py b/gn3/commands.py index 697db42..3852c41 100644 --- a/gn3/commands.py +++ b/gn3/commands.py @@ -28,6 +28,8 @@ from gn3.debug import __pk__ from gn3.chancy import random_string from gn3.exceptions import RedisConnectionError +logger = logging.getLogger(__name__) + def compose_gemma_cmd(gemma_wrapper_cmd: str = "gemma-wrapper", gemma_wrapper_kwargs: Optional[Dict] = None, @@ -183,8 +185,7 @@ def run_cmd(cmd: str, success_codes: Tuple = (0,), env: Optional[str] = None) -> out = str(results.stdout, 'utf-8') if results.returncode not in success_codes: # Error! out = str(results.stderr, 'utf-8') - ( # We do not always run this within an app context - current_app.logger.debug if current_app else logging.debug)(out) + logger.debug("Command output: %s", out) return {"code": results.returncode, "output": out} diff --git a/sheepdog/worker.py b/sheepdog/worker.py index c4571e1..e8a7177 100644 --- a/sheepdog/worker.py +++ b/sheepdog/worker.py @@ -8,6 +8,8 @@ import argparse import redis import redis.connection +from gn3.loggers import setup_modules_logging + # Enable importing from one dir up: put as first to override any other globally # accessible GN3 sys.path.insert(0, os.path.abspath( @@ -90,6 +92,9 @@ if __name__ == "__main__": args = parse_cli_arguments() logger.setLevel(args.log_level.upper()) logger.debug("Worker Script: Initialising worker") + setup_modules_logging( + logging.getLevelName(logger.getEffectiveLevel()), + ("gn3.commands",)) with redis.Redis() as redis_conn: if not args.daemon: logger.info("Worker Script: Running worker in one-shot mode.") |
