python312Packages.types-aiobotocore: 2.15.2 -> 2.15.2.post3 (#361801)
[NixPkgs.git] / pkgs / applications / office / trilium / 0001-Use-console-logger-instead-of-rolling-files.patch
blob68f203b464b2b0ceeecd7a07c78f7015e42e7e87
1 diff --git a/src/services/log.js b/src/services/log.js
2 index a141eae14..094b9381b 100644
3 --- a/src/services/log.js
4 +++ b/src/services/log.js
5 @@ -1,15 +1,7 @@
6 "use strict";
8 -const fs = require('fs');
9 -const dataDir = require('./data_dir.js');
10 const cls = require('./cls.js');
12 -if (!fs.existsSync(dataDir.LOG_DIR)) {
13 - fs.mkdirSync(dataDir.LOG_DIR, 0o700);
16 -let logFile = null;
18 const SECOND = 1000;
19 const MINUTE = 60 * SECOND;
20 const HOUR = 60 * MINUTE;
21 @@ -17,38 +9,6 @@ const DAY = 24 * HOUR;
23 const NEW_LINE = process.platform === "win32" ? '\r\n' : '\n';
25 -let todaysMidnight = null;
27 -initLogFile();
29 -function getTodaysMidnight() {
30 - const now = new Date();
32 - return new Date(now.getFullYear(), now.getMonth(), now.getDate());
35 -function initLogFile() {
36 - todaysMidnight = getTodaysMidnight();
38 - const path = `${dataDir.LOG_DIR}/trilium-${formatDate()}.log`;
40 - if (logFile) {
41 - logFile.end();
42 - }
44 - logFile = fs.createWriteStream(path, {flags: 'a'});
47 -function checkDate(millisSinceMidnight) {
48 - if (millisSinceMidnight >= DAY) {
49 - initLogFile();
51 - millisSinceMidnight -= DAY;
52 - }
54 - return millisSinceMidnight;
57 function log(str) {
58 const bundleNoteId = cls.get("bundleNoteId");
60 @@ -56,12 +16,6 @@ function log(str) {
61 str = `[Script ${bundleNoteId}] ${str}`;
64 - let millisSinceMidnight = Date.now() - todaysMidnight.getTime();
66 - millisSinceMidnight = checkDate(millisSinceMidnight);
68 - logFile.write(`${formatTime(millisSinceMidnight)} ${str}${NEW_LINE}`);
70 console.log(str);