nixpkgs/pkgs/applications/office/trilium/0001-Use-console-logger-instead-of-rolling-files.patch
2021-06-05 14:10:44 +02:00

65 lines
1.4 KiB
Diff

diff --git a/src/services/log.js b/src/services/log.js
index 1345ce39..a9770516 100644
--- a/src/services/log.js
+++ b/src/services/log.js
@@ -1,14 +1,5 @@
"use strict";
-const fs = require('fs');
-const dataDir = require('./data_dir');
-
-if (!fs.existsSync(dataDir.LOG_DIR)) {
- fs.mkdirSync(dataDir.LOG_DIR, 0o700);
-}
-
-let logFile = null;
-
const SECOND = 1000;
const MINUTE = 60 * SECOND;
const HOUR = 60 * MINUTE;
@@ -16,45 +7,7 @@ const DAY = 24 * HOUR;
const NEW_LINE = process.platform === "win32" ? '\r\n' : '\n';
-let todaysMidnight = null;
-
-initLogFile();
-
-function getTodaysMidnight() {
- const now = new Date();
-
- return new Date(now.getFullYear(), now.getMonth(), now.getDate());
-}
-
-function initLogFile() {
- todaysMidnight = getTodaysMidnight();
-
- const path = dataDir.LOG_DIR + '/trilium-' + formatDate() + '.log';
-
- if (logFile) {
- logFile.end();
- }
-
- logFile = fs.createWriteStream(path, {flags: 'a'});
-}
-
-function checkDate(millisSinceMidnight) {
- if (millisSinceMidnight >= DAY) {
- initLogFile();
-
- millisSinceMidnight =- DAY;
- }
-
- return millisSinceMidnight;
-}
-
function log(str) {
- let millisSinceMidnight = Date.now() - todaysMidnight.getTime();
-
- millisSinceMidnight = checkDate(millisSinceMidnight);
-
- logFile.write(formatTime(millisSinceMidnight) + ' ' + str + NEW_LINE);
-
console.log(str);
}