signal-desktop/preload.js
Scott Nonnenberg 6b11f67dc6
Move logging to disk via bunyan
- Logging is available in main process as well as renderer process, and
  entries all go to one set of rotating files. Log entries in the
  renderer process go to DevTools as well as the console. Entries from
  the main process only show up in the console.
- We save three days of logs, one day per file in %userData%/logs
- The 'debug' object store is deleted in a new database migration
- Timestamps and level included in the new log we generate for publish
  as well as the devtools
- The bunyan API is exposed via windows.log (providing the ability to
  log at different levels, and save objects instead of just text), so we
  can move our code to it over time.

FREEBIE
2017-09-25 15:00:34 -07:00

43 lines
1.2 KiB
JavaScript

(function () {
'use strict';
console.log('preload');
const electron = require('electron');
window.PROTO_ROOT = 'protos';
window.config = require('url').parse(window.location.toString(), true).query;
const ipc = electron.ipcRenderer;
window.config.localeMessages = ipc.sendSync('locale-data');
window.setBadgeCount = function(count) {
ipc.send('set-badge-count', count);
};
window.drawAttention = function() {
console.log('draw attention');
ipc.send('draw-attention');
};
window.showWindow = function() {
console.log('show window');
ipc.send('show-window');
};
window.restart = function() {
console.log('restart');
ipc.send('restart');
};
ipc.on('debug-log', function() {
Whisper.events.trigger('showDebugLog');
});
// We pull these dependencies in now, from here, because they have Node.js dependencies
require('./js/logging');
require('./js/spell_check');
require('./js/backup');
window.nodeSetImmediate = setImmediate;
window.nodeXMLHttpRequest = require("./js/XMLHttpRequest").XMLHttpRequest;
window.nodeWebSocket = require("websocket").w3cwebsocket;
window.EmojiConvertor = require('emoji-js');
})();