Skip to content

Conversation

@WSXYT
Copy link
Collaborator

@WSXYT WSXYT commented Jan 11, 2026

This pull request updates exception handling throughout the codebase to improve error logging. Specifically, it replaces logger.error with logger.exception in 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:

  • Replaced logger.error with logger.exception in all exception handlers in the following modules:

Impact:

  • Full stack traces will now be included in the logs when exceptions are caught, improving the ability to diagnose and fix issues quickly.

Copilot AI review requested due to automatic review settings January 11, 2026 06:02
@lzy98276 lzy98276 merged commit ca4166f into SECTL:master Jan 11, 2026
10 of 11 checks passed
Copy link
Contributor

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 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.error with logger.exception systematically across ~500+ locations in exception handlers
  • Updated Sentry integration to use LoguruIntegration instead of manual message capture
  • Added before_send filter 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("无法启动本地服务器,程序将退出")
Copy link

Copilot AI Jan 11, 2026

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.

Copilot uses AI. Check for mistakes.

if not self.security_verifier:
logger.error("安全验证器未配置")
logger.exception("安全验证器未配置")
Copy link

Copilot AI Jan 11, 2026

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.

Suggested change
logger.exception("安全验证器未配置")
logger.error("安全验证器未配置")

Copilot uses AI. Check for mistakes.

except Exception as e:
logger.error(f"应用平均值差值保护时发生错误: {e}", exc_info=True)
logger.exception(f"应用平均值差值保护时发生错误: {e}", exc_info=True)
Copy link

Copilot AI Jan 11, 2026

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.

Suggested change
logger.exception(f"应用平均值差值保护时发生错误: {e}", exc_info=True)
logger.exception(f"应用平均值差值保护时发生错误: {e}")

Copilot uses AI. Check for mistakes.
has_perm = True # 实际实现时替换为真实权限检查
if not has_perm:
logger.error(f"权限不足,无法执行 {func.__name__}")
logger.exception(f"权限不足,无法执行 {func.__name__}")
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

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

This statement is unreachable.

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