瀏覽代碼

Correction gestion des logs

feature/remote-launch
William Petit 3 年之前
父節點
當前提交
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.
2 2
 var BrowserWindow = require('browser-window');  // Module to create native browser window.
3 3
 var Menu = require('menu');
4 4
 var isDev = process.env.NODE_ENV === 'development';
5
-var constants = require('./'+(isDev ? 'src': 'dist')+'/util').Const;
5
+var Util = require('./'+(isDev ? 'src': 'dist')+'/util');
6 6
 
7 7
 var mainWindow = null;
8 8
 
@@ -41,3 +41,7 @@ app.on('ready', function() {
41 41
   });
42 42
 
43 43
 });
44
+
45
+process.on('exit', function(code) {
46
+  Util.Logger.info('Exiting with code "%s"', code || 0);
47
+});

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

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

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

@@ -6,12 +6,18 @@ var logFile = process.env.PITAYA_LOG_FILE;
6 6
 
7 7
 logger.level = logLevel;
8 8
 
9
-logger.add(winston.transports.Console, { colorize: true });
9
+logger.add(winston.transports.Console, {
10
+  colorize: true,
11
+  handleExceptions: true,
12
+  humanReadableUnhandledException: true
13
+});
10 14
 
11 15
 if(logFile) {
12 16
   logger.add(winston.transports.File, {
13 17
     filename: logFile,
14
-    json: false
18
+    json: false,
19
+    handleExceptions: true,
20
+    humanReadableUnhandledException: true
15 21
   });
16 22
 }
17 23
 

Loading…
取消
儲存