Aller au contenu

Print Instead Of Logger (ARCH2157)

Ce contenu n’est pas encore disponible dans votre langue.

Key python.logging.print-instead-of-logger · Severity info · Category logging

Writing to the console with print lacks configurable features like log level, timestamps, and output routing. In production these outputs cannot be aggregated or filtered.

def process(order):
print("Processing:", order.id)
return charge(order)
import logging
logger = logging.getLogger(__name__)
def process(order):
logger.info("Processing: %s", order.id)
return charge(order)

Replace print calls with a configured logging.Logger at the appropriate level.