Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 4310801

Browse files
committedNov 8, 2019
Log the configs when app starts.
1 parent c84a9fd commit 4310801

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');
@@ -25,6 +27,39 @@ function check() {
2527
};
2628
}
2729

30+
// dump the configuration to logger
31+
const ignoreConfigLog = ['cert', 'key', 'AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY', 'AUTH0_CLIENT_ID', 'AUTH0_CLIENT_SECRET'];
32+
/**
33+
* Print configs to logger
34+
* @param {Object} params the config params
35+
* @param {Number} level the level of param object
36+
*/
37+
function dumpConfigs(params, level) {
38+
Object.keys(params).forEach((key) => {
39+
if (_.includes(ignoreConfigLog, key)) {
40+
return;
41+
}
42+
const item = params[key];
43+
let str = '';
44+
let n = 0;
45+
while (n < level) { // eslint-disable-line no-restricted-syntax
46+
n++;
47+
str += ' ';
48+
}
49+
if (item && _.isObject(item)) {
50+
str += `${key}=`;
51+
logger.debug(str);
52+
dumpConfigs(item, level + 1);
53+
} else {
54+
str += `${key}=${item}`;
55+
logger.debug(str);
56+
}
57+
});
58+
}
59+
logger.debug('--- List of Configurations ---');
60+
dumpConfigs(config, 0);
61+
logger.debug('--- End of List of Configurations ---');
62+
2863
const webhooks = require('./routes/webhooks');
2964

3065
const app = express();

‎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)
This repository has been archived.