{"id":7383,"library":"logmuse","title":"Logmuse: Logging Setup","description":"Logmuse is a lightweight Python library designed to simplify the setup of basic logging for applications. It provides utilities to configure named loggers, set log levels, and integrate logging options with `argparse`. The current version is 0.3.0, and it maintains a relatively stable release cadence with minor updates.","status":"active","version":"0.3.0","language":"en","source_language":"en","source_url":"https://github.com/databio/logmuse","tags":["logging","utility","configuration"],"install":[{"cmd":"pip install logmuse","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"symbol":"setup_logging","correct":"from logmuse import setup_logging"},{"symbol":"add_logging_options","correct":"from logmuse import add_logging_options"}],"quickstart":{"code":"import logging\nfrom logmuse import setup_logging\n\n# Get a logger instance for your application\n_LOGGER = logging.getLogger(\"my_app\")\n\ndef main():\n    # Setup logging to console at INFO level for 'my_app'\n    # Set 'level=\"DEBUG\"' to see more detailed messages\n    setup_logging(name=\"my_app\", level=\"INFO\")\n    \n    _LOGGER.info(\"Application started successfully!\")\n    _LOGGER.debug(\"This debug message will not be shown by default with INFO level.\")\n    _LOGGER.warning(\"This is a warning message.\")\n    _LOGGER.error(\"An error occurred, but the app continues.\")\n\nif __name__ == \"__main__\":\n    main()","lang":"python","description":"This quickstart demonstrates how to initialize a named logger using `setup_logging` and emit various log messages. Remember to call `setup_logging` before your logger instance (`_LOGGER`) starts emitting messages to ensure handlers are configured."},"warnings":[{"fix":"Ensure `setup_logging` is called only once per logger name during application initialization. If you need to change logging levels dynamically, use `logging.getLogger(name).setLevel()` directly.","message":"Calling `setup_logging` multiple times for the same logger name (or without a name, affecting the root logger) can overwrite previous configurations or add duplicate handlers.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always explicitly specify the desired logging level, e.g., `setup_logging(name='my_app', level='DEBUG')` to ensure all messages are captured.","message":"The default logging level set by `logmuse.setup_logging` might not be `DEBUG`. If you're not seeing expected log messages, the level might be set too high.","severity":"gotcha","affected_versions":"All versions"},{"fix":"It's best practice to use a single, consistent approach for logging configuration. Ensure `logmuse.setup_logging` is your primary method, and avoid calling `logging.basicConfig()` if `logmuse` is handling your setup.","message":"Interaction with `logging.basicConfig()`: If `logging.basicConfig()` has been called elsewhere in your application (e.g., by another library or implicitly), `logmuse.setup_logging` might not behave as expected or could lead to duplicate log messages.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Use `from logmuse import setup_logging` and call `setup_logging(...)` instead.","cause":"You are trying to use a non-existent function. The primary function for setting up logging in `logmuse` is `setup_logging`.","error":"AttributeError: module 'logmuse' has no attribute 'configure_logging'"},{"fix":"Ensure `logmuse.setup_logging(name=\"your_application_name\", ...)` is called *before* any messages are emitted by `logging.getLogger(\"your_application_name\")`.","cause":"This generic Python logging error indicates that a logger tried to emit messages but had no handlers configured. This typically happens if `logmuse.setup_logging` was not called, or was called for a different logger name than the one emitting messages.","error":"No handlers could be found for logger \"your_application_name\""},{"fix":"Run `pip install logmuse` in your terminal to install the package.","cause":"The `logmuse` package is not installed in your current Python environment.","error":"ModuleNotFoundError: No module named 'logmuse'"}]}