@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
@@ -4,11 +4,52 @@ import { LoggerInterface } from "../interfaces/logger.interface";
4
4
  import { Readable, Writable } from "stream";
5
5
  import { OutputModeEnum } from "../enums/output-mode.enum";
6
6
  import { BaseLogger } from "./base.logger";
7
+ /**
8
+ * The FileLogger outputs the logs into file.
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 FileLogger extends BaseLogger implements LoggerInterface {
8
13
  private readonly filePath;
14
+ /**
15
+ * The readable stream from which the logger reads the logs that need to be outputted.
16
+ */
9
17
  readableStream: Readable;
18
+ /**
19
+ * The writable stream used to write to the file.
20
+ * @private
21
+ */
10
22
  writableStream: Writable;
11
- constructor(numberOfStackedLogs: number, logSeverityLevelConfiguration: number, logDebugDepthConfiguration: number, logInfoDepthConfiguration: number, logWarningDepthConfiguration: number, logErrorDepthConfiguration: number, logCriticalDepthConfiguration: number, isActive: boolean, outputMode: OutputModeEnum, fileLoggerPretty: boolean, filePath: string);
23
+ /**
24
+ * The ConsoleLogger outputs the logs in the console.
25
+ * @param numberOfStackedLogs The number of logs to keep in the stack and to print once a log with a high enough severity arrives.
26
+ * @param logSeverityLevelConfiguration The number representing the severity from which logs should be outputted.
27
+ * For example, if this is set to 3, any log that has a severity of Error(3) or critical(4) will be outputted.
28
+ * @param logDebugDepthConfiguration The number of level to go down in an object when printing a log with the Debug 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 logInfoDepthConfiguration The number of level to go down in an object when printing a log with the Info 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 logWarningDepthConfiguration The number of level to go down in an object when printing a log with the Warning 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 logErrorDepthConfiguration The number of level to go down in an object when printing a log with the Error 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 logCriticalDepthConfiguration The number of level to go down in an object when printing a log with the Critical 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 isActivated Whether or not this particular logger is activated and should output logs.
39
+ * @param outputMode The output mode, that the logger should use.
40
+ * @param fileLoggerPretty Whether or not the file logger should prettify the output.
41
+ * @param filePath The file path where to output the log.
42
+ */
43
+ constructor(numberOfStackedLogs: number, logSeverityLevelConfiguration: number, logDebugDepthConfiguration: number, logInfoDepthConfiguration: number, logWarningDepthConfiguration: number, logErrorDepthConfiguration: number, logCriticalDepthConfiguration: number, isActivated: boolean, outputMode: OutputModeEnum, fileLoggerPretty: boolean, filePath: string);
44
+ /**
45
+ * Initializes the file logger, and opens the write stream.
46
+ * @protected
47
+ */
12
48
  protected initialize(): void;
49
+ /**
50
+ * Outputs the log in the file.
51
+ * @param log The log to be outputted
52
+ * @protected
53
+ */
13
54
  protected log(log: LogModel): void;
14
55
  }
@@ -1 +1,2 @@
1
1
  export * from "./console.logger";
2
+ export * from "./file.logger";
@@ -2,8 +2,8 @@ import { ModuleInterface } from "@pristine-ts/common";
2
2
  export * from "./enums/enums";
3
3
  export * from "./handlers/handlers";
4
4
  export * from "./interfaces/interfaces";
5
- export * from "./models/models";
6
5
  export * from "./loggers/loggers";
6
+ export * from "./models/models";
7
7
  export * from "./utils/utils";
8
8
  export * from "./logging.module.keyname";
9
9
  export declare const LoggingModule: ModuleInterface;
@@ -1,15 +1,52 @@
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 declare class DiagnosticsModel {
6
+ /**
7
+ * The node version on which the code was executed.
8
+ */
2
9
  nodeVersion?: string;
10
+ /**
11
+ * An array representing the stack trace from which the log originated.
12
+ */
3
13
  stackTrace: {
14
+ /**
15
+ * The class name at which it was called in the stack trace.
16
+ */
4
17
  className: string;
18
+ /**
19
+ * The class name at which it was called in the stack trace.
20
+ */
5
21
  filename: string;
22
+ /**
23
+ * The line at which it was called in the stack trace
24
+ */
6
25
  line: string;
26
+ /**
27
+ * The column at which it was called in the stack trace
28
+ */
7
29
  column: string;
8
30
  }[];
31
+ /**
32
+ * The very last element of the stack trace to know precisely where the log originated from.
33
+ */
9
34
  lastStackTrace?: {
35
+ /**
36
+ * The class name at which it was called in the stack trace.
37
+ */
10
38
  className: string;
39
+ /**
40
+ * The class name at which it was called in the stack trace.
41
+ */
11
42
  filename: string;
43
+ /**
44
+ * The line at which it was called in the stack trace
45
+ */
12
46
  line: string;
47
+ /**
48
+ * The column at which it was called in the stack trace
49
+ */
13
50
  column: string;
14
51
  };
15
52
  }
