mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-04-14 11:36:45 +00:00
Fixed issue that logging was not actually disabled,
when no transport were configured in the production environment
This commit is contained in:
parent
4ab2d25429
commit
5e845b8aa6
1 changed files with 5 additions and 4 deletions
|
|
@ -19,13 +19,14 @@ const logger = winston.createLogger();
|
|||
|
||||
const _config = {
|
||||
logger,
|
||||
loggingEnabled: true, // false if no transport has been configured
|
||||
loggingEnabled: false, // is set to true, if a transport gets configured
|
||||
};
|
||||
|
||||
export { _config as _loggerConfig }; // exported for use during tests
|
||||
|
||||
if (IS_PROD) {
|
||||
if (ENABLE_CONSOLE_LOGS_IN_PROD) {
|
||||
_config.loggingEnabled = true;
|
||||
logger
|
||||
.add(new winston.transports.Console({ // text part
|
||||
format: winston.format.combine(
|
||||
|
|
@ -44,6 +45,7 @@ if (IS_PROD) {
|
|||
}
|
||||
|
||||
if (LOGGLY_TOKEN && LOGGLY_SUBDOMAIN) {
|
||||
_config.loggingEnabled = true;
|
||||
logger.add(new Loggly({
|
||||
inputToken: LOGGLY_TOKEN,
|
||||
subdomain: LOGGLY_SUBDOMAIN,
|
||||
|
|
@ -51,8 +53,9 @@ if (IS_PROD) {
|
|||
json: true,
|
||||
}));
|
||||
}
|
||||
// Do not log anything when testing unless specified
|
||||
// Do not log anything when testing unless specified
|
||||
} else if (!IS_TEST || (IS_TEST && ENABLE_LOGS_IN_TEST)) {
|
||||
_config.loggingEnabled = true;
|
||||
logger
|
||||
.add(new winston.transports.Console({
|
||||
level: 'warn', // warn and errors (text part)
|
||||
|
|
@ -116,8 +119,6 @@ if (IS_PROD) {
|
|||
}),
|
||||
),
|
||||
}));
|
||||
} else {
|
||||
_config.loggingEnabled = false;
|
||||
}
|
||||
|
||||
// exports a public interface insteaf of accessing directly the logger module
|
||||
|
|
|
|||
Loading…
Reference in a new issue