Skip to content

fix(resource_reader): use namespaced module logger instead of root logger - #225

Open
reginaldalfret wants to merge 1 commit into
google:masterfrom
reginaldalfret:fix/issue-194-module-logger
Open

reginaldalfret wants to merge 1 commit into
google:masterfrom
reginaldalfret:fix/issue-194-module-logger

Conversation

@reginaldalfret

Copy link
Copy Markdown

Fixes #194

Problem

In \gin/resource_reader.py, calls to log resource opening and missing search paths currently use \logging.info\ and \logging.error\ directly on Python's root logger. When applications or packages import gin, this pollutes the root logger output and prevents consuming applications from configuring, muting, or adjusting log levels for gin messages (such as \logging.getLogger('gin').setLevel(logging.CRITICAL)).

Solution

  • Initialize a module-level logger: \logger = logging.getLogger(name).
  • Route \system_path_reader\ and \system_path_file_exists\ logging calls through \logger.info\ and \logger.error.
  • Add unit tests in \ ests/resource_reader_test.py\ verifying logger naming and filtering behavior.

Verification

  • Tested with Python 3.11 \ ests/resource_reader_test.py: all 3 tests passed cleanly.

…gger (google#194)

Signed-off-by: reginaldalfret <reginaldalfret@gmail.com>
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.

Use non-root python logger

1 participant