Quick Start¶
Get a logger in one line, then add configuration when you need it.
loguru compatible
Same API as loguru - easy migration from existing code.
Choose your style¶
Set the minimum level¶
from logust import logger, LogLevel
logger.set_level(LogLevel.Warning)
logger.info("This will not be shown")
logger.warning("This will be shown")
Add a file sink¶
Common recipes¶
Performance tip
Use enqueue=True for async file writes in high-throughput scenarios.
from logust import logger
# Rotate and retain
logger.add("app.log", rotation="500 MB", retention="10 days")
# JSON output
logger.add("app.json", serialize=True)
logger.info("Structured log")
# Bind context
user_logger = logger.bind(user_id="123")
user_logger.info("User action")
# Catch exceptions
@logger.catch()
def risky():
return 1 / 0