Skip to content

fix: stop library from overriding application logging config#81

Merged
arun1729 merged 2 commits intomasterfrom
v3.7.3
Mar 5, 2026
Merged

fix: stop library from overriding application logging config#81
arun1729 merged 2 commits intomasterfrom
v3.7.3

Conversation

@arun1729
Copy link
Copy Markdown
Owner

@arun1729 arun1729 commented Mar 5, 2026

Remove dictConfig() call from Graph.init that was replacing the host application's entire logging setup. Follow Python best practice for library logging: add NullHandler to top-level 'cog' logger and let the application control its own configuration.

  • Remove logging_config dict from config.py
  • Remove dictConfig call and import from torque.py
  • Add NullHandler in cog/init.py
  • Namespace all loggers under 'cog.' (e.g. cog.torque, cog.database)
  • Clean up dictConfig references in test files

fixes #80

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the logging configuration within the cog library to adhere to Python's best practices for libraries. Previously, the library would aggressively configure logging for the entire application, potentially overriding the host application's desired setup. The changes ensure that the cog library now gracefully integrates by adding a NullHandler to its top-level logger and namespacing its internal loggers, allowing the application to maintain full control over its logging configuration.

Highlights

  • Logging Configuration Removal: Removed the dictConfig() call from Graph.__init__ in cog/torque.py to prevent the library from overwriting the host application's logging setup.
  • Logging Configuration Data Removal: Eliminated the logging_config dictionary from cog/config.py, which previously defined the library's default logging configuration.
  • NullHandler Implementation: Added a NullHandler to the top-level 'cog' logger in cog/__init__.py, aligning with Python's best practices for library logging.
  • Logger Namespacing: Standardized all internal loggers by namespacing them under 'cog.' (e.g., cog.torque, cog.database) for better organization and clarity.
  • Test File Cleanup: Cleaned up and removed all dictConfig references and imports from various test files to reflect the new logging approach.
Changelog
  • cog/init.py
    • Added logging.NullHandler() to the cog logger.
  • cog/cache.py
    • Updated logger name from 'table' to 'cog.cache'.
  • cog/config.py
    • Removed the logging_config dictionary.
  • cog/core.py
    • Updated logger names to 'cog.table', 'cog.index', 'cog.store', and 'cog.indexer'.
  • cog/database.py
    • Updated logger name from 'database' to 'cog.database'.
  • cog/torque.py
    • Removed dictConfig import.
    • Removed dictConfig call from __init__.
    • Updated logger name from 'torque' to 'cog.torque'.
  • test/bench.py
    • Removed dictConfig import and call.
  • test/test_batch_mode.py
    • Removed dictConfig import and multiple calls.
  • test/test_core.py
    • Removed dictConfig import and multiple calls.
  • test/test_core_coverage.py
    • Removed dictConfig import and call.
  • test/test_eof_error.py
    • Removed dictConfig import and multiple calls.
  • test/test_index.py
    • Removed dictConfig import and call.
  • test/test_indexer.py
    • Removed dictConfig import and call.
  • test/test_storage_integration.py
    • Removed dictConfig import and call.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly refactors the library's logging to align with Python best practices. By removing the dictConfig call and adding a NullHandler, the library no longer interferes with the host application's logging configuration. The namespacing of loggers under the cog hierarchy is also a great improvement for clarity. I've added a few minor suggestions to use the __name__ variable for getting loggers, which is a common and maintainable pattern.

Comment thread cog/cache.py Outdated
Comment thread cog/database.py Outdated
Comment thread cog/torque.py Outdated
Remove dictConfig() call from Graph.__init__ that was replacing the
host application's entire logging setup. Follow Python best practice
for library logging: add NullHandler to top-level 'cog' logger and
let the application control its own configuration.
- Remove logging_config dict from config.py
- Remove dictConfig call and import from torque.py
- Add NullHandler in cog/__init__.py
- Namespace all loggers under 'cog.' (e.g. cog.torque, cog.database)
- Clean up dictConfig references in test files
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.12%. Comparing base (0b1a361) to head (aff897c).
⚠️ Report is 1 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #81      +/-   ##
==========================================
- Coverage   87.13%   87.12%   -0.02%     
==========================================
  Files          12       12              
  Lines        2378     2376       -2     
==========================================
- Hits         2072     2070       -2     
  Misses        306      306              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@arun1729 arun1729 merged commit 197ce68 into master Mar 5, 2026
6 checks passed
@arun1729 arun1729 deleted the v3.7.3 branch March 5, 2026 18:57
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.

cogdb clobbers application logging

1 participant