mirror of
https://github.com/zadam/trilium.git
synced 2025-11-02 03:16:11 +01:00
logging JS errors to backend logs
This commit is contained in:
@@ -1,9 +1,20 @@
|
||||
"use strict";
|
||||
|
||||
const messaging = (function() {
|
||||
function messageHandler(event) {
|
||||
console.log(event.data);
|
||||
let ws = null;
|
||||
|
||||
function logError(message) {
|
||||
console.error(message);
|
||||
|
||||
if (ws && ws.readyState === 1) {
|
||||
ws.send(JSON.stringify({
|
||||
type: 'log-error',
|
||||
error: message
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
function messageHandler(event) {
|
||||
const message = JSON.parse(event.data);
|
||||
|
||||
if (message.type === 'sync') {
|
||||
@@ -27,8 +38,6 @@ const messaging = (function() {
|
||||
}
|
||||
}
|
||||
|
||||
let ws = null;
|
||||
|
||||
function connectWebSocket() {
|
||||
// use wss for secure messaging
|
||||
ws = new WebSocket("ws://" + location.host);
|
||||
@@ -65,4 +74,8 @@ const messaging = (function() {
|
||||
showMessage("Re-connected to server");
|
||||
}
|
||||
}, 3000);
|
||||
|
||||
return {
|
||||
logError
|
||||
};
|
||||
})();
|
||||
Reference in New Issue
Block a user