diff --git a/.env.example b/.env.example index c921fe0..b98e904 100644 --- a/.env.example +++ b/.env.example @@ -1,6 +1,9 @@ # OpenAI support (required) OPENAI_API_KEY=sk-proj-qwertya +# Logging configuration (optional) +# LOG_LEVEL=INFO + # VCS connector setup (required to connect core pipeline with VCS) #VCS_PROVIDER=github #VCS_ACCESS_TOKEN= diff --git a/README.md b/README.md index 43a71cc..be26ff5 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,20 @@ Running as a service to automatically process issues: ## Configuration +### Logging + +DeepNext uses [Loguru](https://loguru.readthedocs.io/) for logging. +By default, the log level is set to `INFO` to reduce verbosity. +You can override the log level by setting the `LOG_LEVEL` environment variable in your `.env` file: + +```env +# LOG_LEVEL=DEBUG +``` + +Supported values: `DEBUG`, `INFO`, `WARNING`, `ERROR`, `CRITICAL`. + +### LLM Providers + DeepNext supports multiple LLM providers: - OpenAI - AWS Bedrock (Claude, Mistral, and others) diff --git a/apps/app/deep_next/app/entrypoint.py b/apps/app/deep_next/app/entrypoint.py index 1933a8d..5571576 100644 --- a/apps/app/deep_next/app/entrypoint.py +++ b/apps/app/deep_next/app/entrypoint.py @@ -155,8 +155,9 @@ def main() -> None: if __name__ == "__main__": - from deep_next.common.common import load_monorepo_dotenv + from deep_next.common.common import load_monorepo_dotenv, setup_logging load_monorepo_dotenv() + setup_logging() main() diff --git a/apps/app/deep_next/app/entrypoint_scheduled.py b/apps/app/deep_next/app/entrypoint_scheduled.py index 97d4666..83bc904 100644 --- a/apps/app/deep_next/app/entrypoint_scheduled.py +++ b/apps/app/deep_next/app/entrypoint_scheduled.py @@ -41,8 +41,9 @@ def cli(interval_s: int): if __name__ == "__main__": - from deep_next.common.common import load_monorepo_dotenv + from deep_next.common.common import load_monorepo_dotenv, setup_logging load_monorepo_dotenv() + setup_logging() cli() diff --git a/libs/common/deep_next/common/common.py b/libs/common/deep_next/common/common.py index 7486d8d..b415a27 100644 --- a/libs/common/deep_next/common/common.py +++ b/libs/common/deep_next/common/common.py @@ -1,3 +1,5 @@ +import os +import sys import textwrap from dotenv import load_dotenv @@ -60,3 +62,20 @@ def prepare_issue_statement( {issue_comments_str} """ ) + + +def setup_logging() -> None: + """ + Configure Loguru logging for the application. + + This function sets up Loguru to use the log level specified by the LOG_LEVEL + environment variable (default: INFO). It removes all existing Loguru handlers + to prevent duplicate or conflicting outputs, then adds a single handler that + outputs to stdout at the configured log level. This ensures consistent logging + behavior across the application and allows dynamic adjustment of verbosity + through the LOG_LEVEL environment variable. + """ + log_level = os.environ.get("LOG_LEVEL", "INFO").upper() + logger.remove() + logger.add(sys.stdout, level=log_level) + logger.debug(f"Loguru logging configured. LOG_LEVEL={log_level}") diff --git a/libs/core/deep_next/core/entrypoint.py b/libs/core/deep_next/core/entrypoint.py index 230ba42..482e180 100644 --- a/libs/core/deep_next/core/entrypoint.py +++ b/libs/core/deep_next/core/entrypoint.py @@ -122,8 +122,9 @@ def cli( if __name__ == "__main__": - from deep_next.common.common import load_monorepo_dotenv + from deep_next.common.common import load_monorepo_dotenv, setup_logging load_monorepo_dotenv() + setup_logging() cli()