logs: escape and unescape new lines

This commit is contained in:
Girish Ramakrishnan
2026-04-07 12:54:31 +02:00
parent 20e0774df2
commit 9e20c5a3e3
9 changed files with 25 additions and 10 deletions

View File

@@ -59,7 +59,8 @@ async function start() {
try {
fs.mkdirSync(appLogDir, { recursive: true });
fs.appendFileSync(`${appLogDir}/app.log`, `${info.timestamp} ${info.message.trim()}\n`);
const escaped = info.message.trim().replace(/\\/g, '\\\\').replace(/\n/g, '\\n');
fs.appendFileSync(`${appLogDir}/app.log`, `${info.timestamp} ${escaped}\n`);
} catch (error) {
log(error);
}