Skip to content

Commit

Permalink
Use config for logLevel.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonesy committed Feb 11, 2020
1 parent 6144253 commit 796e183
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 5 deletions.
2 changes: 2 additions & 0 deletions frontend/config/default.json.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"port": 8000,
"wsPort": 3001,
"logLevel": "info",
"morganLogLevel": "dev",
"cookieSecret": "COOKIE_SECRET_HERE",
"jwtSecret": "JWT_SECRET_HERE",
"helpURL": "EXTERNAL DOCUMENTATION URL (optional)",
Expand Down
2 changes: 2 additions & 0 deletions frontend/config/test.json.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"port": 8000,
"wsPort": 3001,
"logLevel": "error",
"morganLogLevel": "dev",
"cookieSecret": "COOKIE_SECRET_HERE",
"jwtSecret": "JWT_SECRET_HERE",
"helpURL": "EXTERNAL DOCUMENTATION URL (optional)",
Expand Down
2 changes: 2 additions & 0 deletions frontend/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ printf "{\n" > ./config/default.json
printf "\"port\": \"${PORT}\",\n" >> ./config/default.json
printf "\"host\": \"${HOST}\",\n" >> ./config/default.json
printf "\"helpURL\": \"${HELP_URL}\",\n" >> ./config/default.json
printf "\"logLevel\": \"${LOG_LEVEL}\",\n" >> ./config/default.json
printf "\"morganLogType\": \"dev\",\n" >> ./config/default.json
printf "\"forumApiHost\": \"${FORUM_API_HOST}\",\n" >> ./config/default.json
printf "\"forumSocket\": \"${FORUM_SOCKET_HOST}\",\n" >> ./config/default.json
printf "\"requestApiHost\": \"${REQUEST_API_HOST}\",\n" >> ./config/default.json
Expand Down
2 changes: 2 additions & 0 deletions frontend/helm/ocwa-frontend/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ spec:
value: "{{ .Values.port }}"
- name: HOST
value: {{ .Values.host }}
- name: LOG_LEVEL
value: {{ .Values.logLevel }}
- name: HELP_URL
value: "{{ .Values.helpURL }}"
- name: FORUM_API_HOST
Expand Down
9 changes: 4 additions & 5 deletions frontend/server/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ const requestSocket = config.get('requestSocket');
const exporterMode = config.get('exporterMode');
const codeExportEnabled = config.get('codeExportEnabled');
const repositoryHost = config.get('repositoryHost');
const logLevel = config.get('logLevel');
const morganLogLevel = config.get('morganLogLevel');

log.level = 'debug'; // config.get('logLevel');
log.level = logLevel;
log.addLevel('debug', 2900, { fg: 'green' });

const memoryStore = new MemoryStore({
Expand All @@ -54,7 +56,7 @@ if (process.env.NODE_ENV !== 'test') {
}),
});
app.use(logger);
app.use(morgan('dev'));
app.use(morgan(morganLogLevel));
}

if (isDevelopment) {
Expand All @@ -71,9 +73,6 @@ if (isDevelopment) {
app.use(webpackHotMiddleware(compiler));
}

log.level = 'debug'; // config.get('logLevel');
log.addLevel('debug', 2900, { fg: 'green' });

// Express config
app.set('view engine', 'pug');
app.set('views', `${__dirname}/views`);
Expand Down
1 change: 1 addition & 0 deletions terraform/ocwa_frontend.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ resource "docker_container" "ocwa_download_frontend" {
env = [
"COOKIE_SECRET=${random_string.cookie.result}",
"JWT_SECRET=${random_string.jwtSecret.result}",
"LOG_LEVEL=debug",
"AUTH_ENDPOINT=${var.authHost}/auth/realms/ocwa/protocol/openid-connect/auth",
"TOKEN_ENDPOINT=${var.authHost}/auth/realms/ocwa/protocol/openid-connect/token",
"USER_INFO_ENDPOINT=${var.authHost}/auth/realms/ocwa/protocol/openid-connect/userinfo",
Expand Down

0 comments on commit 796e183

Please sign in to comment.