diff --git a/app.js b/app.js index 326e849..977b088 100755 --- a/app.js +++ b/app.js @@ -8,6 +8,8 @@ * @version 1.0 */ 'use strict'; +const config = require('config'); +const _ = require('lodash'); const express = require('express'); const cookieParser = require('cookie-parser'); const bodyParser = require('body-parser'); @@ -72,4 +74,37 @@ process.on('unhandledRejection', (err) => { logger.logFullError(err, 'system'); }); +// dump the configuration to logger +const ignoreConfigLog = ['cert', 'key', 'AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY', 'AUTH0_CLIENT_ID', 'AUTH0_CLIENT_SECRET']; +/** + * Print configs to logger + * @param {Object} params the config params + * @param {Number} level the level of param object + */ +function dumpConfigs(params, level) { + Object.keys(params).forEach((key) => { + if (_.includes(ignoreConfigLog, key)) { + return; + } + const item = params[key]; + let str = ''; + let n = 0; + while (n < level) { // eslint-disable-line no-restricted-syntax + n++; + str += ' '; + } + if (item && _.isObject(item)) { + str += `${key}=`; + logger.debug(str); + dumpConfigs(item, level + 1); + } else { + str += `${key}=${item}`; + logger.debug(str); + } + }); +} +logger.debug('--- List of Configurations ---'); +dumpConfigs(config, 0); +logger.debug('--- End of List of Configurations ---'); + module.exports = app; diff --git a/config/default.js b/config/default.js index 10b258b..0a35946 100755 --- a/config/default.js +++ b/config/default.js @@ -15,7 +15,7 @@ const fs = require('fs'); module.exports = { PORT: process.env.PORT || 3000, // eslint-disable-line no-magic-numbers - LOG_LEVEL: process.env.LOG_LEVEL || 'info', + LOG_LEVEL: process.env.LOG_LEVEL || 'debug', TOPIC: process.env.TOPIC || 'tc-x-events', KAFKA_OPTIONS: { connectionString: process.env.KAFKA_URL || 'localhost:9092',