Skip to content

Conversation

@davassi
Copy link
Owner

@davassi davassi commented Nov 29, 2025

No description provided.

@davassi davassi requested a review from Copilot November 29, 2025 17:29
@davassi davassi merged commit ff4a397 into master Nov 29, 2025
6 checks passed
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a configure_logging function to centralize log level configuration across uvicorn and application loggers, addressing issues with logging setup.

  • Introduces configure_logging function in hypertrade/logging.py to set log levels for uvicorn and app loggers
  • Calls configure_logging during app initialization in hypertrade/daemon.py to apply settings
  • Validates log levels with fallback to "INFO" for invalid values

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
hypertrade/logging.py Adds new configure_logging function to configure log levels for uvicorn and hypertrade loggers
hypertrade/daemon.py Imports and calls configure_logging during daemon initialization to apply log level settings

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +20 to +24
valid_levels = {"CRITICAL", "ERROR", "WARNING", "INFO", "DEBUG", "NOTSET"}

if level not in valid_levels:
level = "INFO"

Copy link

Copilot AI Nov 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The validation logic here is redundant. The log_level parameter is already validated and normalized by the _normalize_level field validator in hypertrade/config.py (lines 94-99), which ensures that only valid log levels reach this function. This duplicate validation adds unnecessary complexity. Consider removing lines 19-23 and using log_level directly, or at minimum, just call .upper() without re-validation.

Suggested change
valid_levels = {"CRITICAL", "ERROR", "WARNING", "INFO", "DEBUG", "NOTSET"}
if level not in valid_levels:
level = "INFO"

Copilot uses AI. Check for mistakes.
Comment on lines +17 to +31
def configure_logging(log_level: str = "INFO") -> None:
"""Configure Python logging to use the specified level."""
level = log_level.upper()
valid_levels = {"CRITICAL", "ERROR", "WARNING", "INFO", "DEBUG", "NOTSET"}

if level not in valid_levels:
level = "INFO"

# Configure uvicorn loggers
pylog.getLogger("uvicorn").setLevel(level)
pylog.getLogger("uvicorn.access").setLevel(level)
pylog.getLogger("uvicorn.error").setLevel(level)

# Configure app logger
pylog.getLogger("hypertrade").setLevel(level)
Copy link

Copilot AI Nov 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new configure_logging function lacks test coverage. The repository has comprehensive tests for other modules (e.g., test_health.py, test_webhook.py), but this new logging configuration functionality is not tested. Consider adding tests to verify:

  • Correct log level configuration for all uvicorn and app loggers
  • Behavior with valid and invalid log levels
  • Integration with the daemon initialization

Copilot uses AI. Check for mistakes.
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.

2 participants