日志优化

This commit is contained in:
Chen committed 2025-12-07 17:12:29 +08:00
1 parent fa5bb66d14
commit aeb403f3c0
21 files changed
+402 -209

No files matched your search

+5 -5
View File
@@ -41,10 +41,10 @@ class LibraryService {
// 规范化路径
const normalizedPath = path.normalize(libraryPath);
console.log(`[LibraryService] Creating library: name=${name}, path=${normalizedPath}`);
logger.system(`创建素材库: name=${name}, path=${normalizedPath}`);
if (!fs.existsSync(normalizedPath)) {
console.log(`[LibraryService] Path does not exist: ${normalizedPath}`);
logger.warn(`路径不存在: ${normalizedPath}`);
throw new ValidationError('Path does not exist', 'path');
}
@@ -59,7 +59,7 @@ class LibraryService {
fs.writeFileSync(testFile, 'test');
fs.unlinkSync(testFile);
} catch (writeError) {
console.log(`[LibraryService] No write permission: ${normalizedPath}`);
logger.warn(`无写入权限: ${normalizedPath}`);
throw new ValidationError(
'无法访问该文件夹。请在飞牛 fnOS 的"数据共享"中将此文件夹添加到 FlyPic 应用的访问权限。',
'permission'
@@ -67,7 +67,7 @@ class LibraryService {
}
} catch (readError) {
if (readError.code === 'EACCES' || readError.code === 'EPERM') {
console.log(`[LibraryService] No access permission: ${normalizedPath}`);
logger.warn(`无访问权限: ${normalizedPath}`);
throw new ValidationError(
'无法访问该文件夹。请在飞牛 fnOS 的"数据共享"中将此文件夹添加到 FlyPic 应用的访问权限。',
'permission'
@@ -186,7 +186,7 @@ class LibraryService {
try {
this.lightweightWatcher.watch(id, library.path, library.name, this.io);
} catch (e) {
console.warn('Failed to start file watcher:', e.message);
logger.warn('启动文件监控失败:', e.message);
}
}