Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions dimos/agents_deprecated/modules/gateway/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,18 @@

import asyncio
from collections.abc import AsyncIterator, Iterator
import logging
import os
from types import TracebackType
from typing import Any

import httpx
from tenacity import retry, stop_after_attempt, wait_exponential

from dimos.utils.logging_config import setup_logger

from .tensorzero_embedded import TensorZeroEmbeddedGateway

logger = logging.getLogger(__name__)
logger = setup_logger()


class UnifiedGatewayClient:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
"""TensorZero embedded gateway client with correct config format."""

from collections.abc import AsyncIterator, Iterator
import logging
from pathlib import Path
from typing import Any

logger = logging.getLogger(__name__)
from dimos.utils.logging_config import setup_logger

logger = setup_logger()


class TensorZeroEmbeddedGateway:
Expand Down
4 changes: 2 additions & 2 deletions dimos/control/hardware_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@

from __future__ import annotations

import logging
import time
from typing import TYPE_CHECKING

from dimos.hardware.manipulators.spec import ControlMode, ManipulatorAdapter
from dimos.utils.logging_config import setup_logger

if TYPE_CHECKING:
from dimos.control.components import HardwareComponent, HardwareId, JointName, JointState
from dimos.hardware.drive_trains.spec import TwistBaseAdapter

logger = logging.getLogger(__name__)
logger = setup_logger()


class ConnectedHardware:
Expand Down
5 changes: 3 additions & 2 deletions dimos/hardware/drive_trains/flowbase/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,17 @@

from __future__ import annotations

import logging
import threading
from typing import TYPE_CHECKING

import numpy as np

from dimos.utils.logging_config import setup_logger

if TYPE_CHECKING:
from dimos.hardware.drive_trains.registry import TwistBaseAdapterRegistry

logger = logging.getLogger(__name__)
logger = setup_logger()


class FlowBaseAdapter:
Expand Down
5 changes: 3 additions & 2 deletions dimos/hardware/drive_trains/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,15 @@

from collections.abc import Callable
import importlib
import logging
import os
from typing import TYPE_CHECKING, Any

from dimos.utils.logging_config import setup_logger

if TYPE_CHECKING:
from dimos.hardware.drive_trains.spec import TwistBaseAdapter

logger = logging.getLogger(__name__)
logger = setup_logger()


class TwistBaseAdapterRegistry:
Expand Down
5 changes: 3 additions & 2 deletions dimos/hardware/manipulators/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@
from __future__ import annotations

import importlib
import logging
from typing import TYPE_CHECKING, Any

from dimos.utils.logging_config import setup_logger

if TYPE_CHECKING:
from dimos.hardware.manipulators.spec import ManipulatorAdapter

logger = logging.getLogger(__name__)
logger = setup_logger()


class AdapterRegistry:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
from dimos.hardware.sensors.camera.gstreamer.gstreamer_camera import GstreamerCameraModule
from dimos.msgs.sensor_msgs.Image import Image
from dimos.protocol.pubsub.impl import lcmpubsub as _lcm
from dimos.utils.logging_config import setup_logger

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
logger = setup_logger()


def main() -> None:
Expand Down
4 changes: 2 additions & 2 deletions dimos/models/vl/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from abc import ABC, abstractmethod
import json
import logging
from typing import Any
import warnings

Expand All @@ -15,8 +14,9 @@
from dimos.utils.data import get_data
from dimos.utils.decorators.decorators import retry
from dimos.utils.llm_utils import extract_json
from dimos.utils.logging_config import setup_logger

logger = logging.getLogger(__name__)
logger = setup_logger()

class Captioner(ABC):
"""Interface for models that can generate image captions."""
Expand Down
116 changes: 116 additions & 0 deletions dimos/project/test_get_logger.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# Copyright 2026 Dimensional Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import os

from dimos.constants import DIMOS_PROJECT_ROOT

PATTERN = "= logging.getLogger"

IGNORED_DIRS = {
".venv",
"venv",
"__pycache__",
"node_modules",
".git",
"dist",
"build",
".egg-info",
".tox",
}

# Lines that match the pattern but are legitimate uses.
WHITELIST = [
("dimos/utils/logging_config.py", "logger_obj = logging.getLogger(logger_name)"),
("dimos/utils/logging_config.py", "stdlib_logger = logging.getLogger(name)"),
("dimos/core/coordination/python_worker.py", "lg = logging.getLogger(name)"),
("dimos/robot/foxglove_bridge.py", "logger = logging.getLogger(logger)"),
(
"dimos/hardware/sensors/camera/gstreamer/gstreamer_sender.py",
'logger = logging.getLogger("gstreamer_tcp_sender")',
),
]


