11'use strict' ;
22
33var Constants = require ( '../util/Constants' ) ;
4+ const ExternalLoggerWrapper = require ( '../logging/ExternalLoggerWrapper' ) ;
5+ const ApiException = require ( '../util/ApiException' ) ;
46
57class LogConfiguration {
68 enableLog ;
@@ -10,6 +12,8 @@ class LogConfiguration {
1012 loggingLevel ;
1113 maxLogFiles ;
1214 enableMasking ;
15+ hasExternalLogger ;
16+ externalLogger ;
1317
1418 constructor ( logConfig ) {
1519 this . setLogEnable ( logConfig . enableLog ) ;
@@ -19,6 +23,8 @@ class LogConfiguration {
1923 this . setLoggingLevel ( logConfig . loggingLevel ) ;
2024 this . setMaxLogFiles ( logConfig . maxLogFiles ) ;
2125 this . setMaskingEnabled ( logConfig . enableMasking ) ;
26+ this . setHasExternalLogger ( logConfig . hasExternalLogger ) ;
27+ this . setExternalLogger ( logConfig . externalLogger ) ;
2228 }
2329
2430 isLogEnabled ( ) {
@@ -43,6 +49,22 @@ class LogConfiguration {
4349 this . enableMasking = enableMaskingValue ;
4450 }
4551
52+ setHasExternalLogger ( hasExternalLogger ) {
53+ this . hasExternalLogger = hasExternalLogger ;
54+ }
55+
56+ isExternalLoggerSet ( ) {
57+ return this . hasExternalLogger ;
58+ }
59+
60+ setExternalLogger ( externalLogger ) {
61+ this . externalLogger = externalLogger ;
62+ }
63+
64+ getExternalLogger ( ) {
65+ return this . externalLogger ;
66+ }
67+
4668 getLogDirectory ( ) {
4769 return this . logDirectory ;
4870 }
@@ -64,7 +86,7 @@ class LogConfiguration {
6486 setLogFileName ( logFileNameValue ) {
6587 this . logFileName = logFileNameValue ;
6688 }
67-
89+
6890 getLogFileMaxSize ( ) {
6991 return this . logFileMaxSize ;
7092 }
@@ -90,7 +112,7 @@ class LogConfiguration {
90112 getMaxLogFiles ( ) {
91113 return this . maxLogFiles ;
92114 }
93-
115+
94116 /**
95117 * @param {any } maxLogFilesValue
96118 */
@@ -99,6 +121,19 @@ class LogConfiguration {
99121 }
100122
101123 getDefaultLoggingProperties ( warningMessage ) {
124+
125+ if ( typeof ( this . hasExternalLogger ) === "boolean" && this . hasExternalLogger === true ) {
126+ this . hasExternalLogger = true ;
127+ } else {
128+ this . hasExternalLogger = false ;
129+ }
130+
131+ if ( ( typeof ( this . externalLogger ) === "object" && ! ( this . externalLogger instanceof ExternalLoggerWrapper ) )
132+ || this . externalLogger === undefined || ! ( this . externalLogger . isLoggerEmpty ( ) ) ) {
133+ ApiException . LoggerException ( "No valid external logger object found. Turning off external logger flag." )
134+ this . hasExternalLogger = false ;
135+ }
136+
102137 if ( typeof ( this . enableLog ) === "boolean" && this . enableLog === true ) {
103138 this . enableLog = true ;
104139 } else {
0 commit comments