TARDIS Logger Widget Demo¶
This notebook demonstrates how to use the TARDIS logging widget in a Jupyter environment.
[ ]:
import sys
import os
sys.path.append(os.path.dirname(os.path.abspath(''))) # Add parent directory to path
import logging
import time
from logger import logging_state
# Initialize the logging widget - this will display the widget in the notebook
widget = logging_state(log_level="DEBUG", display_logging_widget=True)
# Get the tardis logger
logger = logging.getLogger("tardis")
Basic Logging Examples¶
Let’s try different log levels. You’ll see the messages appear in different tabs of the widget above.
[2]:
# Debug level message
logger.debug("🔍 This is a debug message - useful for detailed debugging information"*10000000)
# Info level message
logger.info("ℹ️ This is an info message - general information about program execution")
# Warning level message
logger.warning("⚠️ This is a warning message - something might be wrong!")
# Error level message
logger.error("❌ This is an error message - something has definitely gone wrong!")
Structured Logging Example¶
You can include variables and formatted strings in your logs:
[3]:
batch_number = 42
processed_items = 100
logger.info("📊 Processing batch %d with %d items", batch_number, processed_items)
logger.debug("🔢 Current processing rate: %.2f items/second", processed_items/2.5)
Exception Logging Example¶
The logger can capture and display exception information:
[4]:
try:
result = 1 / 0
except Exception as e:
logger.error("💥 An error occurred during calculation", exc_info=True)
Changing Log Levels¶
You can change the log level at any time:
[5]:
# Switch to INFO level - debug messages will no longer appear
widget = logging_state(log_level="INFO", display_logging_widget=True)
logger.debug("🔍 This debug message won't appear")
logger.info("ℹ️ But this info message will!")
[ ]: