Browse Source

Correction gestion des logs

William Petit 3 years ago
parent
commit
f56e2b7f4f
3 changed files with 13 additions and 4 deletions
  1. 5
    1
      main.js
  2. 0
    1
      src/store/middlewares/logger.js
  3. 8
    2
      src/util/logger.js

+ 5
- 1
main.js View File

@@ -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 View File

@@ -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 View File

@@ -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