feat(data-sync): implement logging for data synchronization process

- Added logging functionality to the DataSyncService to track progress and errors during the manifest generation process.
- Introduced DataSyncLogLevel and DataSyncLogPayload types for structured logging.
- Updated emitLog method to handle different log levels (info, success, warn, error) and include relevant details.
- Enhanced PhotoSyncProgressState to maintain a log of synchronization events, displayed in the PhotoSyncProgressPanel.

Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
Innei
2025-11-13 00:42:43 +08:00
parent 42c217e2f8
commit ff73de44c8
6 changed files with 244 additions and 7 deletions

View File

@@ -14,6 +14,9 @@ import type { PickedExif } from '../types/photo.js'
export async function extractExifData(imageBuffer: Buffer, originalBuffer?: Buffer): Promise<PickedExif | null> {
const log = getGlobalLoggers().exif
await mkdir('/tmp/image_process', { recursive: true })
const tempImagePath = path.resolve('/tmp/image_process', `${crypto.randomUUID()}.jpg`)
try {
log.info('开始提取 EXIF 数据')
@@ -35,15 +38,10 @@ export async function extractExifData(imageBuffer: Buffer, originalBuffer?: Buff
return null
}
await mkdir('/tmp/image_process', { recursive: true })
const tempImagePath = path.resolve('/tmp/image_process', `${crypto.randomUUID()}.jpg`)
await writeFile(tempImagePath, originalBuffer || imageBuffer)
const exifData = await exiftool.read(tempImagePath)
const result = handleExifData(exifData, metadata)
await unlink(tempImagePath).catch(noop)
if (!exifData) {
log.warn('EXIF 数据解析失败')
return null
@@ -59,6 +57,8 @@ export async function extractExifData(imageBuffer: Buffer, originalBuffer?: Buff
} catch (error) {
log.error('提取 EXIF 数据失败:', error)
return null
} finally {
await unlink(tempImagePath).catch(noop)
}
}