Skip to content

Commit

Permalink
fix(debug): Make log file not crash the entire instance if it can't b…
Browse files Browse the repository at this point in the history
…e created
  • Loading branch information
tecc committed Nov 9, 2022
1 parent 53f1817 commit cf5e666
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions libs/server/debugging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,20 @@ function getLogFile(name: string) {
}

const loggerTransport: Parameters<typeof pino.multistream>[0] = [
{
stream: fs.createWriteStream(getLogFile('debug'), { flags: 'a' }),
level: "debug"
},
{
stream: pinoPretty(),
level: "info"
}
];
try {
loggerTransport.push({
stream: fs.createWriteStream(getLogFile('debug'), { flags: 'a' }),
level: "debug"
});
} catch (e) {
// well, whoops!
console.warn("No file logs: %O", e);
}

const multistream = pino.multistream(loggerTransport);

Expand Down

0 comments on commit cf5e666

Please sign in to comment.