Skip to content

Replace print/verbose with standard logging#337

Merged
johnwmillr merged 6 commits into
masterfrom
feature/logging
Mar 15, 2026
Merged

Replace print/verbose with standard logging#337
johnwmillr merged 6 commits into
masterfrom
feature/logging

Conversation

@johnwmillr

@johnwmillr johnwmillr commented Mar 13, 2026

Copy link
Copy Markdown
Owner

Replaces ad-hoc print() calls and the non-standard verbose flag with Python's built-in logging module.

Changes

  • Add NullHandler to the lyricsgenius logger so the library is silent by default (library best practice)
  • Replace all guarded print() calls with logger.info/debug/warning at appropriate levels
  • Remove self.verbose from Genius; deprecate the verbose constructor parameter with a DeprecationWarning
  • Deprecate verbose params on add_song() and save_lyrics() across all types
  • Wire the CLI --verbose flag to logging.basicConfig(level=DEBUG) instead of passing it into Genius

Usage after this change

import logging
logging.getLogger("lyricsgenius").setLevel(logging.DEBUG)

Closes #185, #256

- 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.
@johnwmillr johnwmillr merged commit 8b9e0db into master Mar 15, 2026
10 checks passed
@johnwmillr johnwmillr deleted the feature/logging branch March 15, 2026 03:54
@johnwmillr johnwmillr mentioned this pull request Mar 15, 2026
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.
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.

1 participant