Skip to content

Conversation

@shukari
Copy link
Contributor

@shukari shukari commented Aug 6, 2025

It is now possible to set loglevels for each module or for all per:

# all loggers
logging.getLogger('meshtastic').setLevel(logging.DEBUG)

# only ble_interface
logging.getLogger('meshtastic.ble_interface').setLevel(logging.DEBUG)
  • test are now runable on windows, some are ignored on windows
  • test_exit_with_exception with a true exception
  • new --debuglib parameter for only meshtastic debug

@ianmcorvidae ianmcorvidae requested a review from Copilot August 6, 2025 17:15
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces structured logging with module-specific handlers throughout the Meshtastic codebase. The main purpose is to enable granular log level control for individual modules or the entire library.

  • Adds named logger instances to all modules using logging.getLogger(__name__)
  • Replaces direct logging.* calls with module-specific logger.* calls
  • Enables per-module log level configuration as described in the PR description

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
meshtastic/util.py Adds module logger and converts logging calls
meshtastic/tunnel.py Adds module logger and converts logging calls
meshtastic/test.py Adds module logger and converts logging calls
meshtastic/tcp_interface.py Adds module logger and converts logging calls
meshtastic/stream_interface.py Adds module logger and converts logging calls
meshtastic/serial_interface.py Adds module logger and converts logging calls
meshtastic/remote_hardware.py Adds module logger and converts logging calls
meshtastic/node.py Adds module logger and converts logging calls
meshtastic/mesh_interface.py Adds module logger and converts logging calls
meshtastic/ble_interface.py Adds module logger and converts logging calls
meshtastic/main.py Adds module logger and converts logging calls
meshtastic/init.py Adds module logger and converts logging calls

@ianmcorvidae
Copy link
Contributor

Looks pretty reasonable to me skimming from my phone; I'll throw copilot at it for now and set off CI, and try to give it a close look when I've next got a small block of time at a proper computer just in case there's anything finicky to spot. Thanks for the PR!

shukari and others added 3 commits August 6, 2025 19:54
- test are now runable on windows, some are ignored and a fake termios for the decorators
- test_exit_with_exception with a true exception
@shukari shukari changed the title Added Logging Handler Names Added Logging Handler Names & windows pytest support Aug 6, 2025
@shukari
Copy link
Contributor Author

shukari commented Aug 6, 2025

@ianmcorvidae because the test test_exit_with_exception didnt raise a true exception, the test failed. I changed it and it should now report the traceback. Also i did some changes that windows users can run the tests (some are linux only atm)

@shukari
Copy link
Contributor Author

shukari commented Aug 9, 2025

So.... i did a pytest and a pylint... please... be ok now 😅

@shukari
Copy link
Contributor Author

shukari commented Aug 21, 2025

Windows test (used host windows) with act -P ubuntu-latest=-self-hosted --matrix "python-version:3.12" -> ✅
Linux test with act --matrix "python-version:3.12" -> ✅

@codecov
Copy link

codecov bot commented Sep 12, 2025

Codecov Report

❌ Patch coverage is 55.85586% with 98 lines in your changes missing coverage. Please review.
✅ Project coverage is 60.15%. Comparing base (c60b5d4) to head (fe093ac).
⚠️ Report is 13 commits behind head on master.

Files with missing lines Patch % Lines
meshtastic/node.py 39.21% 31 Missing ⚠️
meshtastic/mesh_interface.py 57.77% 19 Missing ⚠️
meshtastic/ble_interface.py 5.88% 16 Missing ⚠️
meshtastic/serial_interface.py 60.00% 6 Missing ⚠️
meshtastic/stream_interface.py 45.45% 6 Missing ⚠️
meshtastic/__main__.py 70.58% 5 Missing ⚠️
meshtastic/slog/slog.py 75.00% 5 Missing ⚠️
meshtastic/tunnel.py 80.00% 4 Missing ⚠️
meshtastic/__init__.py 70.00% 3 Missing ⚠️
meshtastic/analysis/__main__.py 75.00% 1 Missing ⚠️
... and 2 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #812      +/-   ##
==========================================
+ Coverage   60.13%   60.15%   +0.01%     
==========================================
  Files          24       24              
  Lines        4219     4241      +22     
==========================================
+ Hits         2537     2551      +14     
- Misses       1682     1690       +8     
Flag Coverage Δ
unittests 60.15% <55.85%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ianmcorvidae ianmcorvidae merged commit cfb2378 into meshtastic:master Sep 18, 2025
1 check passed
@shukari shukari deleted the loggingHandler2 branch September 18, 2025 17:00
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.

2 participants