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
This commit is contained in:
Scott Nonnenberg 2017-09-25 15:00:19 -07:00
parent 33f5a804fe
commit 6b11f67dc6
No known key found for this signature in database
GPG key ID: A4931C09644C654B
12 changed files with 315 additions and 108 deletions

23
main.js
View file

@ -1,8 +1,10 @@
const path = require('path');
const url = require('url');
const electron = require('electron')
const app = electron.app
const BrowserWindow = electron.BrowserWindow
const path = require('path')
const url = require('url')
const BrowserWindow = electron.BrowserWindow;
const app = electron.app;
const ipc = electron.ipcMain;
const Menu = electron.Menu;
const shell = electron.shell;
@ -10,6 +12,7 @@ const shell = electron.shell;
const autoUpdate = require('./app/auto_update');
const windowState = require('./app/window_state');
console.log('setting AUMID');
app.setAppUserModelId('org.whispersystems.signal-desktop')
@ -38,9 +41,15 @@ if (config.environment === 'production' && !process.mas) {
}
const userConfig = require('./app/user_config');
let windowConfig = userConfig.get('window');
const logging = require('./app/logging');
// this must be after we set up appPath in user_config.js
logging.initialize();
const logger = logging.getLogger();
let windowConfig = userConfig.get('window');
const loadLocale = require('./app/locale').load;
let locale;
function createWindow () {
@ -126,7 +135,7 @@ function createWindow () {
});
mainWindow.webContents.on('will-navigate', function(e) {
console.log('will-navigate');
logger.info('will-navigate');
e.preventDefault();
});
@ -169,7 +178,7 @@ function showDebugLog() {
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', function() {
console.log('app ready');
logger.info('app ready');
if (!locale) {
locale = loadLocale();