Replace print/verbose with standard logging#337
Merged
Conversation
- lyricsgenius/__init__.py: add NullHandler per library logging best practice - auth.py: replace print() with logger.warning/info - types/base.py: remove verbose param from save_lyrics(), replace prints with logger.debug - types/artist.py: deprecate verbose in add_song()/save_lyrics(), replace prints with logger.debug - types/song.py: deprecate verbose in save_lyrics(), remove pass-through to super() - types/album.py: deprecate verbose in save_lyrics(), remove pass-through to super()
- Remove self.verbose attribute entirely - Deprecate verbose __init__ param with DeprecationWarning shim - Replace all if self.verbose: print(...) guards with module-level logger calls at appropriate levels: - INFO: search progress, song count, artist name changes - DEBUG: skipped/rejected songs, alternative search attempts - WARNING: not-found results, missing lyrics sections
- Add module-level logger - Drop verbose=args.verbose from Genius() constructor call - --verbose now calls logging.basicConfig(level=DEBUG) so all lyricsgenius log records surface to stderr - Replace guarded print() for 'Saving lyrics' with logger.info()
Replace print/verbose with standard Python logging (minor feature change).
One-liner for scripts/notebooks that handles basicConfig with a
sensible default format:
lyricsgenius.enable_logging()
lyricsgenius.enable_logging(logging.INFO)
lyricsgenius.enable_logging(fmt='%(asctime)s %(levelname)s: %(message)s')
Updates README and docs accordingly.
Closed
johnwmillr
added a commit
that referenced
this pull request
Mar 15, 2026
* logging: add NullHandler, replace prints with logging in auth and types
- lyricsgenius/__init__.py: add NullHandler per library logging best practice
- auth.py: replace print() with logger.warning/info
- types/base.py: remove verbose param from save_lyrics(), replace prints with logger.debug
- types/artist.py: deprecate verbose in add_song()/save_lyrics(), replace prints with logger.debug
- types/song.py: deprecate verbose in save_lyrics(), remove pass-through to super()
- types/album.py: deprecate verbose in save_lyrics(), remove pass-through to super()
* logging: replace self.verbose/print with logger in genius.py
- Remove self.verbose attribute entirely
- Deprecate verbose __init__ param with DeprecationWarning shim
- Replace all if self.verbose: print(...) guards with module-level
logger calls at appropriate levels:
- INFO: search progress, song count, artist name changes
- DEBUG: skipped/rejected songs, alternative search attempts
- WARNING: not-found results, missing lyrics sections
* logging: wire --verbose flag to logging in CLI
- Add module-level logger
- Drop verbose=args.verbose from Genius() constructor call
- --verbose now calls logging.basicConfig(level=DEBUG) so all
lyricsgenius log records surface to stderr
- Replace guarded print() for 'Saving lyrics' with logger.info()
* tests: remove deprecated verbose= kwargs from all test calls
* chore: bump version to 3.11.0
Replace print/verbose with standard Python logging (minor feature change).
* logging: add enable_logging() convenience helper
One-liner for scripts/notebooks that handles basicConfig with a
sensible default format:
lyricsgenius.enable_logging()
lyricsgenius.enable_logging(logging.INFO)
lyricsgenius.enable_logging(fmt='%(asctime)s %(levelname)s: %(message)s')
Updates README and docs accordingly.
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.
Replaces ad-hoc
print()calls and the non-standardverboseflag with Python's built-inloggingmodule.Changes
NullHandlerto thelyricsgeniuslogger so the library is silent by default (library best practice)print()calls withlogger.info/debug/warningat appropriate levelsself.verbosefromGenius; deprecate theverboseconstructor parameter with aDeprecationWarningverboseparams onadd_song()andsave_lyrics()across all types--verboseflag tologging.basicConfig(level=DEBUG)instead of passing it intoGeniusUsage after this change
Closes #185, #256