refactor(ocr): 添加日志记录以跟踪OCR文件处理

在OCR服务中添加日志记录功能,便于跟踪文件处理过程
This commit is contained in:
icarus 2025-08-23 15:51:42 +08:00
parent 31cf452974
commit 4e30d89e1c

View File

@ -1,8 +1,9 @@
import { loggerService } from '@logger'
import { isOcrApiProvider, OcrProvider, OcrResult, SupportedOcrFile } from '@renderer/types'
import { OcrApiClientFactory } from './clients/OcrApiClientFactory'
// const logger = loggerService.withContext('renderer:OcrService')
const logger = loggerService.withContext('renderer:OcrService')
/**
* ocr a file
@ -12,6 +13,7 @@ import { OcrApiClientFactory } from './clients/OcrApiClientFactory'
* @throws {Error}
*/
export const ocr = async (file: SupportedOcrFile, provider: OcrProvider): Promise<OcrResult> => {
logger.info(`ocr file ${file.path}`)
if (isOcrApiProvider(provider)) {
const client = OcrApiClientFactory.create(provider)
return client.ocr(file)