Repository navigation
fix: honor log_level=DEBUG for the meshcore library logger - #12
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Setting
log_level = DEBUGinmcbot.confenabled the bot's own debug lines but NOT the meshcore library's verbose output; only--debugproduced the library firehose. (Confirmed from a live log: the startup banner showedlogging at DEBUG (log_level=DEBUG)and a[DEBUG]line from themcbotlogger appeared, while themeshcorelogger stayed quiet.)Root cause
MeshCore.__init__sets themeshcorelogger level from itsdebugargument (debug=True → DEBUG, else→ INFO) — and that arg is only a logger-level switch, nothing else. The bot callscreate_serial(..., debug=self.cfg.debug)duringrun(), aftersetup_logging. So:setup_loggingsetsmeshcore→ DEBUGcreate_serial(debug=False)at connect overrides it back to INFO--debugworked only because it setcfg.debug=True, making the library set its own logger to DEBUG.Fix
effective_log_level(cfg)(DEBUGif--debug, elselog_level).run()passesdebug=want_debug(from the effective level) tocreate_serial/create_tcp, and re-asserts themeshcorelogger level immediately after connecting — covering theTypeErrorfallback path andWARNING/ERROR(which the library would otherwise floor at INFO).setup_logginguses the same helper.effective_log_level.Testing
py_compileclean;tests/test_logging.py,tests/test_repeat_tracking.py,tests/test_radio_eviction.pyall pass. With this,log_level=DEBUGyields 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_loggingbut was overridden by the library at connect). The #11 startup banner is what made this diagnosable from the live log.