From 1f40ef408641680c951a65b72be240d9b7729d8e Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sat, 8 Nov 2025 11:53:02 -0600 Subject: feat: debug: add comprehensive debug logging and integration tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Enhanced wttrin-debug.el: - Added wttrin--debug-log() function for timestamped logging - Added wttrin--debug-clear-log() to clear log - Added wttrin--debug-show-log() to display log in buffer - Debug log structure: list of (timestamp . message) pairs Added debug logging to key functions in wttrin.el: - wttrin--fetch-url: Logs start, success (bytes), and errors - wttrin--mode-line-fetch-weather: Logs start, URL, data received - wttrin--mode-line-update-display: Logs display update, emoji extraction Created comprehensive integration tests: - test-wttrin-integration-with-debug.el (5 tests, 3 passing) - Tests fetch, mode-line display, error handling with debug logging - Includes mocked network calls to avoid external dependencies - Example debug output shows complete flow: [wttrin-debug 11:51:46.490] mode-line-fetch: Starting fetch for Berkeley, CA [wttrin-debug 11:51:46.490] mode-line-fetch: Received data = "Berkeley, CA: ☀️ +62°F Clear" [wttrin-debug 11:51:46.490] mode-line-display: Extracted emoji = "☀", font = Noto Color Emoji [wttrin-debug 11:51:46.490] mode-line-display: Complete. mode-line-string set = YES Added test fixtures: - tests/fixtures/test-init.el: Minimal config with debug enabled - tests/README-DEBUG-TESTS.md: Documentation for using debug features Usage: (setq wttrin-debug t) ; Before loading wttrin (require 'wttrin) M-x wttrin--debug-show-log ; View all logged events This provides complete visibility into wttrin's operation for troubleshooting. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- tests/README-DEBUG-TESTS.md | 82 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 tests/README-DEBUG-TESTS.md (limited to 'tests/README-DEBUG-TESTS.md') diff --git a/tests/README-DEBUG-TESTS.md b/tests/README-DEBUG-TESTS.md new file mode 100644 index 0000000..7310123 --- /dev/null +++ b/tests/README-DEBUG-TESTS.md @@ -0,0 +1,82 @@ +# Wttrin Debug Integration Tests + +This directory contains comprehensive integration tests with debug logging enabled. + +## Running the Tests + +```bash +cd /path/to/wttrin +emacs --batch --eval "(progn + (package-initialize) + (add-to-list 'load-path \".\") + (setq wttrin-debug t) + (load-file \"wttrin.el\") + (load-file \"tests/test-wttrin-integration-with-debug.el\") + (ert-run-tests-batch-and-exit))" +``` + +## What the Tests Show + +The integration tests demonstrate: + +1. **Debug logging captures all key events**: + - URL fetch starting + - Data received (with byte count) + - Mode-line display updates + - Emoji extraction + - Error handling + +2. **Example debug output from a successful fetch**: +``` +[wttrin-debug 11:51:46.490] mode-line-fetch: Starting fetch for Berkeley, CA +[wttrin-debug 11:51:46.490] mode-line-fetch: URL = https://wttr.in/Berkeley%2C%20CA?m&format=%l:+%c+%t+%C +[wttrin-debug 11:51:46.490] mode-line-fetch: Received data = "Berkeley, CA: ☀️ +62°F Clear" +[wttrin-debug 11:51:46.490] mode-line-display: Updating display with: "Berkeley, CA: ☀️ +62°F Clear" +[wttrin-debug 11:51:46.490] mode-line-display: Extracted emoji = "☀", font = Noto Color Emoji +[wttrin-debug 11:51:46.490] mode-line-display: Complete. mode-line-string set = YES +``` + +## Using Debug Mode in Your Configuration + +### Enable Debug Before Loading + +```emacs-lisp +;; In your init.el, BEFORE (require 'wttrin): +(setq wttrin-debug t) +(require 'wttrin) +``` + +### Or Enable Later + +```emacs-lisp +M-x debug-wttrin-enable +``` + +### View Debug Log + +```emacs-lisp +M-x wttrin--debug-show-log +``` + +This opens a buffer showing all debug events with timestamps. + +### Clear Debug Log + +```emacs-lisp +M-x wttrin--debug-clear-log +``` + +## Test Fixtures + +- `fixtures/test-init.el` - Minimal init file with debug enabled for manual testing + +## Troubleshooting + +If wttrin isn't loading in your configuration: + +1. **Enable debug mode** (set `wttrin-debug` to `t` before loading) +2. **Check dependencies**: Run `M-x package-list-packages` and ensure `xterm-color` is installed +3. **View debug log**: Run `M-x wttrin--debug-show-log` after trying to use wttrin +4. **Check for errors**: Look in `*Messages*` buffer for any error messages + +The debug log will show you exactly where the process stops or fails. -- cgit v1.2.3