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

Commit f5a1492

Browse files
committed
Log the configs when app starts.
1 parent 5a75931 commit f5a1492

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

src/app.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,50 @@ process.on('unhandledRejection', (err) => {
148148
logger.logFullError(err, 'system');
149149
});
150150

151+
// dump the configuration to logger
152+
const ignoreConfigLog = [
153+
'cert',
154+
'key',
155+
'AWS_ACCESS_KEY_ID',
156+
'AWS_SECRET_ACCESS_KEY',
157+
'AUTH0_CLIENT_ID',
158+
'AUTH0_CLIENT_SECRET',
159+
'GITHUB_CLIENT_ID',
160+
'GITHUB_CLIENT_SECRET',
161+
'GITLAB_CLIENT_ID',
162+
'GITLAB_CLIENT_SECRET'
163+
];
164+
/**
165+
* Print configs to logger
166+
* @param {Object} params the config params
167+
* @param {Number} level the level of param object
168+
*/
169+
function dumpConfigs(params, level) {
170+
Object.keys(params).forEach((key) => {
171+
if (_.includes(ignoreConfigLog, key)) {
172+
return;
173+
}
174+
const item = params[key];
175+
let str = '';
176+
let n = 0;
177+
while (n < level) { // eslint-disable-line no-restricted-syntax
178+
n++;
179+
str += ' ';
180+
}
181+
if (item && _.isObject(item)) {
182+
str += `${key}=`;
183+
logger.debug(str);
184+
dumpConfigs(item, level + 1);
185+
} else {
186+
str += `${key}=${item}`;
187+
logger.debug(str);
188+
}
189+
});
190+
}
191+
logger.debug('--- List of Configurations ---');
192+
dumpConfigs(config, 0);
193+
logger.debug('--- End of List of Configurations ---');
194+
151195
const port = config.PORT;
152196
app.listen(port, '0.0.0.0');
153197
logger.info('Topcoder X server listening on port %d', port);

0 commit comments

Comments
 (0)