refactor: 移除冗余日志记录,优化代码可读性

This commit is contained in:
kuaifan 2026-01-14 09:41:06 +00:00
parent 3a2b7b1400
commit dd20711c04
6 changed files with 4 additions and 55 deletions

View File

@ -158,10 +158,9 @@ class ManticoreBase
) charset_table='non_cjk, cjk' morphology='icu_chinese'
");
Log::info('Manticore tables initialized successfully');
// Tables initialized successfully
} catch (PDOException $e) {
Log::warning('Manticore initialization warning: ' . $e->getMessage());
// 不抛出异常,表可能已存在
// 表可能已存在,忽略初始化错误
}
}
@ -2040,8 +2039,7 @@ class ManticoreBase
if ($instance->execute($stmt['sql'], $stmt['values'])) {
$successCount++;
} else {
// 插入失败,记录日志(数据已被删除,需要重新同步)
Log::warning("Manticore batch update failed for {$table}", ['pk' => $stmt['pk']]);
// 插入失败,数据已被删除,需要重新同步
}
}
@ -2110,7 +2108,7 @@ class ManticoreBase
return $result['data'] ?? [];
}
} catch (\Exception $e) {
Log::warning('Get embedding error: ' . $e->getMessage());
// embedding 获取失败,返回空数组
}
return [];

View File

@ -235,7 +235,6 @@ class ManticoreFile
// 根据文件类型检查大小限制
$maxSize = self::getMaxFileSizeByExt($file->ext);
if ($file->size > $maxSize) {
Log::info("Manticore: Skip large file {$file->id} ({$file->size} bytes, max: {$maxSize})");
// 删除可能存在的旧索引(文件更新后可能超限)
self::delete($file->id);
return true;
@ -546,7 +545,6 @@ class ManticoreFile
// 4. 批量获取 embedding
$result = AI::getBatchEmbeddings($texts);
if (!Base::isSuccess($result) || empty($result['data'])) {
Log::warning('ManticoreFile: Batch embedding failed', ['file_ids' => $ids]);
continue;
}
@ -565,13 +563,6 @@ class ManticoreFile
if (!empty($vectorData)) {
$batchCount = ManticoreBase::batchUpdateFileVectors($vectorData);
$successCount += $batchCount;
if ($batchCount < count($vectorData)) {
Log::warning('ManticoreFile: Some vector updates failed', [
'expected' => count($vectorData),
'actual' => $batchCount,
]);
}
}
}

View File

@ -460,10 +460,6 @@ class ManticoreMsg
$result = AI::getBatchEmbeddings($texts);
if (Base::isError($result)) {
Log::warning('ManticoreMsg: Batch embedding failed', [
'msg_ids' => $idsArray,
'error' => $result['msg'] ?? 'Unknown error',
]);
continue;
}
@ -488,13 +484,6 @@ class ManticoreMsg
if (!empty($vectorData)) {
$batchCount = ManticoreBase::batchUpdateMsgVectors($vectorData);
$count += $batchCount;
if ($batchCount < count($vectorData)) {
Log::warning('ManticoreMsg: Some vector updates failed', [
'expected' => count($vectorData),
'actual' => $batchCount,
]);
}
}
}

View File

@ -339,7 +339,6 @@ class ManticoreProject
// 4. 批量获取 embedding
$result = AI::getBatchEmbeddings($texts);
if (!Base::isSuccess($result) || empty($result['data'])) {
Log::warning('ManticoreProject: Batch embedding failed', ['project_ids' => $ids]);
continue;
}
@ -358,13 +357,6 @@ class ManticoreProject
if (!empty($vectorData)) {
$batchCount = ManticoreBase::batchUpdateProjectVectors($vectorData);
$successCount += $batchCount;
if ($batchCount < count($vectorData)) {
Log::warning('ManticoreProject: Some vector updates failed', [
'expected' => count($vectorData),
'actual' => $batchCount,
]);
}
}
}

View File

@ -144,10 +144,6 @@ class ManticoreTask
{
// 防止无限递归深度超过10层或循环引用
if ($depth > 10 || in_array($task->id, $visited)) {
Log::warning('ManticoreTask: getAllowedUsers recursion limit reached', [
'task_id' => $task->id,
'depth' => $depth,
]);
return [];
}
$visited[] = $task->id;
@ -280,7 +276,6 @@ class ManticoreTask
// 限制内容长度
return mb_substr($text, 0, self::MAX_CONTENT_LENGTH);
} catch (\Exception $e) {
Log::warning('Get task content error: ' . $e->getMessage(), ['task_id' => $task->id]);
return '';
}
}
@ -568,7 +563,6 @@ class ManticoreTask
// 4. 批量获取 embedding
$result = AI::getBatchEmbeddings($texts);
if (!Base::isSuccess($result) || empty($result['data'])) {
Log::warning('ManticoreTask: Batch embedding failed', ['task_ids' => $ids]);
continue;
}
@ -587,13 +581,6 @@ class ManticoreTask
if (!empty($vectorData)) {
$batchCount = ManticoreBase::batchUpdateTaskVectors($vectorData);
$successCount += $batchCount;
if ($batchCount < count($vectorData)) {
Log::warning('ManticoreTask: Some vector updates failed', [
'expected' => count($vectorData),
'actual' => $batchCount,
]);
}
}
}

View File

@ -331,7 +331,6 @@ class ManticoreUser
// 4. 批量获取 embedding
$result = AI::getBatchEmbeddings($texts);
if (!Base::isSuccess($result) || empty($result['data'])) {
Log::warning('ManticoreUser: Batch embedding failed', ['user_ids' => $ids]);
continue;
}
@ -350,13 +349,6 @@ class ManticoreUser
if (!empty($vectorData)) {
$batchCount = ManticoreBase::batchUpdateUserVectors($vectorData);
$successCount += $batchCount;
if ($batchCount < count($vectorData)) {
Log::warning('ManticoreUser: Some vector updates failed', [
'expected' => count($vectorData),
'actual' => $batchCount,
]);
}
}
}