浏览代码

Correction gestion des logs

upgrade-electron
wpetit 4 年前
父节点
当前提交
f56e2b7f4f
共有 3 个文件被更改,包括 13 次插入4 次删除
  1. +5
    -1
      main.js
  2. +0
    -1
      src/store/middlewares/logger.js
  3. +8
    -2
      src/util/logger.js

+ 5
- 1
main.js 查看文件

@@ -2,7 +2,7 @@ var app = require('app'); // Module to control application life.
var BrowserWindow = require('browser-window'); // Module to create native browser window.
var Menu = require('menu');
var isDev = process.env.NODE_ENV === 'development';
var constants = require('./'+(isDev ? 'src': 'dist')+'/util').Const;
var Util = require('./'+(isDev ? 'src': 'dist')+'/util');

var mainWindow = null;

@@ -41,3 +41,7 @@ app.on('ready', function() {
});

});

process.on('exit', function(code) {
Util.Logger.info('Exiting with code "%s"', code || 0);
});

+ 0
- 1
src/store/middlewares/logger.js 查看文件

@@ -8,7 +8,6 @@ module.exports = function loggerMiddleware(store) {
next(action);
if(action.error) {
logger.error(action.type, action.error);
return app.quit(1);
}
};
};

+ 8
- 2
src/util/logger.js 查看文件

@@ -6,12 +6,18 @@ var logFile = process.env.PITAYA_LOG_FILE;

logger.level = logLevel;

logger.add(winston.transports.Console, { colorize: true });
logger.add(winston.transports.Console, {
colorize: true,
handleExceptions: true,
humanReadableUnhandledException: true
});

if(logFile) {
logger.add(winston.transports.File, {
filename: logFile,
json: false
json: false,
handleExceptions: true,
humanReadableUnhandledException: true
});
}


正在加载...
取消
保存