Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
logging current time with console.logs on frontend
azivner3edbb65b0f34
diff --git a/public/javascripts/messaging.js b/public/javascripts/messaging.jsindex d22dd53974..eca8aacd1d 100644--- a/public/javascripts/messaging.js+++ b/public/javascripts/messaging.js@@ -5,7 +5,7 @@ const messaging = (function() {let ws = null;function logError(message) {- console.log(message); // needs to be separate from .trace()+ console.log(now(), message); // needs to be separate from .trace()console.trace();if (ws && ws.readyState === 1) {@@ -24,11 +24,11 @@ const messaging = (function() {const syncData = message.data.filter(sync => sync.source_id !== glob.sourceId);if (syncData.length > 0) {- console.log("Sync data: ", message);+ console.log(now(), "Sync data: ", message);}if (syncData.some(sync => sync.entity_name === 'notes_tree')) {- console.log("Reloading tree because of background changes");+ console.log(now(), "Reloading tree because of background changes");noteTree.reload();}@@ -40,7 +40,7 @@ const messaging = (function() {}if (syncData.some(sync => sync.entity_name === 'recent_notes')) {- console.log("Reloading recent notes because of background changes");+ console.log(now(), "Reloading recent notes because of background changes");recentNotes.reload();}@@ -60,7 +60,7 @@ const messaging = (function() {// use wss for secure messagingws = new WebSocket(protocol + "://" + location.host);- ws.onopen = event => console.log("Connected to server with WebSocket");+ ws.onopen = event => console.log(now(), "Connected to server with WebSocket");ws.onmessage = messageHandler;ws.onclose = function(){// Try to reconnect in 5 secondsdiff --git a/public/javascripts/note_tree.js b/public/javascripts/note_tree.jsindex d53f1fbee8..87c3e8dd9f 100644--- a/public/javascripts/note_tree.js+++ b/public/javascripts/note_tree.js@@ -204,7 +204,7 @@ const noteTree = (function() {let parentNoteId = 'root';- console.log("Run path: ", runPath);+ //console.log(now(), "Run path: ", runPath);for (const childNoteId of runPath) {const node = getNodesByNoteId(childNoteId).find(node => node.data.note_pid === parentNoteId);@@ -248,7 +248,7 @@ const noteTree = (function() {}if (!parents.includes(parentNoteId)) {- console.log("Did not find parent " + parentNoteId + " for child " + childNoteId);+ console.log(now(), "Did not find parent " + parentNoteId + " for child " + childNoteId);if (parents.length > 0) {const pathToRoot = getSomeNotePath(parents[0]).split("/").reverse();diff --git a/public/javascripts/server.js b/public/javascripts/server.jsindex f1173bb7fe..d5e452964a 100644--- a/public/javascripts/server.js+++ b/public/javascripts/server.js@@ -40,7 +40,7 @@ const server = (function() {return new Promise((resolve, reject) => {reqResolves[requestId] = resolve;- console.log("Request #" + requestId + " to " + method + " " + url);+ console.log(now(), "Request #" + requestId + " to " + method + " " + url);ipc.send('server-request', {requestId: requestId,@@ -60,7 +60,7 @@ const server = (function() {const ipc = require('electron').ipcRenderer;ipc.on('server-response', (event, arg) => {- console.log("Response #" + arg.requestId + ": " + arg.statusCode);+ console.log(now(), "Response #" + arg.requestId + ": " + arg.statusCode);reqResolves[arg.requestId](arg.body);diff --git a/public/javascripts/utils.js b/public/javascripts/utils.jsindex bf3ae997a3..3c17a4269c 100644--- a/public/javascripts/utils.js+++ b/public/javascripts/utils.js@@ -5,7 +5,7 @@ function reloadApp() {}function showMessage(message) {- console.log("message: ", message);+ console.log(now(), "message: ", message);$.notify({// options@@ -18,7 +18,7 @@ function showMessage(message) {}function showError(message, delay = 10000) {- console.log("error: ", message);+ console.log(now(), "error: ", message);$.notify({// options@@ -53,6 +53,10 @@ function formatTime(date) {return padNum(date.getHours()) + ":" + padNum(date.getMinutes());}+function formatTimeWithSeconds(date) {+ return padNum(date.getHours()) + ":" + padNum(date.getMinutes()) + ":" + padNum(date.getSeconds());+}+function formatDate(date) {return padNum(date.getDate()) + ". " + padNum(date.getMonth() + 1) + ". " + date.getFullYear();}@@ -61,6 +65,10 @@ function formatDateTime(date) {return formatDate(date) + " " + formatTime(date);}+function now() {+ return formatTimeWithSeconds(new Date());+}+function isElectron() {return window && window.process && window.process.type;}\ No newline at end of file