Skip to content

[DeepNext] Resolve issue #165: Make logging by default on INFO level#170

Closed
pjedlikowskistx wants to merge 1 commit intodevelopfrom
deep_next/issue_165/2025_09_25_10_04_26
Closed

[DeepNext] Resolve issue #165: Make logging by default on INFO level#170
pjedlikowskistx wants to merge 1 commit intodevelopfrom
deep_next/issue_165/2025_09_25_10_04_26

Conversation

@pjedlikowskistx
Copy link
Contributor

This is description for the MR created by DeepNext.

@pjedlikowskistx
Copy link
Contributor Author

🚧 DeepNext status update

🚀 DeepNext is onto it! Hold on...

@pjedlikowskistx
Copy link
Contributor Author

🚧 DeepNext status update

🔴 DeepNext app failed for MR #170: 1 validation error for _State
code_context
Input should be a valid dictionary or instance of ExistingCodeContext [type=model_type, input_value=[], input_type=list]
For further information visit https://errors.pydantic.dev/2.11/v/model_type

@pjedlikowskistx
Copy link
Contributor Author

🚧 DeepNext status update

🚀 DeepNext is onto it! Hold on...

@pjedlikowskistx
Copy link
Contributor Author

🚧 DeepNext status update

🔴 DeepNext app failed for MR #170: 1 validation error for _State
code_context
Input should be a valid dictionary or instance of ExistingCodeContext [type=model_type, input_value=[], input_type=list]
For further information visit https://errors.pydantic.dev/2.11/v/model_type

@pjedlikowskistx
Copy link
Contributor Author

🚧 DeepNext status update

🚀 DeepNext is onto it! Hold on...

@pjedlikowskistx
Copy link
Contributor Author

🚧 DeepNext status update

🔴 DeepNext app failed for MR #170: 1 validation error for _State
code_context
Input should be a valid dictionary or instance of ExistingCodeContext [type=model_type, input_value=[], input_type=list]
For further information visit https://errors.pydantic.dev/2.11/v/model_type

@pjedlikowskistx
Copy link
Contributor Author

🚧 DeepNext status update

🚀 DeepNext is onto it! Hold on...

@pjedlikowskistx
Copy link
Contributor Author

🚧 DeepNext status update

🔴 DeepNext app failed for MR #170: 1 validation error for _State
code_context
Input should be a valid dictionary or instance of ExistingCodeContext [type=model_type, input_value=[], input_type=list]
For further information visit https://errors.pydantic.dev/2.11/v/model_type

@pjedlikowskistx
Copy link
Contributor Author

🚧 DeepNext status update

🚀 DeepNext is onto it! Hold on...

@pjedlikowskistx
Copy link
Contributor Author

🚧 DeepNext status update

🔴 DeepNext app failed for MR #170: 1 validation error for _State
code_context
Input should be a valid dictionary or instance of ExistingCodeContext [type=model_type, input_value=[], input_type=list]
For further information visit https://errors.pydantic.dev/2.11/v/model_type

@pjedlikowskistx
Copy link
Contributor Author

🚧 DeepNext status update

🚀 DeepNext is onto it! Hold on...

@pjedlikowskistx
Copy link
Contributor Author

🚧 DeepNext status update

🔴 DeepNext app failed for MR #170: 1 validation error for _State
code_context
Input should be a valid dictionary or instance of ExistingCodeContext [type=model_type, input_value=[], input_type=list]
For further information visit https://errors.pydantic.dev/2.11/v/model_type

@pjedlikowskistx
Copy link
Contributor Author

🚧 DeepNext status update

🚀 DeepNext is onto it! Hold on...

@pjedlikowskistx
Copy link
Contributor Author

🚧 DeepNext status update

🔴 DeepNext app failed for MR #170: 1 validation error for _State
code_context
Input should be a valid dictionary or instance of ExistingCodeContext [type=model_type, input_value=[], input_type=list]
For further information visit https://errors.pydantic.dev/2.11/v/model_type

@pjedlikowskistx
Copy link
Contributor Author

🚧 DeepNext status update

🚀 DeepNext is onto it! Hold on...

