Przeglądaj źródła

ensure to check process.env.FORMAT_NODE_LOG on production

Yuki Takei 8 lat temu
rodzic
commit
23b0408cbe
2 zmienionych plików z 8 dodań i 2 usunięć
  1. 2 0
      config/env.prod.js
  2. 6 2
      lib/service/logger/stream.prod.js

+ 2 - 0
config/env.prod.js

@@ -1,5 +1,7 @@
 module.exports = {
 module.exports = {
   NODE_ENV: 'production',
   NODE_ENV: 'production',
+  // FORMAT_NODE_LOG: false,
+
   // settings for 'visionmedia/debug'
   // settings for 'visionmedia/debug'
   // see also './logger/config.prod.js'
   // see also './logger/config.prod.js'
   DEBUG: [
   DEBUG: [

+ 6 - 2
lib/service/logger/stream.prod.js

@@ -1,6 +1,10 @@
 let stream = undefined;
 let stream = undefined;
 
 
-// do nothing
-// output JSON to stdout
+const isFormat = !(process.env.FORMAT_NODE_LOG === 'false');
+
+if (isFormat) {
+  const bunyanFormat = require('bunyan-format');
+  stream = bunyanFormat({ outputMode: 'long' });
+}
 
 
 module.exports = stream;
 module.exports = stream;