Skip to content

Commit a73edd9

Browse files
committed
review fixes
1 parent b13ba38 commit a73edd9

File tree

3 files changed

+25
-22
lines changed

3 files changed

+25
-22
lines changed

src/authentication/logging/ExternalLoggerWrapper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class ExternalLoggerWrapper{
88
this.extLogger = externalLogger;
99
}
1010

11-
getExternalLogger(){
11+
getLogger(){
1212
return this.extLogger;
1313
}
1414

src/authentication/logging/LogConfiguration.js

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
var Constants = require('../util/Constants');
44
const ExternalLoggerWrapper = require('../logging/ExternalLoggerWrapper');
55
const ApiException = require('../util/ApiException');
6+
const fs = require("fs");
7+
const path = require("path");
68

79
class LogConfiguration {
810
enableLog;
@@ -12,8 +14,8 @@ class LogConfiguration {
1214
loggingLevel;
1315
maxLogFiles;
1416
enableMasking;
17+
hasExternalLogger;
1518
externalLogger;
16-
externalLoggerObj;
1719

1820
constructor(logConfig) {
1921
this.setLogEnable(logConfig.enableLog);
@@ -23,8 +25,8 @@ class LogConfiguration {
2325
this.setLoggingLevel(logConfig.loggingLevel);
2426
this.setMaxLogFiles(logConfig.maxLogFiles);
2527
this.setMaskingEnabled(logConfig.enableMasking);
28+
this.setHasExternalLogger(logConfig.hasExternalLogger);
2629
this.setExternalLogger(logConfig.externalLogger);
27-
this.setExternalLoggerObj(logConfig.externalLoggerObj);
2830
}
2931

3032
isLogEnabled() {
@@ -49,20 +51,20 @@ class LogConfiguration {
4951
this.enableMasking = enableMaskingValue;
5052
}
5153

52-
setExternalLogger(externalLogger){
53-
this.externalLogger = externalLogger;
54+
setHasExternalLogger(hasExternalLogger){
55+
this.hasExternalLogger = hasExternalLogger;
5456
}
5557

5658
isExternalLoggerSet(){
57-
return this.externalLogger;
59+
return this.hasExternalLogger;
5860
}
5961

60-
setExternalLoggerObj(externalLoggerObj){
61-
this.externalLoggerObj = externalLoggerObj;
62+
setExternalLogger(externalLogger){
63+
this.externalLogger = externalLogger;
6264
}
6365

64-
getExternalLoggerObj(){
65-
return this.externalLoggerObj;
66+
getExternalLogger(){
67+
return this.externalLogger;
6668
}
6769

6870
getLogDirectory () {
@@ -122,16 +124,16 @@ class LogConfiguration {
122124

123125
getDefaultLoggingProperties(warningMessage) {
124126

125-
if(typeof (this.externalLogger) === "boolean" && this.externalLogger === true){
126-
this.externalLogger = true;
127+
if(typeof (this.hasExternalLogger) === "boolean" && this.hasExternalLogger === true){
128+
this.hasExternalLogger = true;
127129
} else {
128-
this.externalLogger = false;
130+
this.hasExternalLogger = false;
129131
}
130132

131-
if(typeof (this.externalLoggerObj) === "Object" || !(this.externalLoggerObj instanceof ExternalLoggerWrapper)
132-
&& this.externalLoggerObj === undefined || !(this.externalLoggerObj.isLoggerEmpty())){
133+
if((typeof (this.externalLogger) === "object" && !(this.externalLogger instanceof ExternalLoggerWrapper))
134+
|| this.externalLogger === undefined || !(this.externalLogger.isLoggerEmpty())){
133135
ApiException.LoggerException("No valid external logger object found. Turning off external logger flag.")
134-
this.externalLogger = false;
136+
this.hasExternalLogger = false;
135137
}
136138

137139
if (typeof (this.enableLog) === "boolean" && this.enableLog === true) {

src/authentication/logging/Logger.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ const unmaskedLoggingFormat = printf(({ level, message, label, timestamp }) => {
1515

1616
exports.getLogger = function (merchantConfig, loggerCategory = 'UnknownCategoryLogger') {
1717

18-
if(merchantConfig.getLogConfiguration().isExternalLoggerSet() && merchantConfig.getLogConfiguration().getExternalLoggerObj().getExternalLogger()
19-
&& merchantConfig.getLogConfiguration().getExternalLoggerObj() instanceof ExternalLoggerWrapper){
20-
let logger = merchantConfig.getLogConfiguration().getExternalLoggerObj().getExternalLogger();
18+
if(merchantConfig.getLogConfiguration().isExternalLoggerSet() && merchantConfig.getLogConfiguration().getExternalLogger()
19+
&& merchantConfig.getLogConfiguration().getExternalLogger().getLogger()
20+
&& merchantConfig.getLogConfiguration().getExternalLogger() instanceof ExternalLoggerWrapper){
21+
let logger = merchantConfig.getLogConfiguration().getExternalLogger().getLogger();
2122
return logger;
2223
}
2324
var enableLog = merchantConfig.getLogConfiguration().isLogEnabled();
@@ -43,9 +44,9 @@ exports.getLogger = function (merchantConfig, loggerCategory = 'UnknownCategoryL
4344
newLogger = winston.loggers.get(loggerCategory + loggerCategoryRandomiser, {
4445
level: loggingLevel,
4546
format: combine(
46-
label({ label: loggerCategory }),
47-
timestamp(),
48-
enableMasking ? maskedLoggingFormat : unmaskedLoggingFormat
47+
label({ label: loggerCategory }),
48+
timestamp(),
49+
enableMasking ? maskedLoggingFormat : unmaskedLoggingFormat
4950
),
5051
transports: [new winston.transports.Console({
5152
silent: !enableLog

0 commit comments

Comments
 (0)