Files
kopia/app/public/logging.js
Jarek Kowalski c3ead4bc3e Kopia UI: added desktop app shell based on Electron that runs in the tray (#183)
* app: added desktop app shell based on Electron that runs in the tray, starts a background kopia server and allows access to the UI

* icons: updated icons for the app

* htmlui: flexible containers
2020-02-01 11:58:22 -08:00

28 lines
611 B
JavaScript

const { ipcMain } = require('electron');
const maxLogLines = 100;
let serverLog = [];
function sendLogsUpdate(sender) {
sender.send('logs-updated', serverLog.join(''));
}
ipcMain.on('subscribe-to-logs', (event, arg) => {
sendLogsUpdate(event.sender);
ipcMain.addListener('logs-updated-event', () => {
sendLogsUpdate(event.sender);
})
});
module.exports = {
appendToLog(data) {
const l = serverLog.push(data);
if (l > maxLogLines) {
serverLog.splice(0, 1);
}
ipcMain.emit('logs-updated-event');
console.log(`${data}`);
}
}