Print Instead Of Logger (ARCH2157)
هذا المحتوى غير متوفر بلغتك بعد.
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.
Incorrect
Section titled “Incorrect”def process(order): print("Processing:", order.id) return charge(order)Correct
Section titled “Correct”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.