Add exception info to logger warnings for better debugging#307
Add exception info to logger warnings for better debugging#307
Conversation
Pass exc_info=True so before_send, event_listener, and response-build failures include the underlying traceback, making issues like #305 diagnosable.
Install a LogRecord filter in config/logger.py that, whenever a log record of WARNING level or above is emitted while an exception is in flight (sys.exc_info() is set) and no exc_info was passed explicitly, attaches the active exception so the traceback is included. Call sites that want to stay terse can opt out with exc_info=False; this is done in the MQTT and MQTT Insights reconnect loops where the message alone is enough. Also pass exc_info=True explicitly at the most important catch-all log sites (Shelly event listener, Home Assistant/HomeWizard WebSocket loops, throttled powermeter fetch, Marstek auto-registration) so the intent is obvious at the call site.
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 5 minutes and 47 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (10)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Regrouped the flat bullet list into Breaking / Added / Changed / Fixed subsections so readers can scan by change type. Each bullet is now a standalone diff to main (no cross-references) and cites every PR that contributed. Added Breaking entries that were missing: - CT002/CT003 ACTIVE_CONTROL default (smoothing + 15 W BALANCE_DEADBAND + saturation detection on by default) - WAIT_FOR_NEXT_MESSAGE default True (affects Shelly emulation too, not just CT002/CT003) - Async Powermeter base (out-of-tree subclasses must implement async get_powermeter_watts()) Added missing feature bullets: per-powermeter EMA smoothing/deadband wrappers (#331), Hampel outlier filter (#334), MQTT BROKER_URI (#309), exc_info on warnings (#307). Filled in previously-missing PR refs on the rebrand, CT002/CT003, MQTT Insights, web config editor, PID controller, and GIT_COMMIT_SHA bullets. https://claude.ai/code/session_01BCVmemteVXNfoTQE4De2CU
* Restructure CHANGELOG Next section as Keep-a-Changelog diff to main Regrouped the flat bullet list into Breaking / Added / Changed / Fixed subsections so readers can scan by change type. Each bullet is now a standalone diff to main (no cross-references) and cites every PR that contributed. Added Breaking entries that were missing: - CT002/CT003 ACTIVE_CONTROL default (smoothing + 15 W BALANCE_DEADBAND + saturation detection on by default) - WAIT_FOR_NEXT_MESSAGE default True (affects Shelly emulation too, not just CT002/CT003) - Async Powermeter base (out-of-tree subclasses must implement async get_powermeter_watts()) Added missing feature bullets: per-powermeter EMA smoothing/deadband wrappers (#331), Hampel outlier filter (#334), MQTT BROKER_URI (#309), exc_info on warnings (#307). Filled in previously-missing PR refs on the rebrand, CT002/CT003, MQTT Insights, web config editor, PID controller, and GIT_COMMIT_SHA bullets. https://claude.ai/code/session_01BCVmemteVXNfoTQE4De2CU * Fold same-cycle fixes into their parent Added bullets The Fixed / Changed bullets for CT002/CT003 saturation, efficiency- rotation lockup, and the MQTT_INSIGHTS empty-config crash / HA mosquitto availability check referenced features introduced in this same release cycle, so they weren't a standalone diff against main. Merged those PR refs into the CT002/CT003 and MQTT Insights Added bullets (the end state, which is what a main-viewer cares about). Modbus UNIT_ID fix stays in Fixed — Modbus existed on main. https://claude.ai/code/session_01BCVmemteVXNfoTQE4De2CU * Fold CT002/CT003 active-control defaults into Added bullet The CT002/CT003 ACTIVE_CONTROL default is not a 'changed default' vs main — CT002/CT003 don't exist on main, so the default is just part of the new feature description. Moved the default-on behavior and BALANCE_DEADBAND details into the CT002/CT003 Added bullet. Also narrowed the WAIT_FOR_NEXT_MESSAGE Breaking bullet to just the Shelly emulator (the real diff against main); the CT002/CT003 aspect is implicit in the CT002/CT003 Added bullet. Fixed a minor verb mismatch in Changed: 'Added battery activity info logs' → 'Expanded Shelly emulation logs'. https://claude.ai/code/session_01BCVmemteVXNfoTQE4De2CU --------- Co-authored-by: Claude <noreply@anthropic.com>
Summary
Enhanced logging throughout the codebase by adding
exc_info=Trueparameter to logger.warning() calls that handle exceptions. This ensures that full stack traces are included in warning logs, improving debuggability.Key Changes
exc_info=Trueto_call_event_listener()exception handler to log full stack trace when event listener failsexc_info=Trueto_call_before_send()exception handler to log full stack trace when before_send callback failsexc_info=Trueto_handle_request()exception handler to log full stack trace when request handling failsImplementation Details
These changes maintain backward compatibility while improving observability. When
exc_info=Trueis passed to logger.warning(), Python's logging module automatically includes the full exception traceback in the log output, making it easier to diagnose issues in production environments without requiring additional error handling code.https://claude.ai/code/session_01SGt3XARC6exgnu1jEnYiza