Skip to content

fix: 移除 enable_logging 错误拦截#1920

Open
LaoYueHanNi wants to merge 1 commit intofarion1231:mainfrom
LaoYueHanNi:fix/usage-logging
Open

fix: 移除 enable_logging 错误拦截#1920
LaoYueHanNi wants to merge 1 commit intofarion1231:mainfrom
LaoYueHanNi:fix/usage-logging

Conversation

@LaoYueHanNi
Copy link
Copy Markdown

@LaoYueHanNi LaoYueHanNi commented Apr 6, 2026

问题描述

使用统计(Usage Statistics)在升级到某个版本后不再记录到数据库 proxy_request_logs 表中。

问题原因

提交: bf40b01

这个提交本意是:当用户关闭"启用日志记录"开关时,跳过 HTTP请求详情的日志写入。但同时跳过了使用统计记录,导致未开启日志记录时,使用统计无法记录。

问题代码

src-tauri/src/proxy/response_processor.rs 中有两处问题代码:

1. 流式响应处理(第 283-302 行):
SseUsageCollector::new(start_time, move |events, first_token_ms| {
    if !logging_enabled {
        return;  // 错误:同时跳过了使用统计记录
    }
    // ...
});

2. 非流式响应处理(第 366-371 行):
fn spawn_log_usage(...) {
    if let Ok(config) = state.config.try_read() {
        if !config.enable_logging {
            return;  // 错误:同时跳过了使用统计记录
        }
    }
    // ...
}

修复内容

  1. 移除 enable_logging 检查:删除 response_processor.rs 中两处对 enable_logging
    的检查,让使用统计始终记录,不受日志开关影响

测试计划

  • 关闭"启用日志记录"开关,验证使用统计仍能正常记录
  • 开启"启用日志记录"开关,验证使用统计能正常记录
  • 验证数据库 proxy_request_logs 表中有数据
  • 已通过 cargo test proxy --lib 测试 (296 passed)

@LaoYueHanNi
Copy link
Copy Markdown
Author

LaoYueHanNi commented Apr 6, 2026

失误关闭的PR 操作失误把上个pr关闭了,现在已rebase好重新提交。

@yovinchen
Copy link
Copy Markdown
Collaborator

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0393e08d3c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

问题描述:
- 使用统计(Usage Statistics)在关闭"启用日志记录"开关后不再记录到数据库
- 这是因为 bf40b01 提交错误地同时跳过了使用统计记录

修复内容:
- 移除 response_processor.rs 中两处对 enable_logging 的检查,让使用统计始终记录
@LaoYueHanNi LaoYueHanNi changed the title fix: 移除 enable_logging 错误拦截并使配置实时生效 fix: 移除 enable_logging 错误拦截 Apr 7, 2026
@farion1231
Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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.

3 participants