同步失败原因,最近同步成功的时间记录

This commit is contained in:
root
2026-06-20 05:07:11 +08:00
parent d5a0ffa6db
commit e95f4a227c
19 changed files with 884 additions and 74 deletions
@@ -7,7 +7,9 @@ namespace app\common\service;
use think\Config;
/**
* 工单云控同步调试日志(仅 app_debug=true 时写入 runtime/log/split_sync.log
* 工单云控同步日志
* - logCron:定时任务汇总,app_debug 关闭时也写入 runtime/log/split_sync.log
* - log:详细调试日志,仅 app_debug=true 时写入
*/
class SplitTicketSyncLogger
{
@@ -36,6 +38,18 @@ class SplitTicketSyncLogger
}
/**
* 定时任务汇总日志(始终写入)
*
* @param array<string, mixed> $context
*/
public static function logCron(string $message, array $context = []): void
{
self::writeLine('cron', $message, $context);
}
/**
* 详细调试日志(仅 app_debug=true
*
* @param array<string, mixed> $context
*/
public static function log(string $stage, string $message, array $context = []): void
@@ -43,7 +57,14 @@ class SplitTicketSyncLogger
if (!self::isEnabled()) {
return;
}
self::writeLine($stage, $message, $context);
}
/**
* @param array<string, mixed> $context
*/
private static function writeLine(string $stage, string $message, array $context = []): void
{
$context = self::sanitize($context);
$ctxJson = $context !== [] ? ' ' . json_encode($context, JSON_UNESCAPED_UNICODE) : '';
$line = sprintf(
@@ -83,8 +104,8 @@ class SplitTicketSyncLogger
$out[$key] = self::sanitize($value);
continue;
}
if (is_string($value) && mb_strlen($value) > 800) {
$out[$key] = mb_substr($value, 0, 800, 'UTF-8') . '...(truncated)';
if (is_string($value) && mb_strlen($value) > 2000) {
$out[$key] = mb_substr($value, 0, 2000, 'UTF-8') . '...(truncated)';
continue;
}
$out[$key] = $value;