增加日志忽略记录,美化日志显示
This commit is contained in:
@@ -71,8 +71,17 @@ function loggerMiddleware(req, res, next) {
|
||||
// 过滤掉健康检查请求
|
||||
const isHealthCheck = req.path === '/health';
|
||||
|
||||
// 只记录重要的API请求,排除静态资源、图片代理、下载任务查询、仓库预览和健康检查
|
||||
if (!isStaticResource && !isImageProxy && !isDownloadTasksQuery && !isRepositoryPreview && !isHealthCheck) {
|
||||
// 过滤掉获取作者作品的API请求
|
||||
const isArtistArtworksQuery = /^\/api\/artist\/\d+\/artworks/.test(req.path);
|
||||
|
||||
// 过滤掉作品详情请求
|
||||
const isArtworkDetailQuery = /^\/api\/artwork\/\d+/.test(req.path);
|
||||
|
||||
// 过滤掉仓库下载检查请求
|
||||
const isRepositoryCheckDownloadedQuery = /^\/api\/repository\/check-downloaded\/\d+/.test(req.path);
|
||||
|
||||
// 只记录重要的API请求,排除静态资源、图片代理、下载任务查询、仓库预览、健康检查、作者作品查询、作品详情和仓库下载检查
|
||||
if (!isStaticResource && !isImageProxy && !isDownloadTasksQuery && !isRepositoryPreview && !isHealthCheck && !isArtistArtworksQuery && !isArtworkDetailQuery && !isRepositoryCheckDownloadedQuery) {
|
||||
const start = Date.now();
|
||||
|
||||
// 原始响应结束方法
|
||||
|
||||
@@ -201,7 +201,7 @@ class ArtistService {
|
||||
limit,
|
||||
};
|
||||
|
||||
logger.info(`请求关注列表: offset=${currentOffset}, limit=${limit}`);
|
||||
// logger.info(`请求关注列表: offset=${currentOffset}, limit=${limit}`);
|
||||
const response = await this.makeRequest('GET', `/v1/user/following?${stringify(params)}`);
|
||||
|
||||
// 转换数据格式以匹配前端期望
|
||||
@@ -214,12 +214,12 @@ class ArtistService {
|
||||
}));
|
||||
|
||||
allArtists.push(...artists);
|
||||
logger.info(`本次获取到 ${artists.length} 个作者,累计 ${allArtists.length} 个`);
|
||||
// logger.info(`本次获取到 ${artists.length} 个作者,累计 ${allArtists.length} 个`);
|
||||
|
||||
// 如果返回的数量少于limit,说明已经获取完所有数据
|
||||
if (artists.length < limit) {
|
||||
hasMore = false;
|
||||
logger.info('已获取完所有关注的作者');
|
||||
logger.info(`已获取完所有关注的作者, 共 ${allArtists.length} 个`);
|
||||
} else {
|
||||
currentOffset += artists.length;
|
||||
}
|
||||
@@ -382,7 +382,7 @@ class ArtistService {
|
||||
if (method === 'GET') {
|
||||
try {
|
||||
await this.apiCache.set(method, endpoint, data || {}, responseData);
|
||||
logger.info(`API缓存已保存: ${method} ${endpoint}`);
|
||||
// logger.info(`API缓存已保存: ${method} ${endpoint}`);
|
||||
} catch (error) {
|
||||
logger.error('保存API缓存失败:', error);
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ const ModuleColors = {
|
||||
'PixivBackend': '\x1b[35m', // 紫色
|
||||
'PixivAuth': '\x1b[36m', // 青色
|
||||
'TaskManager': '\x1b[33m', // 黄色
|
||||
'ImageCache': '\x1b[37m', // 白色
|
||||
'ImageCache': '\x1b[92m', // 亮绿色
|
||||
'HistoryManager': '\x1b[90m', // 灰色
|
||||
'ProxyConfig': '\x1b[95m', // 亮紫色
|
||||
'Download': '\x1b[93m', // 亮黄色
|
||||
@@ -52,8 +52,12 @@ const ModuleColors = {
|
||||
'Artist': '\x1b[92m', // 亮绿色
|
||||
'Repository': '\x1b[94m', // 亮蓝色
|
||||
'ErrorHandler': '\x1b[91m', // 亮红色
|
||||
'FileManager': '\x1b[98m', // 亮青色
|
||||
'ProgressManager': '\x1b[99m', // 亮紫色
|
||||
'FileManager': '\x1b[36m', // 青色
|
||||
'ProgressManager': '\x1b[35m', // 紫色
|
||||
'WatchlistManager': '\x1b[94m', // 亮蓝色
|
||||
'UpdateRoute': '\x1b[93m', // 亮黄色
|
||||
'ArtistService': '\x1b[95m', // 亮紫色
|
||||
'DownloadService': '\x1b[96m', // 亮青色
|
||||
'Default': '\x1b[39m' // 默认颜色
|
||||
};
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
"start": "node backend/start.js",
|
||||
"dev": "node backend/start.js",
|
||||
"test": "node backend/test-login.js",
|
||||
"set-proxy": "node backend/set-proxy.js",
|
||||
"build": "pkg . && node scripts/add-icon.js",
|
||||
"bp": "npm run build && node scripts/create-portable.js"
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user