mirror of
https://github.com/zadam/trilium.git
synced 2025-01-27 17:40:44 +08:00
logging current time with console.logs on frontend
This commit is contained in:
parent
1ebf9d4e56
commit
3edbb65b0f
4 changed files with 19 additions and 11 deletions
|
@ -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 messaging
|
||||
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.onclose = function(){
|
||||
// Try to reconnect in 5 seconds
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
Loading…
Reference in a new issue