configure_logging
Enable colored structured logging for the repod library.NullHandler to the "repod" logger so no output appears unless you explicitly opt in.
Signature
Parameters
Minimum log level. Accepts an int (
logging.DEBUG, logging.INFO, etc.) or a string ("DEBUG", "INFO", etc.)Output stream for log messages. Defaults to
sys.stderr if not specified.Returns
This function returnsNone.
Call
configure_logging() once at application startup, before creating any server or client instances.Log Output Format
When logging is enabled, repod produces colored, structured output inspired by structlog:Log Levels
The formatter uses different colors and icons for each level:- DEBUG - Gray
[*]- Detailed diagnostic messages - INFO - Green
[+]- Normal operational messages - WARNING - Yellow
[!]- Warning messages - ERROR - Red
[-]- Error messages - CRITICAL - Bold red
[x]- Critical failures
Structured Context
Log messages include structured key-value pairs after the| separator. Common keys:
host,port,addr- Network addresses (cyan)action- Message action type (blue)error- Error messages (red)clients- Client count (yellow)bytes- Byte counts (yellow)
Example Usage
Basic Setup
Debug Mode
For verbose output during development:Custom Stream
Log to a file instead of stderr:Internal Logging
If you’re building a library or framework on top of repod and want to use the same structured logging pattern, you can import the internal utilities:The
get_logger() function is not part of the public API exported from repod.__init__, but it’s available for advanced use cases. It returns a StructuredLogger wrapper that accepts **kwargs for structured context.See Also
Server API
Configure and run servers
Client API
Connect and communicate with servers