@@ -1,11 +1,35 @@
1
1
  import { SeverityEnum } from "../enums/severity.enum";
2
+ /**
3
+ * The model that represents a log
4
+ */
2
5
  export declare class LogModel {
3
6
  severity: SeverityEnum;
4
7
  message: string;
8
+ /**
9
+ * The trace id from which the log originated.
10
+ */
5
11
  traceId?: string;
12
+ /**
13
+ * The kernel instantiation id from which the log originated.
14
+ */
15
+ kernelInstantiationId?: string;
16
+ /**
17
+ * The date at which the log was created.
18
+ */
6
19
  date: Date;
20
+ /**
21
+ * The module from which the log originated.
22
+ * By default it will be the application module.
23
+ */
7
24
  module: string;
25
+ /**
26
+ * Any extras that need to be outputted along with the message.
27
+ */
8
28
  extra: any;
9
- kernelInstantiationId?: string;
29
+ /**
30
+ * The model that represents a log
31
+ * @param severity The log severity.
32
+ * @param message The actual log message that needs to be outputted.
33
+ */
10
34
  constructor(severity: SeverityEnum, message: string);
11
35
  }
@@ -2,13 +2,49 @@ import { LogModel } from "../models/log.model";
2
2
  import { OutputModeEnum } from "../enums/output-mode.enum";
3
3
  import { SeverityEnum } from "../enums/severity.enum";
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 declare class Utils {
6
9
  static flatTypes: (DateConstructor | StringConstructor | NumberConstructor | BooleanConstructor)[];
10
+ /**
11
+ * Returns whether or not the value is defined
12
+ * @param val
13
+ */
7
14
  static isDefined(val: any): boolean;
15
+ /**
16
+ * Returns whether or not the value is flat, meaning it is not an object.
17
+ * @param val
18
+ */
8
19
  static isFlat(val: any): number | true;
20
+ /**
21
+ * Gets the deep keys of an object.
22
+ * @param obj The object.
23
+ */
9
24
  static getDeepKeys(obj: any): string[];
25
+ /**
26
+ * This function truncates an object to the max depth required.
27
+ * @param object The object to truncate.
28
+ * @param maxDepth The max depth of the object.
29
+ * @param curDepth The current depth at which we are at.
30
+ */
10
31
  static truncate(object: any, maxDepth: number, curDepth?: number): any;
32
+ /**
33
+ * Gets the string representing a value of the log severity enum.
34
+ * @param logSeverity The log severity for which to get the string representation.
35
+ */
11
36
  static getSeverityText(logSeverity: SeverityEnum): string;
37
+ /**
38
+ * Returns the string formatted log based on the output model.
39
+ * @param log The log to be string formatted.
40
+ * @param outputMode The output mode desired.
41
+ * @param logDepth The log depth.
42
+ * @param spaceNumber The number of spaces for a tab.
43
+ */
12
44
  static outputLog(log: LogModel, outputMode: OutputModeEnum, logDepth: number, spaceNumber?: number): string;
45
+ /**
46
+ * Creates the diagnostic model from an error object to attach to a log.
47
+ * @param error The error object from which to get the stack trace.
48
+ */
13
49
  static getDiagnostics(error: Error): DiagnosticsModel;
14
50
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pristine-ts/logging",
3
- "version": "0.0.170",
3
+ "version": "0.0.174",
4
4
  "description": "",
5
5
  "module": "dist/lib/esm/logging.module.js",
6
6
  "main": "dist/lib/cjs/logging.module.js",
@@ -11,8 +11,8 @@
11
11
  "test": "jest"
12
12
  },
13
13
  "dependencies": {
14
- "@pristine-ts/common": "^0.0.170",
15
- "@pristine-ts/configuration": "^0.0.170",
14
+ "@pristine-ts/common": "^0.0.174",
15
+ "@pristine-ts/configuration": "^0.0.174",
16
16
  "date-fns": "^2.22.1"
17
17
  },
18
18
  "files": [
@@ -57,5 +57,5 @@
57
57
  "src/*.{js,ts}"
58
58
  ]
59
59
  },
60
- "gitHead": "03decbb25315a120f2ead0b4f663e4148d8548a8"
60
+ "gitHead": "578d6b9fe5faf8ef55c729bae70048446777a4b9"
61
61
  }