mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-27 03:50:12 +03:00
catch createWriteStream error
This commit is contained in:
parent
d7f7dba13f
commit
d4c9431142
1 changed files with 13 additions and 7 deletions
|
@ -335,17 +335,23 @@ exports.convertToUTF8 = (body) => {
|
||||||
return str.toString();
|
return str.toString();
|
||||||
};
|
};
|
||||||
|
|
||||||
let logFile = fs.createWriteStream("./data/error.log", {
|
let logFile;
|
||||||
flags: "a"
|
|
||||||
});
|
try {
|
||||||
|
logFile = fs.createWriteStream("./data/error.log", {
|
||||||
|
flags: "a"
|
||||||
|
});
|
||||||
|
} catch (_) { }
|
||||||
|
|
||||||
exports.errorLog = (error, outputToConsole = true) => {
|
exports.errorLog = (error, outputToConsole = true) => {
|
||||||
try {
|
try {
|
||||||
const dateTime = R.isoDateTime();
|
if (logFile) {
|
||||||
logFile.write(`[${dateTime}] ` + nodeJsUtil.format(error) + "\n");
|
const dateTime = R.isoDateTime();
|
||||||
|
logFile.write(`[${dateTime}] ` + nodeJsUtil.format(error) + "\n");
|
||||||
|
|
||||||
if (outputToConsole) {
|
if (outputToConsole) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (_) { }
|
} catch (_) { }
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue