Skip to main content
🔒 Preview mode. The first 15 Foundations lessons are free; this one is Pro. Start a 7-day trial to unlock the editor, AI hints and the rest of the curriculum. Card required, cancel any time in Dashboard.Start 7-day trial →
← CoursesSenior Deep-DivesModule 3 · Metaclasses, Descriptors, Magiclogging filters and adapterspredict34 / 161
+100 XP
Task
📝 **Question:** Predict the exact output. Root logger is configured at INFO. A custom \`HealthFilter\` drops any message containing \`/health\`. Four log calls fire — which ones come out, and in what format? 📋 Pick the right answer. 💡 **Hint:** Re-read the theory above if unsure.
Predict the output

Read the code carefully

import logging
import sys

logging.basicConfig(level=logging.INFO, format="%(levelname)s:%(message)s", stream=sys.stdout, force=True)

logger = logging.getLogger("svc")


class HealthFilter(logging.Filter):
    def filter(self, record):
        return "/health" not in record.getMessage()


logger.addFilter(HealthFilter())

logger.debug("debug-line")
logger.info("starting")
logger.info("GET /health 200")
logger.warning("slow query")
print("done")

What will the program print? Write here:

💬 Discussion

Be the first to ask a question or share a tip.
Sign in to join the discussion. Reading is free.
Loading discussion…