1 similar comment
@pjedlikowskistx
Copy link
Contributor Author

🚧 DeepNext status update

🚀 DeepNext is onto it! Hold on...

@pjedlikowskistx
Copy link
Contributor Author

🚧 DeepNext status update

Reasoning (for context only)

### Understanding the Task & Approach
The goal is to make INFO the default logging level for the application, and allow users
to override the log level using a LOG_LEVEL environment variable. This will reduce log
verbosity by default, but still allow for more detailed logs (e.g., DEBUG) when needed
for troubleshooting.

### Project Context & Code Integration
- The project uses Loguru for logging, and logging is used in both the CLI entrypoint
(`apps/app/deep_next/app/entrypoint.py`) and the scheduled entrypoint
(`apps/app/deep_next/app/entrypoint_scheduled.py`).
- Currently, neither entrypoint configures the logging level or reads the LOG_LEVEL
environment variable.
- There are also other modules (e.g., `config.py`) that use Loguru, but do not set the
log level.

### Implementation Considerations & Trade-offs
- **Centralized Logging Configuration:** To ensure consistency, logging configuration
(including log level) should be set as early as possible in the application startup,
ideally in both entrypoints.
- **Environment Variable Support:** The LOG_LEVEL environment variable should be read,
defaulting to INFO if not set or invalid.
- **Minimal Invasiveness:** Only the entrypoints need to be updated to configure Loguru
at startup; other modules can continue to use Loguru as before.
- **Documentation:** The .env.example file should be updated to document the LOG_LEVEL
variable for user awareness.

### Final Decision
The solution will:
1. Add a utility function (e.g., in `apps/app/deep_next/app/common.py`) to configure
Loguru's log level based on LOG_LEVEL env var, defaulting to INFO.
2. Update both entrypoints to call this function at startup, before any logging occurs.
3. Update `.env.example` to document LOG_LEVEL.
This approach is simple, keeps configuration DRY, and ensures all logs respect the
desired log level.

Action Plan

What do you think about the action plan below?

[
    {
        "title": "Implement log level configuration utility",
        "description": "Add a function to `apps/app/deep_next/app/common.py` that:\n- Reads the LOG_LEVEL environment variable (defaulting to INFO if not set or invalid).\n- Configures Loguru to use the selected log level for all logs.\n- Optionally, removes any existing Loguru handlers before adding the new one to avoid duplicate logs.",
        "target_file": "Path(/deep-next/___data/app/repositories/stxnext_deep-next/apps/app/deep_next/app/common.py)"
    },
    {
        "title": "Apply log level configuration in CLI entrypoint",
        "description": "At the very start of `apps/app/deep_next/app/entrypoint.py`, import and call the log level configuration function before any logging occurs. This ensures all logs in the CLI run respect the LOG_LEVEL setting.",
        "target_file": "Path(/deep-next/___data/app/repositories/stxnext_deep-next/apps/app/deep_next/app/entrypoint.py)"
    },
    {
        "title": "Apply log level configuration in scheduled entrypoint",
        "description": "At the very start of `apps/app/deep_next/app/entrypoint_scheduled.py`, import and call the log level configuration function before any logging occurs. This ensures all logs in the scheduled run respect the LOG_LEVEL setting.",
        "target_file": "Path(/deep-next/___data/app/repositories/stxnext_deep-next/apps/app/deep_next/app/entrypoint_scheduled.py)"
    },
    {
        "title": "Document LOG_LEVEL in .env.example",
        "description": "Add a commented line to `.env.example` explaining the LOG_LEVEL variable, its default (INFO), and possible values (e.g., DEBUG, INFO, WARNING, ERROR, CRITICAL).",
        "target_file": "Path(/deep-next/___data/app/repositories/stxnext_deep-next/.env.example)"
    }
]

How to respond?

👌 To ACCEPT the action plan, respond with:

@deepnext
OK

✏️ To REQUEST CHANGES to the action plan, talk to DeepNext following the message format:

@deepnext
<message to DeepNext>

🟢 Step finished. Waiting for your response...

⏱️ DeepNext core execution time: 414 seconds.

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