nixpkgs/pkgs/applications/office/trilium/0001-Use-console-logger-instead-of-rolling-files.patch

62 lines
1.3 KiB
Diff
Raw Normal View History

diff --git a/src/services/log.js b/src/services/log.js
2021-03-02 13:28:21 +00:00
index b4c39e99..4c249154 100644
--- a/src/services/log.js
+++ b/src/services/log.js
2021-03-02 13:28:21 +00:00
@@ -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);
-}
-
2021-03-02 13:28:21 +00:00
-let logFile = null;
-
2021-03-02 13:28:21 +00:00
const SECOND = 1000;
const MINUTE = 60 * SECOND;
const HOUR = 60 * MINUTE;
@@ -16,41 +7,7 @@ const DAY = 24 * HOUR;
2021-03-02 13:28:21 +00:00
const NEW_LINE = process.platform === "win32" ? '\r\n' : '\n';
2021-03-02 13:28:21 +00:00
-let todaysMidnight = null;
-
2021-03-02 13:28:21 +00:00
-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();
- }
-}
-
function log(str) {
- const millisSinceMidnight = Date.now() - todaysMidnight.getTime();
-
- checkDate(millisSinceMidnight);
-
- logFile.write(formatTime(millisSinceMidnight) + ' ' + str + NEW_LINE);
-
2021-03-02 13:28:21 +00:00
console.log(str);
}