Skip to content

.tip

· one of the small things

logging, not print, from the first line of a service

print has no level, no timestamp and no module name, and you can't switch it off in production without editing code.

import logging
log = logging.getLogger(__name__)
log.info("order created", extra={"order_id": order.id})

Set up the format and the handler once at startup. A JSON formatter for production is either a five-line class or a dependency.

pythonobservability