Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit be622f0

Browse files
authored
Merge pull request #14 from afrisalyp/issue-218
Issue 218
2 parents c84a9fd + 39adad2 commit be622f0

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

app.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
* @version 1.0
99
*/
1010
'use strict';
11+
const config = require('config');
12+
const _ = require('lodash');
1113
const express = require('express');
1214
const cookieParser = require('cookie-parser');
1315
const bodyParser = require('body-parser');
@@ -72,4 +74,37 @@ process.on('unhandledRejection', (err) => {
7274
logger.logFullError(err, 'system');
7375
});
7476

77+
// dump the configuration to logger
78+
const ignoreConfigLog = ['cert', 'key', 'AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY', 'AUTH0_CLIENT_ID', 'AUTH0_CLIENT_SECRET'];
79+
/**
80+
* Print configs to logger
81+
* @param {Object} params the config params
82+
* @param {Number} level the level of param object
83+
*/
84+
function dumpConfigs(params, level) {
85+
Object.keys(params).forEach((key) => {
86+
if (_.includes(ignoreConfigLog, key)) {
87+
return;
88+
}
89+
const item = params[key];
90+
let str = '';
91+
let n = 0;
92+
while (n < level) { // eslint-disable-line no-restricted-syntax
93+
n++;
94+
str += ' ';
95+
}
96+
if (item && _.isObject(item)) {
97+
str += `${key}=`;
98+
logger.debug(str);
99+
dumpConfigs(item, level + 1);
100+
} else {
101+
str += `${key}=${item}`;
102+
logger.debug(str);
103+
}
104+
});
105+
}
106+
logger.debug('--- List of Configurations ---');
107+
dumpConfigs(config, 0);
108+
logger.debug('--- End of List of Configurations ---');
109+
75110
module.exports = app;

config/default.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const fs = require('fs');
1515

1616
module.exports = {
1717
PORT: process.env.PORT || 3000, // eslint-disable-line no-magic-numbers
18-
LOG_LEVEL: process.env.LOG_LEVEL || 'info',
18+
LOG_LEVEL: process.env.LOG_LEVEL || 'debug',
1919
TOPIC: process.env.TOPIC || 'tc-x-events',
2020
KAFKA_OPTIONS: {
2121
connectionString: process.env.KAFKA_URL || 'localhost:9092',

0 commit comments

Comments
 (0)