@pristine-ts/logging 0.0.170 → 0.0.174

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/dist/lib/cjs/enums/output-mode.enum.js +9 -0
  2. package/dist/lib/cjs/enums/output-mode.enum.js.map +1 -1
  3. package/dist/lib/cjs/enums/severity.enum.js +3 -0
  4. package/dist/lib/cjs/enums/severity.enum.js.map +1 -1
  5. package/dist/lib/cjs/handlers/log.handler.js +66 -10
  6. package/dist/lib/cjs/handlers/log.handler.js.map +1 -1
  7. package/dist/lib/cjs/loggers/base.logger.js +62 -1
  8. package/dist/lib/cjs/loggers/base.logger.js.map +1 -1
  9. package/dist/lib/cjs/loggers/console.logger.js +35 -3
  10. package/dist/lib/cjs/loggers/console.logger.js.map +1 -1
  11. package/dist/lib/cjs/loggers/file.logger.js +37 -3
  12. package/dist/lib/cjs/loggers/file.logger.js.map +1 -1
  13. package/dist/lib/cjs/loggers/loggers.js +1 -0
  14. package/dist/lib/cjs/loggers/loggers.js.map +1 -1
  15. package/dist/lib/cjs/logging.module.js +51 -1
  16. package/dist/lib/cjs/logging.module.js.map +1 -1
  17. package/dist/lib/cjs/models/diagnostics.model.js +7 -0
  18. package/dist/lib/cjs/models/diagnostics.model.js.map +1 -1
  19. package/dist/lib/cjs/models/log.model.js +15 -0
  20. package/dist/lib/cjs/models/log.model.js.map +1 -1
  21. package/dist/lib/cjs/utils/utils.js +36 -0
  22. package/dist/lib/cjs/utils/utils.js.map +1 -1
  23. package/dist/lib/esm/enums/output-mode.enum.js +9 -0
  24. package/dist/lib/esm/enums/output-mode.enum.js.map +1 -1
  25. package/dist/lib/esm/enums/severity.enum.js +3 -0
  26. package/dist/lib/esm/enums/severity.enum.js.map +1 -1
  27. package/dist/lib/esm/handlers/log.handler.js +66 -10
  28. package/dist/lib/esm/handlers/log.handler.js.map +1 -1
  29. package/dist/lib/esm/loggers/base.logger.js +62 -1
  30. package/dist/lib/esm/loggers/base.logger.js.map +1 -1
  31. package/dist/lib/esm/loggers/console.logger.js +35 -3
  32. package/dist/lib/esm/loggers/console.logger.js.map +1 -1
  33. package/dist/lib/esm/loggers/file.logger.js +37 -3
  34. package/dist/lib/esm/loggers/file.logger.js.map +1 -1
  35. package/dist/lib/esm/loggers/loggers.js +1 -0
  36. package/dist/lib/esm/loggers/loggers.js.map +1 -1
  37. package/dist/lib/esm/logging.module.js +51 -1
  38. package/dist/lib/esm/logging.module.js.map +1 -1
  39. package/dist/lib/esm/models/diagnostics.model.js +7 -0
  40. package/dist/lib/esm/models/diagnostics.model.js.map +1 -1
  41. package/dist/lib/esm/models/log.model.js +15 -0
  42. package/dist/lib/esm/models/log.model.js.map +1 -1
  43. package/dist/lib/esm/utils/utils.js +36 -0
  44. package/dist/lib/esm/utils/utils.js.map +1 -1
  45. package/dist/types/enums/output-mode.enum.d.ts +9 -0
  46. package/dist/types/enums/severity.enum.d.ts +3 -0
  47. package/dist/types/handlers/log.handler.d.ts +58 -3
  48. package/dist/types/interfaces/log-handler.interface.d.ts +37 -3
  49. package/dist/types/interfaces/logger.interface.d.ts +11 -0
  50. package/dist/types/loggers/base.logger.d.ts +71 -1
  51. package/dist/types/loggers/console.logger.d.ts +36 -1
  52. package/dist/types/loggers/file.logger.d.ts +42 -1
  53. package/dist/types/loggers/loggers.d.ts +1 -0
  54. package/dist/types/logging.module.d.ts +1 -1
  55. package/dist/types/models/diagnostics.model.d.ts +37 -0
  56. package/dist/types/models/log.model.d.ts +25 -1
  57. package/dist/types/utils/utils.d.ts +36 -0
  58. package/package.json +4 -4
@@ -1,9 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OutputModeEnum = void 0;
4
+ /**
5
+ * Output mode for the logs.
6
+ */
4
7
  var OutputModeEnum;
5
8
  (function (OutputModeEnum) {
9
+ /**
10
+ * The logs will output a JSON format.
11
+ */
6
12
  OutputModeEnum["Json"] = "JSON";
13
+ /**
14
+ * The logs will output a simple string format.
15
+ */
7
16
  OutputModeEnum["Simple"] = "SIMPLE";
8
17
  })(OutputModeEnum = exports.OutputModeEnum || (exports.OutputModeEnum = {}));
9
18
  //# sourceMappingURL=output-mode.enum.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"output-mode.enum.js","sourceRoot":"","sources":["../../../../src/enums/output-mode.enum.ts"],"names":[],"mappings":";;;AAAA,IAAY,cAGX;AAHD,WAAY,cAAc;IACtB,+BAAa,CAAA;IACb,mCAAiB,CAAA;AACrB,CAAC,EAHW,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAGzB"}
