Skip to content

Make logging.basicConfig conditional#670

Merged
patkan merged 3 commits into
python-escpos:masterfrom
GjjvdBurg:move_logging_config
Aug 24, 2025
Merged

Make logging.basicConfig conditional#670
patkan merged 3 commits into
python-escpos:masterfrom
GjjvdBurg:move_logging_config

Conversation

@GjjvdBurg

Copy link
Copy Markdown
Contributor

Hi there, thank you so much for this library, I'm having a lot of fun with it!

Description

I wrote a wrapper script using this library in which I'm using the logging module, and I'm noticing that all my log messages are duplicated. I found this comment in issue #559 which mentions the same thing and identifies the root cause to be the logging.basicConfig call in capabilities.py. So this PR places that call behind an environment variable, so it can still be enabled for debugging but is no longer enabled by default. I also found this section of the Python docs describing logging from a library, which seems to correspond with this change.

Tested with

Tested with my wrapper script and this branch. With the change I made the log messages are no longer duplicated.

Thanks in advance for taking a look!

@codecov

codecov Bot commented Aug 24, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 33.33333% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.39%. Comparing base (1a780e8) to head (dcaccae).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/escpos/capabilities.py 33.33% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #670      +/-   ##
==========================================
- Coverage   81.50%   81.39%   -0.11%     
==========================================
  Files          21       21              
  Lines        1692     1693       +1     
  Branches      266      267       +1     
==========================================
- Hits         1379     1378       -1     
- Misses        234      235       +1     
- Partials       79       80       +1     
Flag Coverage Δ
unittests 81.21% <33.33%> (-0.11%) ⬇️

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

Files with missing lines Coverage Δ
src/escpos/capabilities.py 81.72% <33.33%> (-1.98%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@patkan patkan merged commit 11d46fd into python-escpos:master Aug 24, 2025
15 checks passed
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