Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix logging no-handlers warning #445

Merged
merged 2 commits into from May 23, 2019

Conversation

Projects
None yet
3 participants
@jeffwecan
Copy link
Collaborator

commented May 23, 2019

The exciting conclusion to #400

paulcaskey and others added some commits Mar 6, 2019

Fix logging no-handlers warning
If a user requests a URI starting with a slash like "/some/path/...", it gets prepended with "/v1/" in the hvac Client class, resulting in a final URL here of "/v1//some/path/..." We then try to log a warning about this (see line 239). However, the python "logging" module requires at least some basic setup before it can be used, so the call on line 242 to logger.warning() actually throws its own non-critical error: 

   No handlers could be found for logger "hvac.adapters"

This change adds the easiest fix, which is to call logging.basicConfig() before instantiating our logger at the top of this file. 

P.S. As a shortcut, logging.warning() calls basicConfg() for you, if you haven't already started with getLogger(). So, confusingly, another fix here would be to remove this entirely:
    logger = logging.getLogger(__name__)
and call this:
    logging.warning('Replacing double-slashes...')
instead of this:
    logger.warning('Replacing double-slashes...')

I feel my fix here is cleaner.

@jeffwecan jeffwecan added this to the 0.8.3 milestone May 23, 2019

@jeffwecan jeffwecan merged commit 434c99a into hvac:develop May 23, 2019

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@jeffwecan jeffwecan deleted the jeffwecan:paulcaskey/patch-1 branch May 23, 2019

@codecov-io

This comment has been minimized.

Copy link

commented May 23, 2019

Codecov Report

Merging #445 into develop will decrease coverage by 0.95%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #445      +/-   ##
===========================================
- Coverage    87.88%   86.93%   -0.96%     
===========================================
  Files           48       49       +1     
  Lines         2468     2533      +65     
===========================================
+ Hits          2169     2202      +33     
- Misses         299      331      +32
Impacted Files Coverage Δ
hvac/adapters.py 94.2% <ø> (-0.25%) ⬇️
hvac/api/secrets_engines/__init__.py 100% <0%> (ø) ⬆️
hvac/constants/gcp.py 100% <0%> (ø) ⬆️
hvac/api/secrets_engines/gcp.py 46.66% <0%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 00d5ab8...52fd3d8. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.