logmuse
A small Python package that makes it easy to add CLI-controllable logging to your command-line tools. It provides a simple interface for standard logging arguments (--verbosity, --silent, --logdev) that can be passed directly to a logger.
Installation
pip install logmuse
Quick start
Add logging options to your CLI and create a logger in three lines:
import argparse
import logmuse
parser = argparse.ArgumentParser()
# your arguments here...
parser = logmuse.add_logging_options(parser)
args = parser.parse_args()
logger = logmuse.logger_via_cli(args)
logger.info("Hello, world!")
This adds --silent, --verbosity, and --logdev options to your CLI automatically.
Setup for a CLI package
1. Add CLI args to your argparser
parser = logmuse.add_logging_options(parser)
This gives you --verbosity, --silent, and --logdev options.
2. Activate in your main function
import logmuse
def main():
# ... parse args ...
logger = logmuse.logger_via_cli(args, make_root=True)
That's it. Call logger_via_cli once in your CLI entry point, and all loggers in your package (and its dependencies) will respect the CLI options.
For imported packages
Imported packages don't need logmuse at all. Just use the standard logging module:
import logging
_LOGGER = logging.getLogger(__name__)
The CLI arguments passed to logmuse will control these loggers too.
Avoid calling init_logger at import time
Do not put logmuse.init_logger() in your package's __init__.py. This replaces the logger's handlers at import time, which prevents it from inheriting configuration from a root logger. This causes problems when your package is used as a library (not via its own CLI).
Using logmuse interactively
To set logging to DEBUG in an interactive session:
logmuse.init_logger("my_package", "DEBUG", devmode=True)
Usage reference
CLI options
add_logging_options(parser) adds three arguments to an argparse.ArgumentParser:
| Option | Effect |
|---|---|
--silent |
Silence all logging output |
--verbosity V |
Set logging level (1=CRITICAL, 2=ERROR, 3=WARN, 4=INFO, 5=DEBUG, or a level name) |
--logdev |
Use a detailed developer log format with timestamps, module, and line numbers |
init_logger parameters
| Parameter | Default | Description |
|---|---|---|
name |
"logmuse" |
Logger name |
level |
None |
Logging level (int or string) |
verbosity |
None |
Verbosity level (1-5); alternative to level |
silent |
False |
Silence all output |
devmode |
False |
Use detailed developer format |
stream |
stderr |
Output stream ("OUT" for stdout, "ERR" for stderr) |
logfile |
None |
Path to log file (mutes stream output) |
make_root |
None |
Use as root logger |
propagate |
False |
Allow messages to reach parent loggers |
fmt |
None |
Custom format string |
datefmt |
"%H:%M:%S" |
Time format |
plain_format |
False |
Force plain format even in devmode |
style |
None |
Format style (%, {, or $) |
use_full_names |
False |
Don't truncate level names |
Verbosity levels
| Verbosity | Logging Level |
|---|---|
| 1 | CRITICAL |
| 2 | ERROR |
| 3 | WARN |
| 4 | INFO |
| 5 | DEBUG |
Metadata
Release files for logmuse 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| logmuse-0.3.1.tar.gz | 13.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| logmuse-0.3.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.5 kB
Release files / logmuse-0.3.1.tar.gz
| Download URL | logmuse-0.3.1.tar.gz |
|---|---|
| Size | 13.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e7035e216bbae03098506e863ab733c42ca3e6a9713444a1d159971da54ae04f
|
|
BLAKE2b-256 checksum How to use checksums |
26e741e287bf07fcfa66700bbf89afe040add3d0aec6487322b96328bc07bc9f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 7, 2026.
Transparency logRelease files / logmuse-0.3.1-py3-none-any.whl
| Download URL | logmuse-0.3.1-py3-none-any.whl |
|---|---|
| Size | 8.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
264e043e6ee6d4613d9cffa747fef394bc9c88e58fca9f797b47dc3200e12509
|
|
BLAKE2b-256 checksum How to use checksums |
ee1f5a1ddf004940b22b55c73df2aef76745be1e792d68c0ad31928e7ef782e5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 7, 2026.
Transparency log