-
Notifications
You must be signed in to change notification settings - Fork 17
sentry #148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sentry #148
Conversation
There was a problem hiding this 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 pull request updates exception handling throughout the codebase to improve error logging by replacing logger.error with logger.exception in exception handlers, ensuring full stack traces are logged. The PR also modifies the Sentry integration in main.py to use LoguruIntegration for better log capture.
Changes:
- Replaced
logger.errorwithlogger.exceptionsystematically across ~500+ locations in exception handlers - Updated Sentry integration to use LoguruIntegration instead of manual message capture
- Added
before_sendfilter to only send events with exception information to Sentry
Reviewed changes
Copilot reviewed 75 out of 75 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| main.py | Updated Sentry integration and changed 2 logging calls (1 critical issue found) |
| app/common/* | Systematic logging updates across IPC, voice, history, data, extraction modules |
| app/view/* | Logging updates in settings, main views, floating windows, and dialogs |
| app/tools/* | Logging updates in utility modules for config, settings, updates, language |
| app/core/* | Logging updates in core application modules |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| if not local_server: | ||
| logger.error("无法启动本地服务器,程序将退出") | ||
| logger.exception("无法启动本地服务器,程序将退出") |
Copilot
AI
Jan 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using logger.exception() outside of an exception handler will cause an error. This code is not within a try-except block, so when local_server is None/False, calling logger.exception() will fail because there's no active exception to log. This should remain as logger.error() or be wrapped in a try-except block.
|
|
||
| if not self.security_verifier: | ||
| logger.error("安全验证器未配置") | ||
| logger.exception("安全验证器未配置") |
Copilot
AI
Jan 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using logger.exception() outside of an exception handler will cause an error. This code is not within a try-except block, so calling logger.exception() when self.security_verifier is None/False will fail because there's no active exception to log. This should remain as logger.error() since it's a configuration issue, not an exception being caught.
| logger.exception("安全验证器未配置") | |
| logger.error("安全验证器未配置") |
|
|
||
| except Exception as e: | ||
| logger.error(f"应用平均值差值保护时发生错误: {e}", exc_info=True) | ||
| logger.exception(f"应用平均值差值保护时发生错误: {e}", exc_info=True) |
Copilot
AI
Jan 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant exc_info=True parameter. When using logger.exception(), the exception information is automatically included in the log output. The exc_info=True parameter is redundant and should be removed.
| logger.exception(f"应用平均值差值保护时发生错误: {e}", exc_info=True) | |
| logger.exception(f"应用平均值差值保护时发生错误: {e}") |
| has_perm = True # 实际实现时替换为真实权限检查 | ||
| if not has_perm: | ||
| logger.error(f"权限不足,无法执行 {func.__name__}") | ||
| logger.exception(f"权限不足,无法执行 {func.__name__}") |
Copilot
AI
Jan 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This statement is unreachable.
This pull request updates exception handling throughout the codebase to improve error logging. Specifically, it replaces
logger.errorwithlogger.exceptionin multiple files and functions. This change ensures that full stack traces are logged whenever exceptions occur, making debugging easier and providing more context for failures.Logging Improvements:
logger.errorwithlogger.exceptionin all exception handlers in the following modules:app/common/IPC_URL/protocol_manager.py[1] [2] [3] [4] [5] [6] [7] [8]app/common/IPC_URL/csharp_ipc_handler.py[1] [2] [3] [4] [5]app/common/IPC_URL/security_verifier.py[1] [2]app/common/IPC_URL/url_command_handler.py[1] [2] [3] [4] [5] [6] [7]app/common/IPC_URL/url_ipc_handler.py[1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11]app/common/behind_scenes/behind_scenes_utils.pyapp/Language/obtain_language.pyImpact: