{"id":8059,"library":"daiquiri","title":"Daiquiri (Logging Library)","description":"Daiquiri is a Python library designed to simplify the configuration of Python's built-in `logging` module. It provides an easy-to-use interface for setting up basic logging functionalities, including custom formatters and handlers, often with a single call to `daiquiri.setup()`. The library is actively maintained, with its current version being 3.4.0, and has a consistent update cadence.","status":"active","version":"3.4.0","language":"en","source_language":"en","source_url":"https://github.com/Mergifyio/daiquiri","tags":["logging","logger","configuration","structured logging"],"install":[{"cmd":"pip install daiquiri","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Required for using the JSON log formatter (daiquiri.formatter.JSON_FORMATTER).","package":"python-json-logger","optional":true}],"imports":[{"symbol":"setup","correct":"import daiquiri\ndaiquiri.setup(...)"},{"symbol":"getLogger","correct":"import daiquiri\nlogger = daiquiri.getLogger(__name__)"},{"note":"Used to configure logging output to streams like stdout or stderr.","symbol":"Stream","correct":"from daiquiri.output import Stream"},{"note":"Used to configure logging output to a file.","symbol":"File","correct":"from daiquiri.output import File"},{"note":"Requires 'python-json-logger' to be installed.","symbol":"JSON_FORMATTER","correct":"from daiquiri.formatter import JSON_FORMATTER"},{"note":"Default text formatter, no extra dependencies.","symbol":"TEXT_FORMATTER","correct":"from daiquiri.formatter import TEXT_FORMATTER"}],"quickstart":{"code":"import logging\nimport daiquiri\n\n# Basic setup to log to stderr with colors\ndaiquiri.setup(level=logging.INFO)\n\n# Get a logger instance\nlogger = daiquiri.getLogger(__name__)\n\nlogger.info('This is an info message.')\nlogger.warning('This is a warning message.')\nlogger.error('This is an error message with extra context!', user_id='123', transaction_id='abc')\n\n# Example with JSON output to a file (requires 'pip install python-json-logger')\n# from daiquiri.output import File\n# from daiquiri.formatter import JSON_FORMATTER\n# daiquiri.setup(\n#     level=logging.INFO,\n#     outputs=(\n#         File('app.log', formatter=JSON_FORMATTER),\n#     )\n# )\n# logger_json = daiquiri.getLogger('json_example')\n# logger_json.info('JSON message', data={'key': 'value'})","lang":"python","description":"This quickstart demonstrates how to initialize Daiquiri for basic logging to `stderr` with colored output. It also shows how to obtain a logger instance and log messages at different levels, including custom keyword arguments which Daiquiri supports natively. An commented-out example for JSON file logging is also provided, highlighting the need for an additional dependency."},"warnings":[{"fix":"To disable this, pass `capture_warnings=False` to `daiquiri.setup()`: `daiquiri.setup(capture_warnings=False)`.","message":"Daiquiri by default overrides Python's standard `warnings` module behavior, routing warnings to the `py.warnings` logger. If you rely on default `warnings` module behavior or custom warning filters, this might affect your application.","severity":"gotcha","affected_versions":"All versions 2.x and 3.x"},{"fix":"Always retrieve loggers using `logger = daiquiri.getLogger(__name__)` to leverage all of Daiquiri's features.","message":"While standard `logging.getLogger()` works, `daiquiri.getLogger()` is recommended. It provides an enhanced logger object that allows passing arbitrary keyword arguments to logging methods, which are then included as part of the log record. This enables rich, structured logging without extra boilerplate.","severity":"gotcha","affected_versions":"All versions 2.x and 3.x"},{"fix":"Ensure `pip install python-json-logger` is run if you intend to use JSON formatting.","message":"For structured JSON logging using `daiquiri.formatter.JSON_FORMATTER`, the `python-json-logger` library is a required dependency and must be installed separately.","severity":"gotcha","affected_versions":"All versions 2.x and 3.x"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Call `daiquiri.setup()` at the beginning of your application's entry point, specifying desired levels and outputs. E.g., `import daiquiri; daiquiri.setup(level=logging.INFO)`.","cause":"Daiquiri's logging setup function, `daiquiri.setup()`, has not been called, or was called incorrectly, preventing handlers from being attached to the root logger.","error":"No logging output appears in the console or file, or 'No handlers could be found for logger'"},{"fix":"Install the missing dependency: `pip install python-json-logger`.","cause":"You are attempting to use `daiquiri.formatter.JSON_FORMATTER` without installing its required dependency, `python-json-logger`.","error":"ModuleNotFoundError: No module named 'python_json_logger'"},{"fix":"Ensure you are installing `pip install daiquiri` for the logging library, and refer to its official documentation at `http://daiquiri.readthedocs.io/` or the GitHub repository at `https://github.com/Mergifyio/daiquiri`.","cause":"There are other Python projects, such as `django-daiquiri` (a framework for scientific databases) and `daiquiri` (a data quality reporting package for R, sometimes confused with Python). Users might install the wrong package or search for documentation of the wrong project.","error":"Confusion with another library or framework named 'Daiquiri'"}]}