feat(sync): 优化日志格式和进度记录逻辑

This commit is contained in:
yuxuanhui
2026-08-09 09:44:46 +08:00
parent 9c1a1eac23
commit aed8948b79
4 changed files with 53 additions and 8 deletions
@@ -425,8 +425,7 @@ class SyncMarketData:
failure = self._failure("daily_basic", key, exc)
failures.append(failure)
logger.warning(
"market_data_sync_item_failed batch_id=%s stage=daily_basic item=%s "
"error_type=%s",
"market_data_sync_item_failed batch_id=%s stage=daily_basic item=%s error_type=%s",
batch_id,
key,
failure.error_type,
@@ -520,10 +519,16 @@ class SyncMarketData:
) -> None:
"""Log bounded, secret-free progress for a batch stage."""
if not force and total > _PROGRESS_LOG_INTERVAL and current not in {
1,
total,
} and current % _PROGRESS_LOG_INTERVAL != 0:
if (
not force
and total > _PROGRESS_LOG_INTERVAL
and current
not in {
1,
total,
}
and current % _PROGRESS_LOG_INTERVAL != 0
):
return
logger.info(
"market_data_sync_progress batch_id=%s stage=%s progress=%d/%d item=%s "
@@ -190,8 +190,7 @@ def test_sync_logs_progress_for_initialize_and_daily_update(
assert initialize.status == "success"
assert any("stage=daily_basic" in message for message in initialize_messages)
assert any(
"stage=bar" in message and "progress=1/1" in message
for message in initialize_messages
"stage=bar" in message and "progress=1/1" in message for message in initialize_messages
)
caplog.clear()