// 简单测试日志写入 import * as fs from 'fs/promises'; import * as path from 'path'; async function testLogDir() { const logDir = '/mnt/code/186-175-template-22/log-prd'; const now = new Date(); const year = now.getFullYear(); const month = String(now.getMonth() + 1).padStart(2, '0'); const day = String(now.getDate()).padStart(2, '0'); const dateFolder = path.join(logDir, `${year}-${month}-${day}`); const logFile = path.join(dateFolder, 'test-service.log'); console.log('测试日志目录:', logDir); console.log('日期文件夹:', dateFolder); console.log('日志文件:', logFile); // 创建目录 await fs.mkdir(dateFolder, { recursive: true }); // 写入测试日志 const message = `[${now.toISOString()}] [INFO] 测试日志写入修复\n`; await fs.appendFile(logFile, message, 'utf8'); console.log('日志写入成功!'); console.log('请检查文件:', logFile); } testLogDir().catch(console.error);