775ac7b58c
you must login with an BTP account in order to see the app
37 lines
963 B
JavaScript
37 lines
963 B
JavaScript
'use strict';
|
|
|
|
const normalizeLevel = require('./common').normalizeLevel;
|
|
|
|
class Env {
|
|
constructor() {
|
|
this.loggingOff = isLoggingOff();
|
|
this.topPrioLevel = this.loggingOff ? null : getTopPrioLevel();
|
|
|
|
this.runsOnXSA = 'XS_BIND_ADDRESS' in process.env;
|
|
this.runsOnCF = 'VCAP_APPLICATION' in process.env && !this.runsOnXSA;
|
|
this.instanceIp = process.env['CF_INSTANCE_IP'];
|
|
this.vcapApp = JSON.parse(process.env['VCAP_APPLICATION'] || '{}');
|
|
|
|
this.logUser = isEnabled('XS_LOG_USER');
|
|
this.logReferer = isEnabled('XS_LOG_REFERER');
|
|
this.logConnectionData = isEnabled('XS_LOG_CONNECTION_DATA');
|
|
}
|
|
}
|
|
|
|
function isLoggingOff() {
|
|
return /^none$/i.test(process.env.XS_APP_LOG_LEVEL);
|
|
}
|
|
|
|
function getTopPrioLevel() {
|
|
const value = process.env.XS_APP_LOG_LEVEL;
|
|
if (!value) {
|
|
return null;
|
|
}
|
|
return normalizeLevel(value);
|
|
}
|
|
|
|
function isEnabled(flag) {
|
|
return /^true$/i.test(process.env[flag]);
|
|
}
|
|
|
|
module.exports = Env;
|