Skip to content

Move logging setup out of __init__.py - #166

Open
nsheff wants to merge 1 commit into
devfrom
no-import-time-logging
Open

Move logging setup out of __init__.py#166
nsheff wants to merge 1 commit into
devfrom
no-import-time-logging

Conversation

@nsheff

@nsheff nsheff commented Aug 7, 2026

Copy link
Copy Markdown
Member

Importing bedboss used to configure logging as a side effect, and not just for itself. __init__.py ran six coloredlogs.install() calls that attached handlers to pipestat, geniml, bbconf, pephubclient, and refgenconf, and set propagate = False on each. bbuploader/__init__.py did the same for itself. All of that happened on import, whether or not anything wanted it.

The reason those calls existed was to label each line with the package it came from, using hardcoded tags like [PIPESTAT] and [BBCONF]. logmuse 0.3.1 puts the logger name in the default format, so that label now comes for free and reports the real logger rather than a fixed string.

So the setup moved into the Typer callback, which runs before any command, and configures the root logger once. Everything logs through one handler and identifies itself:

[INFO] [15:12:20] [bedboss.bedmaker.utils] fasta path: /genomes/hg38/hg38.fa
[INFO] [15:12:20] [bbuploader] GSE12345 queued for upload
[INFO] [15:12:20] [pipestat] reported 12 results
[INFO] [15:12:20] [bbconf] Could not get assembly object for hg38
[INFO] [15:12:20] [refgenconf] refgenie config loaded

Root is used rather than the bedboss logger because bbuploader logs under the name bbuploader, not bedboss.bbuploader, so it is a separate tree and would not otherwise be covered.

This also fixes a bug in the old code. The refgenconf block installed its handler on _LOGGER_PHC instead of _LOGGER_REF_CONF, so refgenconf never got one and pephubclient got two. Any refgenconf line was being labelled [PEPHUBCLIENT].

Also adds --verbosity, --logdev, and --silent, and requires logmuse 0.3.1.

@nsheff
nsheff requested a review from khoroshevskyi August 7, 2026 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant