Skip to content
UPEEC

logging

Structured application logs with levels, handlers and formats.

Easy
Comments 0
import logging
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(message)s")
log = logging.getLogger(__name__)
log.info("sensor started"); log.warning("voltage high: %.2f", v)

Prefer logging over print in anything that runs unattended.

Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.

Discussion (0)

Sign in or join free to ask questions and discuss this topic.