def _is_ignored_dir(dirpath: str) -> bool:
parts = dirpath.split(os.sep)
return bool(IGNORED_DIRS.intersection(parts))


def _is_whitelisted(rel_path: str, line: str) -> bool:
for allowed_path, allowed_substr in WHITELIST:
if rel_path == allowed_path and allowed_substr in line:
return True
return False


def find_get_logger_usages() -> list[tuple[str, int, str]]:
"""Return a list of (rel_path, line_number, line_text) for every violation."""
dimos_dir = DIMOS_PROJECT_ROOT / "dimos"
violations: list[tuple[str, int, str]] = []
# Skip this test file.
self_path = os.path.realpath(__file__)

for dirpath, dirnames, filenames in os.walk(dimos_dir):
dirnames[:] = [d for d in dirnames if d not in IGNORED_DIRS]

if _is_ignored_dir(dirpath):
continue

for fname in filenames:
if not fname.endswith(".py"):
continue

full_path = os.path.join(dirpath, fname)
if os.path.realpath(full_path) == self_path:
continue
rel_path = os.path.relpath(full_path, DIMOS_PROJECT_ROOT)

try:
with open(full_path, encoding="utf-8", errors="replace") as f:
for lineno, line in enumerate(f, start=1):
stripped = line.rstrip("\n")
if PATTERN not in stripped:
Comment thread
paul-nechifor marked this conversation as resolved.
continue
if _is_whitelisted(rel_path, stripped):
continue
violations.append((rel_path, lineno, stripped))
except (OSError, UnicodeDecodeError):
continue

return violations


def test_no_get_logger():
"""
Fail if any file uses `= logging.getLogger` outside the whitelist.
"""
violations = find_get_logger_usages()
if violations:
report_lines = [
f"Found {len(violations)} forbidden use(s) of `logging.getLogger`. "
"Use `setup_logger` instead:",
"",
" from dimos.utils.logging_config import setup_logger",
"",
" logger = setup_logger()",
"",
"If the usage is legitimate (e.g. standalone script, logging "
"infrastructure, or third-party logger suppression), add it to the "
"WHITELIST in dimos/project/test_get_logger.py.",
"",
]
for path, lineno, text in violations:
report_lines.append(f" {path}:{lineno}: {text.strip()}")
raise AssertionError("\n".join(report_lines))
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions dimos/protocol/service/system_configurator/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
from __future__ import annotations

from abc import ABC, abstractmethod
import logging
import os
import subprocess

from dimos.utils import prompt
from dimos.utils.logging_config import setup_logger

logger = logging.getLogger(__name__)
logger = setup_logger()


def _read_sysctl_int(name: str) -> int | None:
Expand Down
4 changes: 2 additions & 2 deletions dimos/protocol/service/system_configurator/libpython.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@

from __future__ import annotations

import logging
from pathlib import Path
import platform
import sys

from dimos.protocol.service.system_configurator.base import SystemConfigurator
from dimos.utils.logging_config import setup_logger

logger = logging.getLogger(__name__)
logger = setup_logger()


class LibPythonConfiguratorMacOS(SystemConfigurator):
Expand Down
4 changes: 2 additions & 2 deletions dimos/robot/unitree/go2/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import logging
import sys
from threading import Thread
import time
Expand All @@ -32,6 +31,7 @@
from dimos.core.stream import In, Out
from dimos.core.transport import LCMTransport, pSHMTransport
from dimos.spec.perception import Camera, Pointcloud
from dimos.utils.logging_config import setup_logger

if TYPE_CHECKING:
from dimos.core.rpc_client import ModuleProxy
Expand All @@ -53,7 +53,7 @@
else:
from typing import TypeVar

logger = logging.getLogger(__name__)
logger = setup_logger()


class ConnectionConfig(ModuleConfig):
Expand Down
5 changes: 2 additions & 3 deletions dimos/skills/rest/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import logging

from pydantic import Field
import requests

from dimos.skills.skills import AbstractSkill
from dimos.utils.logging_config import setup_logger

logger = logging.getLogger(__name__)
logger = setup_logger()


class GenericRestSkill(AbstractSkill):
Expand Down
7 changes: 2 additions & 5 deletions dimos/skills/skills.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,18 @@

from __future__ import annotations

import logging
from typing import TYPE_CHECKING, Any

from openai import pydantic_function_tool
from pydantic import BaseModel

from dimos.types.constants import Colors
from dimos.utils.logging_config import setup_logger

if TYPE_CHECKING:
from collections.abc import Iterator

# Configure logging for the module
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
logger = setup_logger()


class SkillLibrary:
Expand Down
Loading
Loading