mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-12-24 08:00:18 -06:00
catch createWriteStream error
This commit is contained in:
parent
d7f7dba13f
commit
d4c9431142
@ -335,17 +335,23 @@ exports.convertToUTF8 = (body) => {
|
||||
return str.toString();
|
||||
};
|
||||
|
||||
let logFile = fs.createWriteStream("./data/error.log", {
|
||||
let logFile;
|
||||
|
||||
try {
|
||||
logFile = fs.createWriteStream("./data/error.log", {
|
||||
flags: "a"
|
||||
});
|
||||
} catch (_) { }
|
||||
|
||||
exports.errorLog = (error, outputToConsole = true) => {
|
||||
try {
|
||||
if (logFile) {
|
||||
const dateTime = R.isoDateTime();
|
||||
logFile.write(`[${dateTime}] ` + nodeJsUtil.format(error) + "\n");
|
||||
|
||||
if (outputToConsole) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
} catch (_) { }
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user