Skip to content

chore(logging): enforce usage of setup_logger#1895

Open
paul-nechifor wants to merge 1 commit intodevfrom
paul/chore/no-get-logger
Open

chore(logging): enforce usage of setup_logger#1895
paul-nechifor wants to merge 1 commit intodevfrom
paul/chore/no-get-logger

Conversation

@paul-nechifor
Copy link
Copy Markdown
Contributor

Problem

People keep adding logger.getLogger instead of setup_logger().

Closes DIM-804

Solution

  • Add a test which disallows use of getLogger.
  • Fix current bad usages.

Breaking Changes

None

How to Test

Contributor License Agreement

  • I have read and approved the CLA.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 21, 2026

Greptile Summary

This PR enforces the project convention of using setup_logger() over logging.getLogger() by adding a new test (test_get_logger.py) that scans the codebase for forbidden assignment-form usages and whitelists the handful of legitimate exceptions. Fifteen files are migrated to setup_logger() alongside the new enforcement test.

Confidence Score: 5/5

Safe to merge — all migrations are correct and the new test is well-structured with only a minor P2 edge case around commented lines.

All findings are P2 or lower. The one flagged issue (test pattern matching inside comment lines) is a theoretical edge case with no current instances in the codebase. All 15 migrated files correctly switch to setup_logger(), and the whitelist accurately captures the 5 legitimate exceptions.

dimos/project/test_get_logger.py — minor edge case with commented-out code matching the forbidden pattern

Important Files Changed

Filename Overview
dimos/project/test_get_logger.py New enforcement test for setup_logger usage; correctly walks the tree and whitelists legitimate uses, but does not skip commented-out lines containing the forbidden pattern
dimos/agents_deprecated/modules/gateway/client.py Migrated from logging.getLogger to setup_logger(); change is correct
dimos/agents_deprecated/modules/gateway/tensorzero_embedded.py Migrated from logging.getLogger to setup_logger(); change is correct
dimos/hardware/sensors/camera/gstreamer/gstreamer_camera_test_script.py Module logger migrated to setup_logger(); root-logger level override via logging.getLogger().setLevel() is a non-assignment pattern not caught by the test, which is intentionally correct
dimos/hardware/drive_trains/registry.py Migrated to setup_logger(); correct
dimos/hardware/manipulators/registry.py Migrated to setup_logger(); correct
dimos/stream/video_provider.py Migrated to setup_logger(); correct
dimos/stream/data_provider.py Migrated to setup_logger(); correct
dimos/skills/skills.py Migrated to setup_logger(); correct
dimos/project/test_no_sections.py Unchanged — shown for context alongside the new test_get_logger.py; structure is consistent

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[test_get_logger.py] --> B[Walk dimos/ tree]
    B --> C{Line contains\n'= logging.getLogger'?}
    C -- No --> D[Skip]
    C -- Yes --> E{In WHITELIST?}
    E -- Yes --> D
    E -- No --> F[Add to violations]
    F --> G{violations empty?}
    G -- Yes --> H[Test passes ✓]
    G -- No --> I[AssertionError:\nUse setup_logger instead]
Loading

Reviews (1): Last reviewed commit: "chore(logging): enforce usage of setup_l..." | Re-trigger Greptile

Comment thread dimos/project/test_get_logger.py
@paul-nechifor paul-nechifor enabled auto-merge (squash) April 22, 2026 01:32
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