Skip to content

fix: honor log_level=DEBUG for the meshcore library logger - #12

Merged
sg merged 1 commit into
mainfrom
fix/meshcore-debug-logging
Jun 13, 2026
Merged

sg merged 1 commit into
mainfrom
fix/meshcore-debug-logging

Conversation

@sg

@sg sg commented Jun 13, 2026

Copy link
Copy Markdown
Owner

Problem

Setting log_level = DEBUG in mcbot.conf enabled the bot's own debug lines but NOT the meshcore library's verbose output; only --debug produced the library firehose. (Confirmed from a live log: the startup banner showed logging at DEBUG (log_level=DEBUG) and a [DEBUG] line from the mcbot logger appeared, while the meshcore logger stayed quiet.)

Root cause

MeshCore.__init__ sets the meshcore logger level from its debug argument (debug=True → DEBUG, else → INFO) — and that arg is only a logger-level switch, nothing else. The bot calls create_serial(..., debug=self.cfg.debug) during run(), after setup_logging. So:

  1. setup_logging sets meshcore → DEBUG
  2. create_serial(debug=False) at connect overrides it back to INFO

--debug worked only because it set cfg.debug=True, making the library set its own logger to DEBUG.

Fix

  • Add effective_log_level(cfg) (DEBUG if --debug, else log_level).
  • run() passes debug=want_debug (from the effective level) to create_serial/create_tcp, and re-asserts the meshcore logger level immediately after connecting — covering the TypeError fallback path and WARNING/ERROR (which the library would otherwise floor at INFO).
  • setup_logging uses the same helper.
  • Regression test reproduces the override-then-reassert sequence and checks effective_log_level.

Testing

py_compile clean; tests/test_logging.py, tests/test_repeat_tracking.py, tests/test_radio_eviction.py all pass. With this, log_level=DEBUG yields the full library [DEBUG] output (e.g. Received RF log data: …) without --debug.

Note

Supersedes the logger-level portion of #10 (which set the level in setup_logging but was overridden by the library at connect). The #11 startup banner is what made this diagnosable from the live log.

@sg
sg merged commit 5e92354 into main Jun 13, 2026
1 check passed
@sg
sg deleted the fix/meshcore-debug-logging branch June 13, 2026 05:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant