{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# TARDIS Logger Widget Demo\n", "\n", "This notebook demonstrates how to use the TARDIS logging widget in a Jupyter environment." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import sys\n", "import os\n", "sys.path.append(os.path.dirname(os.path.abspath(''))) # Add parent directory to path\n", "\n", "import logging\n", "import time\n", "from logger import logging_state\n", "\n", "# Initialize the logging widget - this will display the widget in the notebook\n", "widget = logging_state(log_level=\"DEBUG\", display_logging_widget=True)\n", "\n", "# Get the tardis logger\n", "logger = logging.getLogger(\"tardis\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Basic Logging Examples\n", "\n", "Let's try different log levels. You'll see the messages appear in different tabs of the widget above." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "# Debug level message\n", "logger.debug(\"🔍 This is a debug message - useful for detailed debugging information\"*10000000)\n", "\n", "# Info level message\n", "logger.info(\"â„šī¸ This is an info message - general information about program execution\")\n", "\n", "# Warning level message\n", "logger.warning(\"âš ī¸ This is a warning message - something might be wrong!\")\n", "\n", "# Error level message\n", "logger.error(\"❌ This is an error message - something has definitely gone wrong!\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Structured Logging Example\n", "\n", "You can include variables and formatted strings in your logs:" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "batch_number = 42\n", "processed_items = 100\n", "\n", "logger.info(\"📊 Processing batch %d with %d items\", batch_number, processed_items)\n", "logger.debug(\"đŸ”ĸ Current processing rate: %.2f items/second\", processed_items/2.5)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Exception Logging Example\n", "\n", "The logger can capture and display exception information:" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "try:\n", " result = 1 / 0\n", "except Exception as e:\n", " logger.error(\"đŸ’Ĩ An error occurred during calculation\", exc_info=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Changing Log Levels\n", "\n", "You can change the log level at any time:" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "# Switch to INFO level - debug messages will no longer appear\n", "widget = logging_state(log_level=\"INFO\", display_logging_widget=True)\n", "\n", "logger.debug(\"🔍 This debug message won't appear\")\n", "logger.info(\"â„šī¸ But this info message will!\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "panel-resolve-march6", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.13.2" } }, "nbformat": 4, "nbformat_minor": 4 }