Skip to content
Merged
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
2 changes: 2 additions & 0 deletions src/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ class Settings(BaseSettings):
PROJECT_NAME: str = "mAIcro"
VERSION: str = "0.1.0"
API_V1_STR: str = "/api/v1"
LOG_LEVEL: str = "INFO"
LOG_FORMAT: str = "%(asctime)s | %(levelname)s | %(name)s | %(message)s"

ORG_NAME: str = "MicroClub"
ORG_DESCRIPTION: Optional[str] = "A generic organization using mAIcro"
Expand Down
4 changes: 2 additions & 2 deletions src/core/llm_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ConfigurationError(ValueError):
"""Raised when model providers are misconfigured."""


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


class RateLimitExceeded(Exception):
Expand Down Expand Up @@ -103,7 +103,7 @@ def _invoke(prompt: str):
try:
return _invoke_with_rate_limit_retries(primary_llm, prompt)
except RateLimitExceeded:
_LOGGER.warning(
logger.warning(
"Primary Gemini model rate-limited after %s attempts; switching to fallback.",
settings.LLM_MAX_PRIMARY_ATTEMPTS,
)
Expand Down
14 changes: 14 additions & 0 deletions src/core/logging_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import logging
import sys
from core.config import settings

def setup_logging():
"""Centralized logging configuration."""
logging.basicConfig(
level=getattr(logging, settings.LOG_LEVEL.upper(), logging.INFO),
format=settings.LOG_FORMAT,
handlers=[
logging.StreamHandler(sys.stdout)
],
force=True # Ensure that the root logger is reset and configured correctly
)
7 changes: 3 additions & 4 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@
from core.discord_listener import run_discord_listener
from core.ingestion import ingest_from_discord, run_startup_audit
import logging
from core.logging_config import setup_logging

setup_logging()

logging.basicConfig(
level=logging.INFO,
format="%(asctime)s | %(levelname)s | %(name)s | %(message)s",
)

logger = logging.getLogger(__name__)

Expand Down
Loading