mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-30 19:19:03 +01:00 
			
		
		
		
	logging current time with console.logs on frontend
This commit is contained in:
		
							parent
							
								
									1ebf9d4e56
								
							
						
					
					
						commit
						3edbb65b0f
					
				| @ -5,7 +5,7 @@ const messaging = (function() { | |||||||
|     let ws = null; |     let ws = null; | ||||||
| 
 | 
 | ||||||
|     function logError(message) { |     function logError(message) { | ||||||
|         console.log(message); // needs to be separate from .trace()
 |         console.log(now(), message); // needs to be separate from .trace()
 | ||||||
|         console.trace(); |         console.trace(); | ||||||
| 
 | 
 | ||||||
|         if (ws && ws.readyState === 1) { |         if (ws && ws.readyState === 1) { | ||||||
| @ -24,11 +24,11 @@ const messaging = (function() { | |||||||
|             const syncData = message.data.filter(sync => sync.source_id !== glob.sourceId); |             const syncData = message.data.filter(sync => sync.source_id !== glob.sourceId); | ||||||
| 
 | 
 | ||||||
|             if (syncData.length > 0) { |             if (syncData.length > 0) { | ||||||
|                 console.log("Sync data: ", message); |                 console.log(now(), "Sync data: ", message); | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             if (syncData.some(sync => sync.entity_name === 'notes_tree')) { |             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(); |                 noteTree.reload(); | ||||||
|             } |             } | ||||||
| @ -40,7 +40,7 @@ const messaging = (function() { | |||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             if (syncData.some(sync => sync.entity_name === 'recent_notes')) { |             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(); |                 recentNotes.reload(); | ||||||
|             } |             } | ||||||
| @ -60,7 +60,7 @@ const messaging = (function() { | |||||||
| 
 | 
 | ||||||
|         // use wss for secure messaging
 |         // use wss for secure messaging
 | ||||||
|         ws = new WebSocket(protocol + "://" + location.host); |         ws = 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.onmessage = messageHandler; | ||||||
|         ws.onclose = function(){ |         ws.onclose = function(){ | ||||||
|             // Try to reconnect in 5 seconds
 |             // Try to reconnect in 5 seconds
 | ||||||
|  | |||||||
| @ -204,7 +204,7 @@ const noteTree = (function() { | |||||||
| 
 | 
 | ||||||
|         let parentNoteId = 'root'; |         let parentNoteId = 'root'; | ||||||
| 
 | 
 | ||||||
|         console.log("Run path: ", runPath); |         //console.log(now(), "Run path: ", runPath);
 | ||||||
| 
 | 
 | ||||||
|         for (const childNoteId of runPath) { |         for (const childNoteId of runPath) { | ||||||
|             const node = getNodesByNoteId(childNoteId).find(node => node.data.note_pid === parentNoteId); |             const node = getNodesByNoteId(childNoteId).find(node => node.data.note_pid === parentNoteId); | ||||||
| @ -248,7 +248,7 @@ const noteTree = (function() { | |||||||
|                 } |                 } | ||||||
| 
 | 
 | ||||||
|                 if (!parents.includes(parentNoteId)) { |                 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) { |                     if (parents.length > 0) { | ||||||
|                         const pathToRoot = getSomeNotePath(parents[0]).split("/").reverse(); |                         const pathToRoot = getSomeNotePath(parents[0]).split("/").reverse(); | ||||||
|  | |||||||
| @ -40,7 +40,7 @@ const server = (function() { | |||||||
|             return new Promise((resolve, reject) => { |             return new Promise((resolve, reject) => { | ||||||
|                 reqResolves[requestId] = resolve; |                 reqResolves[requestId] = resolve; | ||||||
| 
 | 
 | ||||||
|                 console.log("Request #" + requestId + " to " + method + " " + url); |                 console.log(now(), "Request #" + requestId + " to " + method + " " + url); | ||||||
| 
 | 
 | ||||||
|                 ipc.send('server-request', { |                 ipc.send('server-request', { | ||||||
|                     requestId: requestId, |                     requestId: requestId, | ||||||
| @ -60,7 +60,7 @@ const server = (function() { | |||||||
|         const ipc = require('electron').ipcRenderer; |         const ipc = require('electron').ipcRenderer; | ||||||
| 
 | 
 | ||||||
|         ipc.on('server-response', (event, arg) => { |         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); |             reqResolves[arg.requestId](arg.body); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -5,7 +5,7 @@ function reloadApp() { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function showMessage(message) { | function showMessage(message) { | ||||||
|     console.log("message: ", message); |     console.log(now(), "message: ", message); | ||||||
| 
 | 
 | ||||||
|     $.notify({ |     $.notify({ | ||||||
|         // options
 |         // options
 | ||||||
| @ -18,7 +18,7 @@ function showMessage(message) { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function showError(message, delay = 10000) { | function showError(message, delay = 10000) { | ||||||
|     console.log("error: ", message); |     console.log(now(), "error: ", message); | ||||||
| 
 | 
 | ||||||
|     $.notify({ |     $.notify({ | ||||||
|         // options
 |         // options
 | ||||||
| @ -53,6 +53,10 @@ function formatTime(date) { | |||||||
|     return padNum(date.getHours()) + ":" + padNum(date.getMinutes()); |     return padNum(date.getHours()) + ":" + padNum(date.getMinutes()); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | function formatTimeWithSeconds(date) { | ||||||
|  |     return padNum(date.getHours()) + ":" + padNum(date.getMinutes()) + ":" + padNum(date.getSeconds()); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| function formatDate(date) { | function formatDate(date) { | ||||||
|     return padNum(date.getDate()) + ". " + padNum(date.getMonth() + 1) + ". " + date.getFullYear(); |     return padNum(date.getDate()) + ". " + padNum(date.getMonth() + 1) + ". " + date.getFullYear(); | ||||||
| } | } | ||||||
| @ -61,6 +65,10 @@ function formatDateTime(date) { | |||||||
|     return formatDate(date) + " " + formatTime(date); |     return formatDate(date) + " " + formatTime(date); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | function now() { | ||||||
|  |     return formatTimeWithSeconds(new Date()); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| function isElectron() { | function isElectron() { | ||||||
|     return window && window.process && window.process.type; |     return window && window.process && window.process.type; | ||||||
| } | } | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 azivner
						azivner