@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
@@ -6,13 +6,16 @@ import { SeverityEnum } from "./enums/severity.enum";
6
6
  export * from "./enums/enums";
7
7
  export * from "./handlers/handlers";
8
8
  export * from "./interfaces/interfaces";
9
- export * from "./models/models";
10
9
  export * from "./loggers/loggers";
10
+ export * from "./models/models";
11
11
  export * from "./utils/utils";
12
12
  export * from "./logging.module.keyname";
13
13
  export const LoggingModule = {
14
14
  keyname: LoggingModuleKeyname,
15
15
  configurationDefinitions: [
16
+ /**
17
+ * The number of logs to keep in the stack and to print once a log with a high enough severity arrives.
18
+ */
16
19
  {
17
20
  parameterName: LoggingModuleKeyname + ".numberOfStackedLogs",
18
21
  isRequired: false,
@@ -21,6 +24,10 @@ export const LoggingModule = {
21
24
  new NumberResolver(new EnvironmentVariableResolver("PRISTINE_LOGGING_NUMBER_OF_STACKED_LOGS")),
22
25
  ]
23
26
  },
27
+ /**
28
+ * The number representing the severity from which logs should be outputted.
29
+ * For example, if this is set to 3, any log that has a severity of Error(3) or critical(4) will be outputted.
30
+ */
24
31
  {
25
32
  parameterName: LoggingModuleKeyname + ".logSeverityLevelConfiguration",
26
33
  defaultValue: SeverityEnum.Info,
@@ -29,6 +36,10 @@ export const LoggingModule = {
29
36
  new EnumResolver(new EnvironmentVariableResolver("PRISTINE_LOGGING_LOG_SEVERITY_LEVEL_CONFIGURATION"), SeverityEnum),
30
37
  ]
31
38
  },
39
+ /**
40
+ * The number of level to go down in an object when printing a log with the Debug 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
+ */
32
43
  {
33
44
  parameterName: LoggingModuleKeyname + ".logDebugDepthConfiguration",
34
45
  defaultValue: 5,
@@ -37,6 +48,10 @@ export const LoggingModule = {
37
48
  new NumberResolver(new EnvironmentVariableResolver("PRISTINE_LOGGING_LOG_DEBUG_DEPTH_CONFIGURATION")),
38
49
  ]
39
50
  },
51
+ /**
52
+ * The number of level to go down in an object when printing a log with the Info severity.
53
+ * We often do not need to go to the bottom layer of an object, so we can truncate at a certain depth.
54
+ */
40
55
  {
41
56
  parameterName: LoggingModuleKeyname + ".logInfoDepthConfiguration",
42
57
  defaultValue: 5,
@@ -45,6 +60,10 @@ export const LoggingModule = {
45
60
  new NumberResolver(new EnvironmentVariableResolver("PRISTINE_LOGGING_LOG_INFO_DEPTH_CONFIGURATION")),
46
61
  ]
47
62
  },
63
+ /**
64
+ * The number of level to go down in an object when printing a log with the Warning severity.
65
+ * We often do not need to go to the bottom layer of an object, so we can truncate at a certain depth.
66
+ */
48
67
  {
49
68
  parameterName: LoggingModuleKeyname + ".logWarningDepthConfiguration",
50
69
  defaultValue: 5,
@@ -53,6 +72,10 @@ export const LoggingModule = {
53
72
  new NumberResolver(new EnvironmentVariableResolver("PRISTINE_LOGGING_LOG_WARNING_DEPTH_CONFIGURATION")),
54
73
  ]
55
74
  },
75
+ /**
76
+ * The number of level to go down in an object when printing a log with the Error severity.
77
+ * We often do not need to go to the bottom layer of an object, so we can truncate at a certain depth.
78
+ */
56
79
  {
57
80
  parameterName: LoggingModuleKeyname + ".logErrorDepthConfiguration",
58
81
  defaultValue: 5,
@@ -61,6 +84,10 @@ export const LoggingModule = {
61
84
  new NumberResolver(new EnvironmentVariableResolver("PRISTINE_LOGGING_LOG_ERROR_DEPTH_CONFIGURATION")),
62
85
  ]
63
86
  },
87
+ /**
88
+ * The number of level to go down in an object when printing a log with the Critical severity.
89
+ * We often do not need to go to the bottom layer of an object, so we can truncate at a certain depth.
90
+ */
64
91
  {
65
92
  parameterName: LoggingModuleKeyname + ".logCriticalDepthConfiguration",
66
93
  defaultValue: 5,
@@ -69,6 +96,9 @@ export const LoggingModule = {
69
96
  new NumberResolver(new EnvironmentVariableResolver("PRISTINE_LOGGING_LOG_CRITICAL_DEPTH_CONFIGURATION")),
70
97
  ]
71
98
  },
99
+ /**
100
+ * Whether or not the console logger is activated and should output logs.
101
+ */
72
102
  {
73
103
  parameterName: LoggingModuleKeyname + ".consoleLoggerActivated",
74
104
  defaultValue: true,
@@ -77,6 +107,9 @@ export const LoggingModule = {
77
107
  new BooleanResolver(new EnvironmentVariableResolver("PRISTINE_LOGGING_CONSOLE_LOGGER_ACTIVATED")),
78
108
  ]
79
109
  },
110
+ /**
111
+ * The output mode, that the console logger should use from the OutputModeEnum.
112
+ */
80
113
  {
81
114
  parameterName: LoggingModuleKeyname + ".consoleLoggerOutputMode",
82
115
  defaultValue: OutputModeEnum.Json,
@@ -85,6 +118,9 @@ export const LoggingModule = {
85
118
  new EnumResolver(new EnvironmentVariableResolver("PRISTINE_LOGGING_CONSOLE_LOGGER_OUTPUT_MODE"), OutputModeEnum),
86
119
  ]
87
120
  },
121
+ /**
122
+ * The output mode, that the file logger should use from the OutputModeEnum.
123
+ */
88
124
  {
89
125
  parameterName: LoggingModuleKeyname + ".fileLoggerOutputMode",
90
126
  defaultValue: OutputModeEnum.Json,
@@ -93,6 +129,9 @@ export const LoggingModule = {
93
129
  new EnumResolver(new EnvironmentVariableResolver("PRISTINE_LOGGING_FILE_LOGGER_OUTPUT_MODE"), OutputModeEnum),
94
130
  ]
95
131
  },
132
+ /**
133
+ * Whether or not the console logger is activated and should output logs.
134
+ */
96
135
  {
97
136
  parameterName: LoggingModuleKeyname + ".fileLoggerActivated",
98
137
  defaultValue: false,
@@ -101,6 +140,9 @@ export const LoggingModule = {
101
140
  new BooleanResolver(new EnvironmentVariableResolver("PRISTINE_LOGGING_FILE_LOGGER_ACTIVATED")),
102
141
  ]
103
142
  },
143
+ /**
144
+ * The file path to which the file logger should output the logs.
145
+ */
104
146
  {
105
147
  parameterName: LoggingModuleKeyname + ".filePath",
106
148
  defaultValue: "./logs.txt",
@@ -109,6 +151,9 @@ export const LoggingModule = {
109
151
  new BooleanResolver(new EnvironmentVariableResolver("PRISTINE_LOGGING_FILE_PATH")),
110
152
  ]
111
153
  },
154
+ /**
155
+ * Whether or not the file logger should prettify the outputted logs.
156
+ */
112
157
  {
113
158
  parameterName: LoggingModuleKeyname + ".fileLoggerPretty",
114
159
  defaultValue: false,
@@ -117,6 +162,11 @@ export const LoggingModule = {
117
162
  new BooleanResolver(new EnvironmentVariableResolver("PRISTINE_LOGGING_FILE_LOGGER_PRETTY")),
118
163
  ]
119
164
  },
165
+ /**
166
+ * Whether or not the diagnostic should be activated.
167
+ * When activated, the stack trace and other diagnostic information will be added to the logs.
168
+ * This is an intensive process and can dramatically reduce the performance of the code.
169
+ */
120
170
  {
121
171
  parameterName: LoggingModuleKeyname + ".activateDiagnostics",
122
172
  defaultValue: false,
@@ -1 +1 @@
1
- {"version":3,"file":"logging.module.js","sourceRoot":"","sources":["../../../src/logging.module.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,oBAAoB,EAAC,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EACH,eAAe,EACf,mBAAmB,EAAE,YAAY,EACjC,2BAA2B,EAC3B,cAAc,EACjB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAC,cAAc,EAAC,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAC,YAAY,EAAC,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAC,YAAY,EAAC,MAAM,uBAAuB,CAAC;AAEnD,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,0BAA0B,CAAA;AAExC,MAAM,CAAC,MAAM,aAAa,GAAoB;IAC1C,OAAO,EAAE,oBAAoB;IAC7B,wBAAwB,EAAE;QACtB;YACI,aAAa,EAAE,oBAAoB,GAAG,sBAAsB;YAC5D,UAAU,EAAE,KAAK;YACjB,YAAY,EAAE,EAAE;YAChB,gBAAgB,EAAE;gBACd,IAAI,cAAc,CAAC,IAAI,2BAA2B,CAAC,yCAAyC,CAAC,CAAC;aACjG;SACJ;QACD;YACI,aAAa,EAAE,oBAAoB,GAAG,gCAAgC;YACtE,YAAY,EAAE,YAAY,CAAC,IAAI;YAC/B,UAAU,EAAE,KAAK;YACjB,gBAAgB,EAAE;gBACd,IAAI,YAAY,CAAC,IAAI,2BAA2B,CAAC,mDAAmD,CAAC,EAAE,YAAY,CAAC;aACvH;SACJ;QACD;YACI,aAAa,EAAE,oBAAoB,GAAG,6BAA6B;YACnE,YAAY,EAAE,CAAC;YACf,UAAU,EAAE,KAAK;YACjB,gBAAgB,E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;aACnH;SACJ;QACD;YACI,aAAa,EAAE,oBAAoB,GAAG,uBAAuB;YAC7D,YAAY,EAAE,cAAc,CAAC,IAAI;YACjC,UAAU,EAAE,KAAK;YACjB,gBAAgB,EAAE;gBACd,IAAI,YAAY,CAAC,IAAI,2BAA2B,CAAC,0CAA0C,CAAC,EAAE,cAAc,CAAC;aAChH;SACJ;QACD;YACI,aAAa,EAAE,oBAAoB,GAAG,sBAAsB;YAC5D,YAAY,EAAE,KAAK;YACnB,UAAU,EAAE,KAAK;YACjB,gBAAgB,EAAE;gBACd,IAAI,eAAe,CAAC,IAAI,2BAA2B,CAAC,wCAAwC,CAAC,CAAC;aACjG;SACJ;QACD;YACI,aAAa,EAAE,oBAAoB,GAAG,WAAW;YACjD,YAAY,EAAE,YAAY;YAC1B,UAAU,EAAE,KAAK;YACjB,gBAAgB,EAAE;gBACd,IAAI,eAAe,CAAC,IAAI,2BAA2B,CAAC,4BAA4B,CAAC,CAAC;aACrF;SACJ;QACD;YACI,aAAa,EAAE,oBAAoB,GAAG,mBAAmB;YACzD,YAAY,EAAE,KAAK;YACnB,UAAU,EAAE,KAAK;YACjB,gBAAgB,EAAE;gBACd,IAAI,eAAe,CAAC,IAAI,2BAA2B,CAAC,qCAAqC,CAAC,CAAC;aAC9F;SACJ;QACD;YACI,aAAa,EAAE,oBAAoB,GAAG,sBAAsB;YAC5D,YAAY,EAAE,KAAK;YACnB,UAAU,EAAE,KAAK;YACjB,gBAAgB,EAAE;gBACd,IAAI,eAAe,CAAC,IAAI,2BAA2B,CAAC,uCAAuC,CAAC,CAAC;aAChG;SACJ;KACJ;IACD,aAAa,EAAE;QACX,YAAY;QACZ,mBAAmB;KACtB;IACD,qBAAqB,EAAE,EAAE;CAC5B,CAAC"}
1
+ {"version":3,"file":"logging.module.js","sourceRoot":"","sources":["../../../src/logging.module.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,oBAAoB,EAAC,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EACH,eAAe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C,IAAI;YACjC,UAAU,EAAE,KAAK;YACjB,gBAAgB,EAAE;gBACd,IAAI,YAAY,CAAC,IAAI,2BAA2B,CAAC,0CAA0C,CAAC,EAAE,cAAc,CAAC;aAChH;SACJ;QACD;;WAEG;QACH;YACI,aAAa,EAAE,oBAAoB,GAAG,sBAAsB;YAC5D,YAAY,EAAE,KAAK;YACnB,UAAU,EAAE,KAAK;YACjB,gBAAgB,EAAE;gBACd,IAAI,eAAe,CAAC,IAAI,2BAA2B,CAAC,wCAAwC,CAAC,CAAC;aACjG;SACJ;QACD;;WAEG;QACH;YACI,aAAa,EAAE,oBAAoB,GAAG,WAAW;YACjD,YAAY,EAAE,YAAY;YAC1B,UAAU,EAAE,KAAK;YACjB,gBAAgB,EAAE;gBACd,IAAI,eAAe,CAAC,IAAI,2BAA2B,CAAC,4BAA4B,CAAC,CAAC;aACrF;SACJ;QACD;;WAEG;QACH;YACI,aAAa,EAAE,oBAAoB,GAAG,mBAAmB;YACzD,YAAY,EAAE,KAAK;YACnB,UAAU,EAAE,KAAK;YACjB,gBAAgB,EAAE;gBACd,IAAI,eAAe,CAAC,IAAI,2BAA2B,CAAC,qCAAqC,CAAC,CAAC;aAC9F;SACJ;QACD;;;;WAIG;QACH;YACI,aAAa,EAAE,oBAAoB,GAAG,sBAAsB;YAC5D,YAAY,EAAE,KAAK;YACnB,UAAU,EAAE,KAAK;YACjB,gBAAgB,EAAE;gBACd,IAAI,eAAe,CAAC,IAAI,2BAA2B,CAAC,uCAAuC,CAAC,CAAC;aAChG;SACJ;KACJ;IACD,aAAa,EAAE;QACX,YAAY;QACZ,mBAAmB;KACtB;IACD,qBAAqB,EAAE,EAAE;CAC5B,CAAC"}
@@ -1,5 +1,12 @@
1
+ /**
2
+ * The diagnostic model represents detailed information to help debug that will be outputted in the extras of the log
3
+ * when diagnostic is enabled.
4
+ */
1
5
  export class DiagnosticsModel {
2
6
  constructor() {
7
+ /**
8
+ * An array representing the stack trace from which the log originated.
9
+ */
3
10
  this.stackTrace = [];
4
11
  }
5
12
  }
@@ -1 +1 @@
1
- {"version":3,"file":"diagnostics.model.js","sourceRoot":"","sources":["../../../../src/models/diagnostics.model.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,gBAAgB;IAA7B;QAEI,eAAU,GAKJ,EAAE,CAAC;IAOb,CAAC;CAAA"}
1
+ {"version":3,"file":"diagnostics.model.js","sourceRoot":"","sources":["../../../../src/models/diagnostics.model.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,OAAO,gBAAgB;IAA7B;QAOI;;WAEG;QACH,eAAU,GAoBJ,EAAE,CAAC;IA0Bb,CAAC;CAAA"}
@@ -1,8 +1,23 @@
1
+ /**
2
+ * The model that represents a log
3
+ */
1
4
  export class LogModel {
5
+ /**
6
+ * The model that represents a log
7
+ * @param severity The log severity.
8
+ * @param message The actual log message that needs to be outputted.
9
+ */
2
10
  constructor(severity, message) {
3
11
  this.severity = severity;
4
12
  this.message = message;
13
+ /**
14
+ * The date at which the log was created.
15
+ */
5
16
  this.date = new Date();
17
+ /**
18
+ * The module from which the log originated.
19
+ * By default it will be the application module.
20
+ */
6
21
  this.module = "application";
7
22
  }
8
23
  }
@@ -1 +1 @@
1
- {"version":3,"file":"log.model.js","sourceRoot":"","sources":["../../../../src/models/log.model.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,QAAQ;IAOnB,YAAmB,QAAsB,EAAS,OAAe;QAA9C,aAAQ,GAAR,QAAQ,CAAc;QAAS,YAAO,GAAP,OAAO,CAAQ;QALjE,SAAI,GAAS,IAAI,IAAI,EAAE,CAAC;QACxB,WAAM,GAAW,aAAa,CAAC;IAK/B,CAAC;CAEF"}
1
+ {"version":3,"file":"log.model.js","sourceRoot":"","sources":["../../../../src/models/log.model.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,OAAO,QAAQ;IA2BnB;;;;OAIG;IACH,YAAmB,QAAsB,EAAS,OAAe;QAA9C,aAAQ,GAAR,QAAQ,CAAc;QAAS,YAAO,GAAP,OAAO,CAAQ;QArBjE;;WAEG;QACH,SAAI,GAAS,IAAI,IAAI,EAAE,CAAC;QAExB;;;WAGG;QACH,WAAM,GAAW,aAAa,CAAC;IAa/B,CAAC;CAEF"}
@@ -2,13 +2,28 @@ import { OutputModeEnum } from "../enums/output-mode.enum";
2
2
  import { SeverityEnum } from "../enums/severity.enum";
3
3
  import format from "date-fns/format";
4
4
  import { DiagnosticsModel } from "../models/diagnostics.model";
5
+ /**
6
+ * This class provides some utility functions to help with the logging.
7
+ */
5
8
  export class Utils {
9
+ /**
10
+ * Returns whether or not the value is defined
11
+ * @param val
12
+ */
6
13
  static isDefined(val) {
7
14
  return val !== null && val !== undefined;
8
15
  }
16
+ /**
17
+ * Returns whether or not the value is flat, meaning it is not an object.
18
+ * @param val
19
+ */
9
20
  static isFlat(val) {
10
21
  return !this.isDefined(val) || ~this.flatTypes.indexOf(val.constructor);
11
22
  }
23
+ /**
24
+ * Gets the deep keys of an object.
25
+ * @param obj The object.
26
+ */
12
27
  static getDeepKeys(obj) {
13
28
  let subkeys;
14
29
  let keys = [];
@@ -27,6 +42,12 @@ export class Utils {
27
42
  }
28
43
  return keys;
29
44
  }
45
+ /**
46
+ * This function truncates an object to the max depth required.
47
+ * @param object The object to truncate.
48
+ * @param maxDepth The max depth of the object.
49
+ * @param curDepth The current depth at which we are at.
50
+ */
30
51
  static truncate(object, maxDepth, curDepth = 0) {
31
52
  if (curDepth < maxDepth) {
32
53
  const newDepth = curDepth + 1;
@@ -60,6 +81,10 @@ export class Utils {
60
81
  }
61
82
  return;
62
83
  }
84
+ /**
85
+ * Gets the string representing a value of the log severity enum.
86
+ * @param logSeverity The log severity for which to get the string representation.
87
+ */
63
88
  static getSeverityText(logSeverity) {
64
89
  switch (logSeverity) {
65
90
  case SeverityEnum.Debug:
@@ -74,6 +99,13 @@ export class Utils {
74
99
  return "CRITICAL";
75
100
  }
76
101
  }
102
+ /**
103
+ * Returns the string formatted log based on the output model.
104
+ * @param log The log to be string formatted.
105
+ * @param outputMode The output mode desired.
106
+ * @param logDepth The log depth.
107
+ * @param spaceNumber The number of spaces for a tab.
108
+ */
77
109
  static outputLog(log, outputMode, logDepth, spaceNumber = 0) {
78
110
  const jsonSortOrders = ["severity", "message", "date", "module", "traceId", "kernelInstantiationId"];
79
111
  switch (outputMode) {
@@ -87,6 +119,10 @@ export class Utils {
87
119
  return format(log.date, "yyyy-MM-dd HH:mm:ss") + " - " + " [" + this.getSeverityText(log.severity) + "] - " + log.message + " - " + JSON.stringify(Utils.truncate(log.extra, 2));
88
120
  }
89
121
  }
122
+ /**
123
+ * Creates the diagnostic model from an error object to attach to a log.
124
+ * @param error The error object from which to get the stack trace.
125
+ */
90
126
  static getDiagnostics(error) {
91
127
  const diagnostics = new DiagnosticsModel();
92
128
  const errorStack = error.stack;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/utils/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,cAAc,EAAC,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAC,YAAY,EAAC,MAAM,wBAAwB,CAAC;AACpD,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAC,gBAAgB,EAAC,MAAM,6BAA6B,CAAC;AAG7D,MAAM,OAAO,KAAK;IAIP,MAAM,CAAC,SAAS,CAAC,GAAQ;QAC5B,OAAO,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS,CAAC;IAC7C,CAAC;IAEM,MAAM,CAAC,MAAM,CAAC,GAAQ;QACzB,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;IAC3E,CAAC;IAEM,MAAM,CAAC,WAAW,CAAC,GAAQ;QAC9B,IAAI,OAAiB,CAAC;QACtB,IAAI,IAAI,GAAa,EAAE,CAAC;QACxB,KAAK,IAAI,GA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AK,CAAC,KAAK,CAAC;QAE/B,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,8DAA8D,EAAE,GAAG,CAAC,CAAC;QAE9F,IAAI,UAAU,KAAK,SAAS,EAAE;YAC1B,OAAO,WAAW,CAAC;SACtB;QAED,IAAI,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAEnC,OAAO,KAAK,KAAK,IAAI,EAAE;YACnB,MAAM,UAAU,GAAG;gBACf,SAAS,EAAG,KAAK,CAAC,CAAC,CAAC;gBACpB,QAAQ,EAAG,KAAK,CAAC,CAAC,CAAC;gBACnB,IAAI,EAAG,KAAK,CAAC,CAAC,CAAC;gBACf,MAAM,EAAG,KAAK,CAAC,CAAC,CAAC;aACpB,CAAC;YAEF,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAExC,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;SAClC;QAED,IAAG,WAAW,CAAC,cAAc,KAAK,SAAS,IAAI,WAAW,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE;YAC9E,WAAW,CAAC,cAAc,GAAG,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;SAC1D;QAED,OAAO,WAAW,CAAC;IACvB,CAAC;;AAnKM,eAAS,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAA"}
@@ -1,4 +1,13 @@
1
+ /**
2
+ * Output mode for the logs.
3
+ */
1
4
  export declare enum OutputModeEnum {
5
+ /**
6
+ * The logs will output a JSON format.
7
+ */
2
8
  Json = "JSON",
9
+ /**
10
+ * The logs will output a simple string format.
11
+ */
3
12
  Simple = "SIMPLE"
4
13
  }
@@ -1,3 +1,6 @@
1
+ /**
2
+ * The severity supported for logging purposes.
3
+ */
1
4
  export declare enum SeverityEnum {
2
5
  Critical = 4,
3
6
  Error = 3,
@@ -2,17 +2,72 @@ import "reflect-metadata";
2
2
  import { LoggerInterface } from "../interfaces/logger.interface";
3
3
  import { TracingContext } from "@pristine-ts/common";
4
4
  import { LogHandlerInterface } from "../interfaces/log-handler.interface";
5
+ /**
6
+ * The LogHandler to use when we want to output some logs.
7
+ * This handler makes sure that only the right level of logs are outputted, stacks logs, and logs with different loggers.
8
+ * It is registered with the tag LogHandlerInterface so that it can be injected as a LogHandlerInterface to facilitate mocking.
9
+ */
5
10
  export declare class LogHandler implements LogHandlerInterface {
6
11
  private readonly loggers;
7
12
  private readonly logSeverityLevelConfiguration;
8
13
  private readonly activateDiagnostics;
9
14
  private readonly kernelInstantiationId;
10
15
  private readonly tracingContext;
16
+ /**
17
+ * The LogHandler to use when we want to output some logs.
18
+ * @param loggers The loggers to use to output the logs. All services with the tag ServiceDefinitionTagEnum.Logger will be automatically injected here.
19
+ * @param logSeverityLevelConfiguration The severity from which to start logging the logs.
20
+ * @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.
21
+ * @param kernelInstantiationId The id of instantiation of the kernel.
22
+ * @param tracingContext The context of the tracing.
23
+ */
11
24
  constructor(loggers: LoggerInterface[], logSeverityLevelConfiguration: number, activateDiagnostics: boolean, kernelInstantiationId: string, tracingContext: TracingContext);
12
- error(message: string, extra?: any, module?: string): void;
25
+ /**
26
+ * Logs the message if the severity is set to critical or above.
27
+ * This function is wrapper function for the log method with the proper severity to make it cleaner when using it in the code.
28
+ * @param message The message to log.
29
+ * @param extra The extra object to log.
30
+ * @param module The module from where the log was created.
31
+ */
13
32
  critical(message: string, extra?: any, module?: string): void;
14
- debug(message: string, extra?: any, module?: string): void;
15
- info(message: string, extra?: any, module?: string): void;
33
+ /**
34
+ * Logs the message if the severity is set to error or above.
35
+ * This function is wrapper function for the log method with the proper severity to make it cleaner when using it in the code.
36
+ * @param message The message to log.
37
+ * @param extra The extra object to log.
38
+ * @param module The module from where the log was created.
39
+ */
40
+ error(message: string, extra?: any, module?: string): void;
41
+ /**
42
+ * Logs the message if the severity is set to warning or above.
43
+ * This function is wrapper function for the log method with the proper severity to make it cleaner when using it in the code.
44
+ * @param message The message to log.
45
+ * @param extra The extra object to log.
46
+ * @param module The module from where the log was created.
47
+ */
16
48
  warning(message: string, extra?: any, module?: string): void;
49
+ /**
50
+ * Logs the message if the severity is set to info or above.
51
+ * This function is wrapper function for the log method with the proper severity to make it cleaner when using it in the code.
52
+ * @param message The message to log.
53
+ * @param extra The extra object to log.
54
+ * @param module The module from where the log was created.
55
+ */
56
+ info(message: string, extra?: any, module?: string): void;
57
+ /**
58
+ * Logs the message if the severity is set to debug or above.
59
+ * This function is wrapper function for the log method with the proper severity to make it cleaner when using it in the code.
60
+ * @param message The message to log.
61
+ * @param extra The extra object to log.
62
+ * @param module The module from where the log was created.
63
+ */
64
+ debug(message: string, extra?: any, module?: string): void;
65
+ /**
66
+ * Logs the message based on the severity.
67
+ * @param message The message to log.
68
+ * @param severity The minimum severity to log.
69
+ * @param extra The extra object to log.
70
+ * @param module The module from where the log was created.
71
+ */
17
72
  private log;
18
73
  }
@@ -1,7 +1,41 @@
1
+ /**
2
+ * This interface defines what functions should be implemented by a LogHandler.
3
+ * This interface is what should be injected when you want a LogHandler so that mocking can be done easier.
4
+ */
1
5
  export interface LogHandlerInterface {
2
- error(message: string, extra?: any, module?: string): void;
6
+ /**
7
+ * Logs the message if the severity is set to critical or above.
8
+ * @param message The message to log.
9
+ * @param extra The extra object to log.
10
+ * @param module The module from where the log was created.
11
+ */
3
12
  critical(message: string, extra?: any, module?: string): void;
4
- debug(message: string, extra?: any, module?: string): void;
5
- info(message: string, extra?: any, module?: string): void;
13
+ /**
14
+ * Logs the message if the severity is set to critical or above.
15
+ * @param message The message to log.
16
+ * @param extra The extra object to log.
17
+ * @param module The module from where the log was created.
18
+ */
19
+ error(message: string, extra?: any, module?: string): void;
20
+ /**
21
+ * Logs the message if the severity is set to critical or above.
22
+ * @param message The message to log.
23
+ * @param extra The extra object to log.
24
+ * @param module The module from where the log was created.
25
+ */
6
26
  warning(message: string, extra?: any, module?: string): void;
27
+ /**
28
+ * Logs the message if the severity is set to critical or above.
29
+ * @param message The message to log.
30
+ * @param extra The extra object to log.
31
+ * @param module The module from where the log was created.
32
+ */
33
+ info(message: string, extra?: any, module?: string): void;
34
+ /**
35
+ * Logs the message if the severity is set to critical or above.
36
+ * @param message The message to log.
37
+ * @param extra The extra object to log.
38
+ * @param module The module from where the log was created.
39
+ */
40
+ debug(message: string, extra?: any, module?: string): void;
7
41
  }
@@ -1,6 +1,17 @@
1
1
  /// <reference types="node" />
2
2
  import { Readable } from "stream";
3
+ /**
4
+ * This interface defines what should be implemented by a Logger.
5
+ * A logger is a class that defines how logs should be outputted.
6
+ * For example, an application could have multiple active loggers, one to output in the console, one to output in a file, etc.
7
+ */
3
8
  export interface LoggerInterface {
9
+ /**
10
+ * The readable stream from which the logger reads the logs that need to be outputted.
11
+ */
4
12
  readableStream: Readable;
13
+ /**
14
+ * Returns whether or not this particular logger is active and should ouput logs.
15
+ */
5
16
  isActive(): boolean;
6
17
  }
@@ -1,5 +1,10 @@
1
1
  import { LogModel } from "../models/log.model";
2
2
  import { OutputModeEnum } from "../enums/output-mode.enum";
3
+ /**
4
+ * The BaseLogger is the base abstract class that all internal loggers should extend.
5
+ * It defines the basic logic that applies to all internal loggers.
6
+ * External loggers could extend the base logger but it is not mandatory.
7
+ */
3
8
  export declare abstract class BaseLogger {
4
9
  protected readonly numberOfStackedLogs: number;
5
10
  protected readonly logSeverityLevelConfiguration: number;
@@ -11,15 +16,80 @@ export declare abstract class BaseLogger {
11
16
  private readonly isActivated;
12
17
  protected readonly outputMode: OutputModeEnum;
13
18
  protected readonly spaces: number;
19
+ /**
20
+ * 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.
21
+ * @private
22
+ */
14
23
  private stackedLogs;
24
+ /**
25
+ * The BaseLogger is the base abstract class that all loggers should extend.
26
+ * It defines the basic logic that applies to all loggers.
27
+ * @param numberOfStackedLogs The number of logs to keep in the stack and to print once a log with a high enough severity arrives.
28
+ * @param logSeverityLevelConfiguration The number representing the severity from which logs should be outputted.
29
+ * For example, if this is set to 3, any log that has a severity of Error(3) or critical(4) will be outputted.
30
+ * @param logDebugDepthConfiguration The number of level to go down in an object when printing a log with the Debug severity.
31
+ * We often do not need to go to the bottom layer of an object, so we can truncate at a certain depth.
32
+ * @param logInfoDepthConfiguration The number of level to go down in an object when printing a log with the Info severity.
33
+ * We often do not need to go to the bottom layer of an object, so we can truncate at a certain depth.
34
+ * @param logWarningDepthConfiguration The number of level to go down in an object when printing a log with the Warning 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 logErrorDepthConfiguration The number of level to go down in an object when printing a log with the Error 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 logCriticalDepthConfiguration The number of level to go down in an object when printing a log with the Critical 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 isActivated Whether or not this particular logger is activated and should output logs.
41
+ * @param outputMode The output mode, that the logger should use.
42
+ * @param spaces The number of spaces to indent the outputted logs.
43
+ */
15
44
  constructor(numberOfStackedLogs: number, logSeverityLevelConfiguration: number, logDebugDepthConfiguration: number, logInfoDepthConfiguration: number, logWarningDepthConfiguration: number, logErrorDepthConfiguration: number, logCriticalDepthConfiguration: number, isActivated?: boolean, outputMode?: OutputModeEnum, spaces?: number);
45
+ /**
46
+ * Initializes the logger. To be implemented in each logger.
47
+ * @protected
48
+ */
16
49
  protected abstract initialize(): void;
50
+ /**
51
+ * Returns whether this particular logger is active and should output logs.
52
+ */
17
53
  isActive(): boolean;
18
- outputLog(log: LogModel): string;
54
+ /**
55
+ * Gets the formatted output log based on a log model.
56
+ * @param log The log to be formatted.
57
+ */
58
+ getFormattedOutputLog(log: LogModel): string;
59
+ /**
60
+ * Actually outputs the log. To be implemented in each logger.
61
+ * @param log The log to be outputted.
62
+ * @protected
63
+ */
19
64
  protected abstract log(log: LogModel): void;
65
+ /**
66
+ * Captures the log and evaluates which logs need to be outputted or stacked.
67
+ * @param log The log to be captured.
68
+ * @protected
69
+ */
20
70
  protected captureLog(log: LogModel): void;
71
+ /**
72
+ * Sets up the stack of logs if it is required.
73
+ * @param traceId Optional trace id to stack logs based on different requests.
74
+ * @private
75
+ */
21
76
  private setupStackedLogsArrayIfRequired;
77
+ /**
78
+ * Adds the log to the stacked logs and makes sure we only keep the right amount of stacked logs.
79
+ * @param log The log to be added.
80
+ * @private
81
+ */
22
82
  private addStackedLog;
83
+ /**
84
+ * Outputs the stacked logs.
85
+ * @param traceId Optional trace id so that we only output the stacked logs for this trace.
86
+ * @private
87
+ */
23
88
  private outputStackedLogs;
89
+ /**
90
+ * Clears the stacked logs.
91
+ * @param traceId Optional trace id so that we only remove the stacked logs for this trace.
92
+ * @private
93
+ */
24
94
  private clearStackedLogs;
25
95
  }
@@ -4,9 +4,44 @@ import { LoggerInterface } from "../interfaces/logger.interface";
4
4
  import { Readable } from "stream";
5
5
  import { OutputModeEnum } from "../enums/output-mode.enum";
6
6
  import { BaseLogger } from "./base.logger";
7
+ /**
8
+ * The ConsoleLogger outputs the logs in the console.
9
+ * It is registered with the tag Logger so that it can be injected along with all the other Loggers.
10
+ * It is module scoped to the logging module so that it is only registered if the logging module is imported.
11
+ */
7
12
  export declare class ConsoleLogger extends BaseLogger implements LoggerInterface {
13
+ /**
14
+ * The readable stream from which the logger reads the logs that need to be outputted.
15
+ */
8
16
  readableStream: Readable;
9
- constructor(numberOfStackedLogs: number, logSeverityLevelConfiguration: number, logDebugDepthConfiguration: number, logInfoDepthConfiguration: number, logWarningDepthConfiguration: number, logErrorDepthConfiguration: number, logCriticalDepthConfiguration: number, isActive: boolean, outputMode: OutputModeEnum);
17
+ /**
18
+ * The ConsoleLogger outputs the logs in the console.
19
+ * @param numberOfStackedLogs The number of logs to keep in the stack and to print once a log with a high enough severity arrives.
20
+ * @param logSeverityLevelConfiguration The number representing the severity from which logs should be outputted.
21
+ * For example, if this is set to 3, any log that has a severity of Error(3) or critical(4) will be outputted.
22
+ * @param logDebugDepthConfiguration The number of level to go down in an object when printing a log with the Debug 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 logInfoDepthConfiguration The number of level to go down in an object when printing a log with the Info 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 logWarningDepthConfiguration The number of level to go down in an object when printing a log with the Warning 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 logErrorDepthConfiguration The number of level to go down in an object when printing a log with the Error 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 logCriticalDepthConfiguration The number of level to go down in an object when printing a log with the Critical severity.
31
+ * We often do not need to go to the bottom layer of an object, so we can truncate at a certain depth.
32
+ * @param isActivated Whether or not this particular logger is activated and should output logs.
33
+ * @param outputMode The output mode, that the logger should use.
34
+ */
35
+ constructor(numberOfStackedLogs: number, logSeverityLevelConfiguration: number, logDebugDepthConfiguration: number, logInfoDepthConfiguration: number, logWarningDepthConfiguration: number, logErrorDepthConfiguration: number, logCriticalDepthConfiguration: number, isActivated: boolean, outputMode: OutputModeEnum);
36
+ /**
37
+ * Initializes the console logger.
38
+ * @protected
39
+ */
10
40
  protected initialize(): void;
41
+ /**
42
+ * Outputs the log in the console.
43
+ * @param log The log to be outputted
44
+ * @protected
45
+ */
11
46
  protected log(log: LogModel): void;
12
47
  }