1
+ {"version":3,"file":"output-mode.enum.js","sourceRoot":"","sources":["../../../../src/enums/output-mode.enum.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,IAAY,cASX;AATD,WAAY,cAAc;IACtB;;OAEG;IACH,+BAAa,CAAA;IACb;;OAEG;IACH,mCAAiB,CAAA;AACrB,CAAC,EATW,cAAc,GAAd,sBAAc,KAAd,sBAAc,QASzB"}
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SeverityEnum = void 0;
4
+ /**
5
+ * The severity supported for logging purposes.
6
+ */
4
7
  var SeverityEnum;
5
8
  (function (SeverityEnum) {
6
9
  SeverityEnum[SeverityEnum["Critical"] = 4] = "Critical";
@@ -1 +1 @@
1
- {"version":3,"file":"severity.enum.js","sourceRoot":"","sources":["../../../../src/enums/severity.enum.ts"],"names":[],"mappings":";;;AAAA,IAAY,YAMX;AAND,WAAY,YAAY;IACpB,uDAAY,CAAA;IACZ,iDAAS,CAAA;IACT,qDAAW,CAAA;IACX,+CAAQ,CAAA;IACR,iDAAS,CAAA;AACb,CAAC,EANW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAMvB"}
1
+ {"version":3,"file":"severity.enum.js","sourceRoot":"","sources":["../../../../src/enums/severity.enum.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,IAAY,YAMX;AAND,WAAY,YAAY;IACpB,uDAAY,CAAA;IACZ,iDAAS,CAAA;IACT,qDAAW,CAAA;IACX,+CAAQ,CAAA;IACR,iDAAS,CAAA;AACb,CAAC,EANW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAMvB"}
@@ -19,7 +19,20 @@ const severity_enum_1 = require("../enums/severity.enum");
19
19
  const log_model_1 = require("../models/log.model");
20
20
  const common_1 = require("@pristine-ts/common");
21
21
  const utils_1 = require("../utils/utils");
22
+ /**
23
+ * The LogHandler to use when we want to output some logs.
24
+ * This handler makes sure that only the right level of logs are outputted, stacks logs, and logs with different loggers.
25
+ * It is registered with the tag LogHandlerInterface so that it can be injected as a LogHandlerInterface to facilitate mocking.
26
+ */
22
27
  let LogHandler = class LogHandler {
28
+ /**
29
+ * The LogHandler to use when we want to output some logs.
30
+ * @param loggers The loggers to use to output the logs. All services with the tag ServiceDefinitionTagEnum.Logger will be automatically injected here.
31
+ * @param logSeverityLevelConfiguration The severity from which to start logging the logs.
32
+ * @param activateDiagnostics Whether or not the outputted logs should contain the diagnostic part. This is an intensive process and can dramatically reduce the performance of the code.
33
+ * @param kernelInstantiationId The id of instantiation of the kernel.
34
+ * @param tracingContext The context of the tracing.
35
+ */
23
36
  constructor(loggers, logSeverityLevelConfiguration, activateDiagnostics, kernelInstantiationId, tracingContext) {
24
37
  this.loggers = loggers;
25
38
  this.logSeverityLevelConfiguration = logSeverityLevelConfiguration;
@@ -27,21 +40,63 @@ let LogHandler = class LogHandler {
27
40
  this.kernelInstantiationId = kernelInstantiationId;
28
41
  this.tracingContext = tracingContext;
29
42
  }
30
- error(message, extra, module = "application") {
31
- return this.log(message, severity_enum_1.SeverityEnum.Error, extra, module);
32
- }
43
+ /**
44
+ * Logs the message if the severity is set to critical or above.
45
+ * This function is wrapper function for the log method with the proper severity to make it cleaner when using it in the code.
46
+ * @param message The message to log.
47
+ * @param extra The extra object to log.
48
+ * @param module The module from where the log was created.
49
+ */
33
50
  critical(message, extra, module = "application") {
34
51
  return this.log(message, severity_enum_1.SeverityEnum.Critical, extra, module);
35
52
  }
36
- debug(message, extra, module = "application") {
37
- return this.log(message, severity_enum_1.SeverityEnum.Debug, extra, module);
53
+ /**
54
+ * Logs the message if the severity is set to error or above.
55
+ * This function is wrapper function for the log method with the proper severity to make it cleaner when using it in the code.
56
+ * @param message The message to log.
57
+ * @param extra The extra object to log.
58
+ * @param module The module from where the log was created.
59
+ */
60
+ error(message, extra, module = "application") {
61
+ return this.log(message, severity_enum_1.SeverityEnum.Error, extra, module);
38
62
  }
63
+ /**
64
+ * Logs the message if the severity is set to warning or above.
65
+ * This function is wrapper function for the log method with the proper severity to make it cleaner when using it in the code.
66
+ * @param message The message to log.
67
+ * @param extra The extra object to log.
68
+ * @param module The module from where the log was created.
69
+ */
70
+ warning(message, extra, module = "application") {
71
+ return this.log(message, severity_enum_1.SeverityEnum.Warning, extra, module);
72
+ }
73
+ /**
74
+ * Logs the message if the severity is set to info or above.
75
+ * This function is wrapper function for the log method with the proper severity to make it cleaner when using it in the code.
76
+ * @param message The message to log.
77
+ * @param extra The extra object to log.
78
+ * @param module The module from where the log was created.
79
+ */
39
80
  info(message, extra, module = "application") {
40
81
  return this.log(message, severity_enum_1.SeverityEnum.Info, extra, module);
41
82
  }
42
- warning(message, extra, module = "application") {
43
- return this.log(message, severity_enum_1.SeverityEnum.Warning, extra, module);
83
+ /**
84
+ * Logs the message if the severity is set to debug or above.
85
+ * This function is wrapper function for the log method with the proper severity to make it cleaner when using it in the code.
86
+ * @param message The message to log.
87
+ * @param extra The extra object to log.
88
+ * @param module The module from where the log was created.
89
+ */
90
+ debug(message, extra, module = "application") {
91
+ return this.log(message, severity_enum_1.SeverityEnum.Debug, extra, module);
44
92
  }
93
+ /**
94
+ * Logs the message based on the severity.
95
+ * @param message The message to log.
96
+ * @param severity The minimum severity to log.
97
+ * @param extra The extra object to log.
98
+ * @param module The module from where the log was created.
99
+ */
45
100
  log(message, severity = severity_enum_1.SeverityEnum.Error, extra, module = "application") {
46
101
  const log = new log_model_1.LogModel(severity, message);
47
102
  log.kernelInstantiationId = this.kernelInstantiationId;
@@ -64,9 +119,10 @@ let LogHandler = class LogHandler {
64
119
  }
65
120
  log.extra["__diagnostics"] = diagnostics;
66
121
  }
67
- for (const writer of this.loggers) {
68
- if (writer.isActive()) {
69
- writer.readableStream.push(log);
122
+ // Log in every logger that is activated.
123
+ for (const logger of this.loggers) {
124
+ if (logger.isActive()) {
125
+ logger.readableStream.push(log);
70
126
  }
71
127
  }
72
128
  }
@@ -1 +1 @@
1
- {"version":3,"file":"log.handler.js","sourceRoot":"","sources":["../../../../src/handlers/log.handler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,4BAAyB;AACzB,uCAAkE;AAClE,0DAAoD;AACpD,mDAA6C;AAE7C,gDAAkH;AAElH,0CAAqC;AAIrC,IAAa,UAAU,GAAvB,MAAa,UAAU;IAErB,YAAgF,OAA0B,EACV,6BAAqC,EAC/C,mBAA4B,EAChB,qBAA6B,EAC3F,cAA8B;QAJc,YAAO,GAAP,OAAO,CAAmB;QACV,kCAA6B,GAA7B,6BAA6B,CAAQ;QAC/C,wBAAmB,GAAnB,mBAAmB,CAAS;QAChB,0BAAqB,GAArB,qBAAqB,CAAQ;QAC3F,mBAAc,GAAd,cAAc,CAAgB;IAClE,CAAC;IAEM,KAAK,CAAC,OAAe,EAAE,KAAW,EAAE,SAAiB,aAAa;QACvE,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,4BAAY,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;IAC9D,CAAC;IAEM,QAAQ,CAAC,OAAe,EAAE,KAAW,EAAE,SAAiB,aAAa;QAC1E,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,4BAAY,CAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;IACjE,CAAC;IAEM,KAAK,CAAC,OAAe,EAAE,KAAW,EAAE,S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B,CAAC,qBAAqB,CAAC,CAAA;qEAC5B,uBAAc;GAdvD,UAAU,CAiHtB;AAjHY,gCAAU"}
@@ -5,7 +5,32 @@ const severity_enum_1 = require("../enums/severity.enum");
5
5
  const utils_1 = require("../utils/utils");
6
6
  const common_1 = require("@pristine-ts/common");
7
7
  const output_mode_enum_1 = require("../enums/output-mode.enum");
8
+ /**
9
+ * The BaseLogger is the base abstract class that all internal loggers should extend.
10
+ * It defines the basic logic that applies to all internal loggers.
11
+ * External loggers could extend the base logger but it is not mandatory.
12
+ */
8
13
  class BaseLogger {
14
+ /**
15
+ * The BaseLogger is the base abstract class that all loggers should extend.
16
+ * It defines the basic logic that applies to all loggers.
17
+ * @param numberOfStackedLogs The number of logs to keep in the stack and to print once a log with a high enough severity arrives.
18
+ * @param logSeverityLevelConfiguration The number representing the severity from which logs should be outputted.
19
+ * For example, if this is set to 3, any log that has a severity of Error(3) or critical(4) will be outputted.
20
+ * @param logDebugDepthConfiguration The number of level to go down in an object when printing a log with the Debug severity.
21
+ * We often do not need to go to the bottom layer of an object, so we can truncate at a certain depth.
22
+ * @param logInfoDepthConfiguration The number of level to go down in an object when printing a log with the Info severity.
23
+ * We often do not need to go to the bottom layer of an object, so we can truncate at a certain depth.
24
+ * @param logWarningDepthConfiguration The number of level to go down in an object when printing a log with the Warning severity.
25
+ * We often do not need to go to the bottom layer of an object, so we can truncate at a certain depth.
26
+ * @param logErrorDepthConfiguration The number of level to go down in an object when printing a log with the Error severity.
27
+ * We often do not need to go to the bottom layer of an object, so we can truncate at a certain depth.
28
+ * @param logCriticalDepthConfiguration The number of level to go down in an object when printing a log with the Critical severity.
29
+ * We often do not need to go to the bottom layer of an object, so we can truncate at a certain depth.
30
+ * @param isActivated Whether or not this particular logger is activated and should output logs.
31
+ * @param outputMode The output mode, that the logger should use.
32
+ * @param spaces The number of spaces to indent the outputted logs.
33
+ */
9
34
  constructor(numberOfStackedLogs, logSeverityLevelConfiguration, logDebugDepthConfiguration, logInfoDepthConfiguration, logWarningDepthConfiguration, logErrorDepthConfiguration, logCriticalDepthConfiguration, isActivated = true, outputMode = output_mode_enum_1.OutputModeEnum.Json, spaces = 2) {
10
35
  this.numberOfStackedLogs = numberOfStackedLogs;
11
36
  this.logSeverityLevelConfiguration = logSeverityLevelConfiguration;
@@ -17,12 +42,23 @@ class BaseLogger {
17
42
  this.isActivated = isActivated;
18
43
  this.outputMode = outputMode;
19
44
  this.spaces = spaces;
45
+ /**
46
+ * The stacked logs are the logs that were not outputted right away but that will need to be outputted if a log with a higher severity arrives.
47
+ * @private
48
+ */
20
49
  this.stackedLogs = {};
21
50
  }
51
+ /**
52
+ * Returns whether this particular logger is active and should output logs.
53
+ */
22
54
  isActive() {
23
55
  return this.isActivated;
24
56
  }
25
- outputLog(log) {
57
+ /**
58
+ * Gets the formatted output log based on a log model.
59
+ * @param log The log to be formatted.
60
+ */
61
+ getFormattedOutputLog(log) {
26
62
  switch (log.severity) {
27
63
  case severity_enum_1.SeverityEnum.Debug:
28
64
  return utils_1.Utils.outputLog(log, this.outputMode, this.logDebugDepthConfiguration);
@@ -36,6 +72,11 @@ class BaseLogger {
36
72
  return utils_1.Utils.outputLog(log, this.outputMode, this.logCriticalDepthConfiguration);
37
73
  }
38
74
  }
75
+ /**
76
+ * Captures the log and evaluates which logs need to be outputted or stacked.
77
+ * @param log The log to be captured.
78
+ * @protected
79
+ */
39
80
  captureLog(log) {
40
81
  if (this.numberOfStackedLogs > 0) {
41
82
  this.setupStackedLogsArrayIfRequired(log.traceId);
@@ -50,6 +91,11 @@ class BaseLogger {
50
91
  this.log(log);
51
92
  }
52
93
  }
94
+ /**
95
+ * Sets up the stack of logs if it is required.
96
+ * @param traceId Optional trace id to stack logs based on different requests.
97
+ * @private
98
+ */
53
99
  setupStackedLogsArrayIfRequired(traceId) {
54
100
  var _a;
55
101
  if (this.stackedLogs.hasOwnProperty(common_1.CommonModuleKeyname) === false) {
@@ -59,6 +105,11 @@ class BaseLogger {
59
105
  this.stackedLogs[traceId] = (_a = this.stackedLogs[common_1.CommonModuleKeyname]) !== null && _a !== void 0 ? _a : [];
60
106
  }
61
107
  }
108
+ /**
109
+ * Adds the log to the stacked logs and makes sure we only keep the right amount of stacked logs.
110
+ * @param log The log to be added.
111
+ * @private
112
+ */
62
113
  addStackedLog(log) {
63
114
  var _a;
64
115
  const stackedLogsKey = (_a = log.traceId) !== null && _a !== void 0 ? _a : common_1.CommonModuleKeyname;
@@ -71,6 +122,11 @@ class BaseLogger {
71
122
  } while (this.stackedLogs[stackedLogsKey].length > this.numberOfStackedLogs);
72
123
  }
73
124
  }
125
+ /**
126
+ * Outputs the stacked logs.
127
+ * @param traceId Optional trace id so that we only output the stacked logs for this trace.
128
+ * @private
129
+ */
74
130
  outputStackedLogs(traceId) {
75
131
  for (const log of this.stackedLogs[common_1.CommonModuleKeyname]) {
76
132
  this.log(log);
@@ -83,6 +139,11 @@ class BaseLogger {
83
139
  }
84
140
  this.clearStackedLogs(traceId);
85
141
  }
142
+ /**
143
+ * Clears the stacked logs.
144
+ * @param traceId Optional trace id so that we only remove the stacked logs for this trace.
145
+ * @private
146
+ */
86
147
  clearStackedLogs(traceId) {
87
148
  this.stackedLogs[common_1.CommonModuleKeyname] = [];
88
149
  if (traceId === undefined || this.stackedLogs.hasOwnProperty(traceId) === false) {
@@ -1 +1 @@
1
- {"version":3,"file":"base.logger.js","sourceRoot":"","sources":["../../../../src/loggers/base.logger.ts"],"names":[],"mappings":";;;AACA,0DAAoD;AACpD,0CAAqC;AACrC,gDAAwD;AAExD,gEAAyD;AAEzD,MAAsB,UAAU;IAG5B,YACuB,mBAA2B,EAC3B,6BAAqC,EACrC,0BAAkC,EAClC,yBAAiC,EACjC,4BAAoC,EACpC,0BAAkC,EAClC,6BAAqC,EACvC,cAAc,IAAI,EAChB,aAAa,iCAAc,CAAC,IAAI,EAChC,SAAS,CAAC;QATV,wBAAmB,GAAnB,mBAAmB,CAAQ;QAC3B,kCAA6B,GAA7B,6BAA6B,CAAQ;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AAW,CAAC,cAAc,CAAC,CAAC,KAAK,EAAE,CAAC;aAC5C,QAAQ,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC,mBAAmB,EAAC;SAC/E;IACL,CAAC;IAED;;;;OAIG;IACK,iBAAiB,CAAC,OAAgB;QACtC,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,WAAW,CAAC,4BAAmB,CAAC,EAAE;YACrD,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;SACjB;QAED,IAAI,OAAO,KAAK,SAAS,IAAI,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,OAAO,CAAC,KAAK,KAAK,EAAE;YAC7E,OAAO;SACV;QAED,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE;YACzC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;SACjB;QAED,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC;IAED;;;;OAIG;IACK,gBAAgB,CAAC,OAAgB;QACrC,IAAI,CAAC,WAAW,CAAC,4BAAmB,CAAC,GAAG,EAAE,CAAC;QAE3C,IAAI,OAAO,KAAK,SAAS,IAAI,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,OAAO,CAAC,KAAK,KAAK,EAAE;YAC7E,OAAO;SACV;QAED,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;IACnC,CAAC;CACJ;AAjLD,gCAiLC"}
@@ -20,11 +20,38 @@ const common_1 = require("@pristine-ts/common");
20
20
  const output_mode_enum_1 = require("../enums/output-mode.enum");
21
21
  const logging_module_keyname_1 = require("../logging.module.keyname");
22
22
  const base_logger_1 = require("./base.logger");
23
+ /**
24
+ * The ConsoleLogger outputs the logs in the console.
25
+ * It is registered with the tag Logger so that it can be injected along with all the other Loggers.
26
+ * It is module scoped to the logging module so that it is only registered if the logging module is imported.
27
+ */
23
28
  let ConsoleLogger = class ConsoleLogger extends base_logger_1.BaseLogger {
24
- constructor(numberOfStackedLogs, logSeverityLevelConfiguration, logDebugDepthConfiguration, logInfoDepthConfiguration, logWarningDepthConfiguration, logErrorDepthConfiguration, logCriticalDepthConfiguration, isActive, outputMode) {
25
- super(numberOfStackedLogs, logSeverityLevelConfiguration, logDebugDepthConfiguration, logInfoDepthConfiguration, logWarningDepthConfiguration, logErrorDepthConfiguration, logCriticalDepthConfiguration, isActive, outputMode);
29
+ /**
30
+ * The ConsoleLogger outputs the logs in the console.
31
+ * @param numberOfStackedLogs The number of logs to keep in the stack and to print once a log with a high enough severity arrives.
32
+ * @param logSeverityLevelConfiguration The number representing the severity from which logs should be outputted.
33
+ * For example, if this is set to 3, any log that has a severity of Error(3) or critical(4) will be outputted.
34
+ * @param logDebugDepthConfiguration The number of level to go down in an object when printing a log with the Debug severity.
35
+ * We often do not need to go to the bottom layer of an object, so we can truncate at a certain depth.
36
+ * @param logInfoDepthConfiguration The number of level to go down in an object when printing a log with the Info severity.
37
+ * We often do not need to go to the bottom layer of an object, so we can truncate at a certain depth.
38
+ * @param logWarningDepthConfiguration The number of level to go down in an object when printing a log with the Warning severity.
39
+ * We often do not need to go to the bottom layer of an object, so we can truncate at a certain depth.
40
+ * @param logErrorDepthConfiguration The number of level to go down in an object when printing a log with the Error severity.
41
+ * We often do not need to go to the bottom layer of an object, so we can truncate at a certain depth.
42
+ * @param logCriticalDepthConfiguration The number of level to go down in an object when printing a log with the Critical severity.
43
+ * We often do not need to go to the bottom layer of an object, so we can truncate at a certain depth.
44
+ * @param isActivated Whether or not this particular logger is activated and should output logs.
45
+ * @param outputMode The output mode, that the logger should use.
46
+ */
47
+ constructor(numberOfStackedLogs, logSeverityLevelConfiguration, logDebugDepthConfiguration, logInfoDepthConfiguration, logWarningDepthConfiguration, logErrorDepthConfiguration, logCriticalDepthConfiguration, isActivated, outputMode) {
48
+ super(numberOfStackedLogs, logSeverityLevelConfiguration, logDebugDepthConfiguration, logInfoDepthConfiguration, logWarningDepthConfiguration, logErrorDepthConfiguration, logCriticalDepthConfiguration, isActivated, outputMode);
26
49
  this.initialize();
27
50
  }
51
+ /**
52
+ * Initializes the console logger.
53
+ * @protected
54
+ */
28
55
  initialize() {
29
56
  if (this.isActive()) {
30
57
  this.readableStream = new stream_1.Readable({
@@ -38,8 +65,13 @@ let ConsoleLogger = class ConsoleLogger extends base_logger_1.BaseLogger {
38
65
  });
39
66
  }
40
67
  }
68
+ /**
69
+ * Outputs the log in the console.
70
+ * @param log The log to be outputted
71
+ * @protected
72
+ */
41
73
  log(log) {
42
- const outputLog = this.outputLog(log);
74
+ const outputLog = this.getFormattedOutputLog(log);
43
75
  switch (log.severity) {
44
76
  case severity_enum_1.SeverityEnum.Debug:
45
77
  console.debug(outputLog);
@@ -1 +1 @@
1
- {"version":3,"file":"console.logger.js","sourceRoot":"","sources":["../../../../src/loggers/console.logger.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uCAAwD;AACxD,0DAAoD;AAGpD,mCAAgC;AAGhC,gDAAqG;AACrG,gEAAyD;AAEzD,sEAA+D;AAC/D,+CAAyC;AAMzC,IAAa,aAAa,GAA1B,MAAa,aAAc,SAAQ,wBAAU;IAG3C,YAAqE,mBAA2B,EACjB,6BAAqC,EACxC,0BAAkC,EACnC,yBAAiC,EAC9B,4BAAoC,EACtC,0BAAkC,EAC/B,6BAAqC,EAC5C,QAAiB,EAChB,UAA0B;QAEjG,KAAK,CAAC,mBAAmB,EACrB,6BAA6B,EAC7B,0BAA0B,EAC1B,yBAAyB,EACzB,4BAA4B,EAC5B,0BAA0B,EAC1B,6BAA6B,EAC7B,QAAQ,EACR,UAAU,CAAC,CAAC;QAEhB,IAAI,CAAC,UAAU,EAAE,CAAC;IACpB,CAAC;IAES,UAAU;QAClB,IAAG,IAAI,CAAC,QAAQ,EAAE,EAAE;YAClB,IAAI,CAAC,cAAc,GAAG,IAAI,iBAAQ,CAAC;gBACjC,UAAU,EAAE,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}
@@ -24,12 +24,41 @@ const fs_1 = __importDefault(require("fs"));
24
24
  const logging_module_keyname_1 = require("../logging.module.keyname");
25
25
  const output_mode_enum_1 = require("../enums/output-mode.enum");
26
26
  const base_logger_1 = require("./base.logger");
27
+ /**
28
+ * The FileLogger outputs the logs into file.
29
+ * It is registered with the tag Logger so that it can be injected along with all the other Loggers.
30
+ * It is module scoped to the logging module so that it is only registered if the logging module is imported.
31
+ */
27
32
  let FileLogger = class FileLogger extends base_logger_1.BaseLogger {
28
- constructor(numberOfStackedLogs, logSeverityLevelConfiguration, logDebugDepthConfiguration, logInfoDepthConfiguration, logWarningDepthConfiguration, logErrorDepthConfiguration, logCriticalDepthConfiguration, isActive, outputMode, fileLoggerPretty, filePath) {
29
- super(numberOfStackedLogs, logSeverityLevelConfiguration, logDebugDepthConfiguration, logInfoDepthConfiguration, logWarningDepthConfiguration, logErrorDepthConfiguration, logCriticalDepthConfiguration, isActive, outputMode, fileLoggerPretty ? 2 : 0);
33
+ /**
34
+ * The ConsoleLogger outputs the logs in the console.
35
+ * @param numberOfStackedLogs The number of logs to keep in the stack and to print once a log with a high enough severity arrives.
36
+ * @param logSeverityLevelConfiguration The number representing the severity from which logs should be outputted.
37
+ * For example, if this is set to 3, any log that has a severity of Error(3) or critical(4) will be outputted.
38
+ * @param logDebugDepthConfiguration The number of level to go down in an object when printing a log with the Debug severity.
39
+ * We often do not need to go to the bottom layer of an object, so we can truncate at a certain depth.
40
+ * @param logInfoDepthConfiguration The number of level to go down in an object when printing a log with the Info severity.
41
+ * We often do not need to go to the bottom layer of an object, so we can truncate at a certain depth.
42
+ * @param logWarningDepthConfiguration The number of level to go down in an object when printing a log with the Warning severity.
43
+ * We often do not need to go to the bottom layer of an object, so we can truncate at a certain depth.
44
+ * @param logErrorDepthConfiguration The number of level to go down in an object when printing a log with the Error severity.
45
+ * We often do not need to go to the bottom layer of an object, so we can truncate at a certain depth.
46
+ * @param logCriticalDepthConfiguration The number of level to go down in an object when printing a log with the Critical severity.
47
+ * We often do not need to go to the bottom layer of an object, so we can truncate at a certain depth.
48
+ * @param isActivated Whether or not this particular logger is activated and should output logs.
49
+ * @param outputMode The output mode, that the logger should use.
50
+ * @param fileLoggerPretty Whether or not the file logger should prettify the output.
51
+ * @param filePath The file path where to output the log.
52
+ */
53
+ constructor(numberOfStackedLogs, logSeverityLevelConfiguration, logDebugDepthConfiguration, logInfoDepthConfiguration, logWarningDepthConfiguration, logErrorDepthConfiguration, logCriticalDepthConfiguration, isActivated, outputMode, fileLoggerPretty, filePath) {
54
+ super(numberOfStackedLogs, logSeverityLevelConfiguration, logDebugDepthConfiguration, logInfoDepthConfiguration, logWarningDepthConfiguration, logErrorDepthConfiguration, logCriticalDepthConfiguration, isActivated, outputMode, fileLoggerPretty ? 2 : 0);
30
55
  this.filePath = filePath;
31
56
  this.initialize();
32
57
  }
58
+ /**
59
+ * Initializes the file logger, and opens the write stream.
60
+ * @protected
61
+ */
33
62
  initialize() {
34
63
  if (this.isActive()) {
35
64
  this.readableStream = new stream_1.Readable({
@@ -44,8 +73,13 @@ let FileLogger = class FileLogger extends base_logger_1.BaseLogger {
44
73
  });
45
74
  }
46
75
  }
76
+ /**
77
+ * Outputs the log in the file.
78
+ * @param log The log to be outputted
79
+ * @protected
80
+ */
47
81
  log(log) {
48
- const outputLog = this.outputLog(log) + ";\n";
82
+ const outputLog = this.getFormattedOutputLog(log) + ";\n";
49
83
  switch (log.severity) {
50
84
  case severity_enum_1.SeverityEnum.Debug:
51
85
  this.writableStream.write(outputLog);
@@ -1 +1 @@
1
- {"version":3,"file":"file.logger.js","sourceRoot":"","sources":["../../../../src/loggers/file.logger.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,uCAAuD;AACvD,0DAAoD;AAGpD,mCAA0C;AAC1C,gDAAgF;AAChF,4CAAoB;AACpB,sEAA+D;AAC/D,gEAAyD;AACzD,+CAAyC;AAMzC,IAAa,UAAU,GAAvB,MAAa,UAAW,SAAQ,wBAAU;IA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GY,gCAAU"}
@@ -11,4 +11,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  __exportStar(require("./console.logger"), exports);
14
+ __exportStar(require("./file.logger"), exports);
14
15
  //# sourceMappingURL=loggers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"loggers.js","sourceRoot":"","sources":["../../../../src/loggers/loggers.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAAiC"}
1
+ {"version":3,"file":"loggers.js","sourceRoot":"","sources":["../../../../src/loggers/loggers.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAAiC;AACjC,gDAA8B"}
@@ -19,13 +19,16 @@ const severity_enum_1 = require("./enums/severity.enum");
19
19
  __exportStar(require("./enums/enums"), exports);
20
20
  __exportStar(require("./handlers/handlers"), exports);
21
21
  __exportStar(require("./interfaces/interfaces"), exports);
22
- __exportStar(require("./models/models"), exports);
23
22
  __exportStar(require("./loggers/loggers"), exports);
23
+ __exportStar(require("./models/models"), exports);
24
24
  __exportStar(require("./utils/utils"), exports);
25
25
  __exportStar(require("./logging.module.keyname"), exports);
26
26
  exports.LoggingModule = {
27
27
  keyname: logging_module_keyname_1.LoggingModuleKeyname,
28
28
  configurationDefinitions: [
29
+ /**
30
+ * The number of logs to keep in the stack and to print once a log with a high enough severity arrives.
31
+ */
29
32
  {
30
33
  parameterName: logging_module_keyname_1.LoggingModuleKeyname + ".numberOfStackedLogs",
31
34
  isRequired: false,
@@ -34,6 +37,10 @@ exports.LoggingModule = {
34
37
  new configuration_1.NumberResolver(new configuration_1.EnvironmentVariableResolver("PRISTINE_LOGGING_NUMBER_OF_STACKED_LOGS")),
35
38
  ]
36
39
  },
40
+ /**
41
+ * The number representing the severity from which logs should be outputted.
42
+ * For example, if this is set to 3, any log that has a severity of Error(3) or critical(4) will be outputted.
43
+ */
37
44
  {
38
45
  parameterName: logging_module_keyname_1.LoggingModuleKeyname + ".logSeverityLevelConfiguration",
39
46
  defaultValue: severity_enum_1.SeverityEnum.Info,
@@ -42,6 +49,10 @@ exports.LoggingModule = {
42
49
  new configuration_1.EnumResolver(new configuration_1.EnvironmentVariableResolver("PRISTINE_LOGGING_LOG_SEVERITY_LEVEL_CONFIGURATION"), severity_enum_1.SeverityEnum),
43
50
  ]
44
51
  },
52
+ /**
53
+ * The number of level to go down in an object when printing a log with the Debug severity.
54
+ * We often do not need to go to the bottom layer of an object, so we can truncate at a certain depth.
55
+ */
45
56
  {
46
57
  parameterName: logging_module_keyname_1.LoggingModuleKeyname + ".logDebugDepthConfiguration",
47
58
  defaultValue: 5,
@@ -50,6 +61,10 @@ exports.LoggingModule = {
50
61
  new configuration_1.NumberResolver(new configuration_1.EnvironmentVariableResolver("PRISTINE_LOGGING_LOG_DEBUG_DEPTH_CONFIGURATION")),
51
62
  ]
52
63
  },
64
+ /**
65
+ * The number of level to go down in an object when printing a log with the Info severity.
66
+ * We often do not need to go to the bottom layer of an object, so we can truncate at a certain depth.
67
+ */
53
68
  {
54
69
  parameterName: logging_module_keyname_1.LoggingModuleKeyname + ".logInfoDepthConfiguration",
55
70
  defaultValue: 5,
@@ -58,6 +73,10 @@ exports.LoggingModule = {
58
73
  new configuration_1.NumberResolver(new configuration_1.EnvironmentVariableResolver("PRISTINE_LOGGING_LOG_INFO_DEPTH_CONFIGURATION")),
59
74
  ]
60
75
  },
76
+ /**
77
+ * The number of level to go down in an object when printing a log with the Warning severity.
78
+ * We often do not need to go to the bottom layer of an object, so we can truncate at a certain depth.
79
+ */
61
80
  {
62
81
  parameterName: logging_module_keyname_1.LoggingModuleKeyname + ".logWarningDepthConfiguration",
63
82
  defaultValue: 5,
@@ -66,6 +85,10 @@ exports.LoggingModule = {
66
85
  new configuration_1.NumberResolver(new configuration_1.EnvironmentVariableResolver("PRISTINE_LOGGING_LOG_WARNING_DEPTH_CONFIGURATION")),
67
86
  ]
68
87
  },
88
+ /**
89
+ * The number of level to go down in an object when printing a log with the Error severity.
90
+ * We often do not need to go to the bottom layer of an object, so we can truncate at a certain depth.
91
+ */
69
92
  {
70
93
  parameterName: logging_module_keyname_1.LoggingModuleKeyname + ".logErrorDepthConfiguration",
71
94
  defaultValue: 5,
@@ -74,6 +97,10 @@ exports.LoggingModule = {
74
97
  new configuration_1.NumberResolver(new configuration_1.EnvironmentVariableResolver("PRISTINE_LOGGING_LOG_ERROR_DEPTH_CONFIGURATION")),
75
98
  ]
76
99
  },
100
+ /**
101
+ * The number of level to go down in an object when printing a log with the Critical severity.
102
+ * We often do not need to go to the bottom layer of an object, so we can truncate at a certain depth.
103
+ */
77
104
  {
78
105
  parameterName: logging_module_keyname_1.LoggingModuleKeyname + ".logCriticalDepthConfiguration",
79
106
  defaultValue: 5,
@@ -82,6 +109,9 @@ exports.LoggingModule = {
82
109
  new configuration_1.NumberResolver(new configuration_1.EnvironmentVariableResolver("PRISTINE_LOGGING_LOG_CRITICAL_DEPTH_CONFIGURATION")),
83
110
  ]
84
111
  },
112
+ /**
113
+ * Whether or not the console logger is activated and should output logs.
114
+ */
85
115
  {
86
116
  parameterName: logging_module_keyname_1.LoggingModuleKeyname + ".consoleLoggerActivated",
87
117
  defaultValue: true,
@@ -90,6 +120,9 @@ exports.LoggingModule = {
90
120
  new configuration_1.BooleanResolver(new configuration_1.EnvironmentVariableResolver("PRISTINE_LOGGING_CONSOLE_LOGGER_ACTIVATED")),
91
121
  ]
92
122
  },
123
+ /**
124
+ * The output mode, that the console logger should use from the OutputModeEnum.
125
+ */
93
126
  {
94
127
  parameterName: logging_module_keyname_1.LoggingModuleKeyname + ".consoleLoggerOutputMode",
95
128
  defaultValue: output_mode_enum_1.OutputModeEnum.Json,
@@ -98,6 +131,9 @@ exports.LoggingModule = {
98
131
  new configuration_1.EnumResolver(new configuration_1.EnvironmentVariableResolver("PRISTINE_LOGGING_CONSOLE_LOGGER_OUTPUT_MODE"), output_mode_enum_1.OutputModeEnum),
99
132
  ]
100
133
  },
134
+ /**
135
+ * The output mode, that the file logger should use from the OutputModeEnum.
136
+ */
101
137
  {
102
138
  parameterName: logging_module_keyname_1.LoggingModuleKeyname + ".fileLoggerOutputMode",
103
139
  defaultValue: output_mode_enum_1.OutputModeEnum.Json,
@@ -106,6 +142,9 @@ exports.LoggingModule = {
106
142
  new configuration_1.EnumResolver(new configuration_1.EnvironmentVariableResolver("PRISTINE_LOGGING_FILE_LOGGER_OUTPUT_MODE"), output_mode_enum_1.OutputModeEnum),
107
143
  ]
108
144
  },
145
+ /**
146
+ * Whether or not the console logger is activated and should output logs.
147
+ */
109
148
  {
110
149
  parameterName: logging_module_keyname_1.LoggingModuleKeyname + ".fileLoggerActivated",
111
150
  defaultValue: false,
@@ -114,6 +153,9 @@ exports.LoggingModule = {
114
153
  new configuration_1.BooleanResolver(new configuration_1.EnvironmentVariableResolver("PRISTINE_LOGGING_FILE_LOGGER_ACTIVATED")),
115
154
  ]
116
155
  },
156
+ /**
157
+ * The file path to which the file logger should output the logs.
158
+ */
117
159
  {
118
160
  parameterName: logging_module_keyname_1.LoggingModuleKeyname + ".filePath",
119
161
  defaultValue: "./logs.txt",
@@ -122,6 +164,9 @@ exports.LoggingModule = {
122
164
  new configuration_1.BooleanResolver(new configuration_1.EnvironmentVariableResolver("PRISTINE_LOGGING_FILE_PATH")),
123
165
  ]
124
166
  },
167
+ /**
168
+ * Whether or not the file logger should prettify the outputted logs.
169
+ */
125
170
  {
126
171
  parameterName: logging_module_keyname_1.LoggingModuleKeyname + ".fileLoggerPretty",
127
172
  defaultValue: false,
@@ -130,6 +175,11 @@ exports.LoggingModule = {
130
175
  new configuration_1.BooleanResolver(new configuration_1.EnvironmentVariableResolver("PRISTINE_LOGGING_FILE_LOGGER_PRETTY")),
131
176
  ]
132
177
  },
178
+ /**
179
+ * Whether or not the diagnostic should be activated.
180
+ * When activated, the stack trace and other diagnostic information will be added to the logs.
181
+ * This is an intensive process and can dramatically reduce the performance of the code.
182
+ */
133
183
  {
134
184
  parameterName: logging_module_keyname_1.LoggingModuleKeyname + ".activateDiagnostics",
135
185
  defaultValue: false,
@@ -1 +1 @@
1
- {"version":3,"file":"logging.module.js","sourceRoot":"","sources":["../../../src/logging.module.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,qEAA8D;AAC9D,8DAKoC;AACpC,+DAAwD;AACxD,gDAAiD;AACjD,yDAAmD;AAEnD,gDAA8B;AAC9B,sDAAoC;AACpC,0DAAwC;AACxC,kDAAgC;AAChC,oDAAkC;AAClC,gDAA8B;AAC9B,2DAAwC;AAE3B,QAAA,aAAa,GAAoB;IAC1C,OAAO,EAAE,6CAAoB;IAC7B,wBAAwB,EAAE;QACtB;YACI,aAAa,EAAE,6CAAoB,GAAG,sBAAsB;YAC5D,UAAU,EAAE,KAAK;YACjB,YAAY,EAAE,EAAE;YAChB,gBAAgB,EAAE;gBACd,IAAI,8BAAc,CAAC,IAAI,2CAA2B,CAAC,yCAAyC,CAAC,CAAC;aACjG;SACJ;QACD;YACI,aAAa,EAAE,6CAAoB,GAAG,gCAAgC;YACtE,YAAY,EAAE,4BAAY,CAAC,IAAI;YAC/B,UAAU,EAAE,KAAK;YACjB,gBAAgB,EAAE;gBACd,IAAI,4BAAY,CAAC,IAAI,2CAA2B,CAAC,mDAAmD,CAAC,EAAE,4BAAY,CAAC;aACvH;SACJ;QACD;YACI,aAAa,EAAE,6CAAoB,GAAG,6BAA6B;YACnE,YAAY,EAAE,CAAC;YACf,UAAU,EAAE,KAAK;YACjB,gBAAgB,EAAE;gBACd,IAAI,8BAAc,CAAC,IAAI,2CAA2B,CAAC,gDAAgD,CAAC,CAAC;aACxG;SACJ;QACD;YACI,aAAa,EAAE,6CAAoB,GAAG,4BAA4B;YAClE,YAAY,EAAE,CAAC;YACf,UAAU,EAAE,KAAK;YACjB,gBAAgB,EAAE;gBACd,IAAI,8BAAc,CAAC,IAAI,2CAA2B,CAAC,+CAA+C,CAAC,CAAC;aACvG;SACJ;QACD;YACI,aAAa,EAAE,6CAAoB,GAAG,+BAA+B;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,UAAU,EAAE,KAAK;YACjB,gBAAgB,EAAE;gBACd,IAAI,+BAAe,CAAC,IAAI,2CAA2B,CAAC,wCAAwC,CAAC,CAAC;aACjG;SACJ;QACD;YACI,aAAa,EAAE,6CAAoB,GAAG,WAAW;YACjD,YAAY,EAAE,YAAY;YAC1B,UAAU,EAAE,KAAK;YACjB,gBAAgB,EAAE;gBACd,IAAI,+BAAe,CAAC,IAAI,2CAA2B,CAAC,4BAA4B,CAAC,CAAC;aACrF;SACJ;QACD;YACI,aAAa,EAAE,6CAAoB,GAAG,mBAAmB;YACzD,YAAY,EAAE,KAAK;YACnB,UAAU,EAAE,KAAK;YACjB,gBAAgB,EAAE;gBACd,IAAI,+BAAe,CAAC,IAAI,2CAA2B,CAAC,qCAAqC,CAAC,CAAC;aAC9F;SACJ;QACD;YACI,aAAa,EAAE,6CAAoB,GAAG,sBAAsB;YAC5D,YAAY,EAAE,KAAK;YACnB,UAAU,EAAE,KAAK;YACjB,gBAAgB,EAAE;gBACd,IAAI,+BAAe,CAAC,IAAI,2CAA2B,CAAC,uCAAuC,CAAC,CAAC;aAChG;SACJ;KACJ;IACD,aAAa,EAAE;QACX,qBAAY;QACZ,mCAAmB;KACtB;IACD,qBAAqB,EAAE,EAAE;CAC5B,CAAC"}
1
+ {"version":3,"file":"logging.module.js","sourceRoot":"","sources":["../../../src/logging.module.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,qEAA8D;AAC9D,8DAKoC;AACpC,+DAAwD;AACxD,gDAAiD;AACjD,yDAAmD;AAEnD,gDAA8B;AAC9B,sDAAoC;AACpC,0DAAwC;AACxC,oDAAkC;AAClC,kDAAgC;AAChC,gDAA8B;AAC9B,2DAAwC;AAE3B,QAAA,aAAa,GAAoB;IAC1C,OAAO,EAAE,6CAAoB;IAC7B,wBAAwB,EAAE;QACtB;;WAEG;QACH;YACI,aAAa,EAAE,6CAAoB,GAAG,sBAAsB;YAC5D,UAAU,EAAE,KAAK;YACjB,YAAY,EAAE,EAA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