@aneuhold/core-ts-lib 2.0.9 → 2.1.0

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 (43) hide show
  1. package/lib/index.d.ts +5 -3
  2. package/lib/index.d.ts.map +1 -1
  3. package/lib/index.js +2 -2
  4. package/lib/index.js.map +1 -1
  5. package/lib/index.ts +6 -3
  6. package/lib/interfaces/ILogger.d.ts +48 -0
  7. package/lib/interfaces/ILogger.d.ts.map +1 -0
  8. package/lib/interfaces/ILogger.js +15 -0
  9. package/lib/interfaces/ILogger.js.map +1 -0
  10. package/lib/interfaces/ILogger.ts +55 -0
  11. package/lib/interfaces/ITracer.d.ts +79 -0
  12. package/lib/interfaces/ITracer.d.ts.map +1 -0
  13. package/lib/interfaces/ITracer.js +32 -0
  14. package/lib/interfaces/ITracer.js.map +1 -0
  15. package/lib/interfaces/ITracer.ts +102 -0
  16. package/lib/services/DependencyRegistry.d.ts +43 -0
  17. package/lib/services/DependencyRegistry.d.ts.map +1 -0
  18. package/lib/services/DependencyRegistry.js +52 -0
  19. package/lib/services/DependencyRegistry.js.map +1 -0
  20. package/lib/services/DependencyRegistry.ts +58 -0
  21. package/lib/services/DependencyService.js +4 -4
  22. package/lib/services/DependencyService.js.map +1 -1
  23. package/lib/services/DependencyService.ts +4 -4
  24. package/lib/services/FileSystemService/FileSystemService.d.ts +8 -0
  25. package/lib/services/FileSystemService/FileSystemService.d.ts.map +1 -1
  26. package/lib/services/FileSystemService/FileSystemService.js +16 -8
  27. package/lib/services/FileSystemService/FileSystemService.js.map +1 -1
  28. package/lib/services/FileSystemService/FileSystemService.ts +16 -8
  29. package/lib/services/PackageService.js +16 -16
  30. package/lib/services/PackageService.js.map +1 -1
  31. package/lib/services/PackageService.ts +16 -16
  32. package/lib/utils/ConsoleLogger.d.ts +101 -0
  33. package/lib/utils/ConsoleLogger.d.ts.map +1 -0
  34. package/lib/utils/ConsoleLogger.js +146 -0
  35. package/lib/utils/ConsoleLogger.js.map +1 -0
  36. package/lib/utils/ConsoleLogger.ts +161 -0
  37. package/package.json +10 -10
  38. package/readme.md +6 -3
  39. package/lib/utils/Logger.d.ts +0 -95
  40. package/lib/utils/Logger.d.ts.map +0 -1
  41. package/lib/utils/Logger.js +0 -136
  42. package/lib/utils/Logger.js.map +0 -1
  43. package/lib/utils/Logger.ts +0 -146
@@ -0,0 +1,146 @@
1
+ /**
2
+ * A standard logger that logs messages to the console.
3
+ * Implements the ILogger interface.
4
+ */
5
+ export default class ConsoleLogger {
6
+ /**
7
+ * Indicates if verbose logging is enabled globally.
8
+ * Affects instances created via the `verbose` getter or constructor.
9
+ */
10
+ static verboseLoggingEnabled = false;
11
+ /**
12
+ * Private flag indicating if this instance should only log when verbose mode is enabled.
13
+ */
14
+ logOnlyIfVerbose = false;
15
+ /**
16
+ * Creates an instance of ConsoleLogger.
17
+ *
18
+ * @param logOnlyIfVerbose - If true, this instance will only log messages if
19
+ * `ConsoleLogger.verboseLoggingEnabled` is also true.
20
+ */
21
+ constructor(logOnlyIfVerbose) {
22
+ if (logOnlyIfVerbose) {
23
+ this.logOnlyIfVerbose = logOnlyIfVerbose;
24
+ }
25
+ }
26
+ /**
27
+ * Gets a new ConsoleLogger instance configured for verbose logging.
28
+ * This instance will only log if `ConsoleLogger.verboseLoggingEnabled` is true.
29
+ *
30
+ * @returns A new ConsoleLogger instance set to log only when verbose mode is active.
31
+ */
32
+ get verbose() {
33
+ return new ConsoleLogger(true);
34
+ }
35
+ /**
36
+ * Static getter for a verbose ConsoleLogger instance.
37
+ * Equivalent to `new ConsoleLogger().verbose`.
38
+ *
39
+ * @returns A new ConsoleLogger instance set to log only when verbose mode is active.
40
+ */
41
+ static get verbose() {
42
+ return new ConsoleLogger(true);
43
+ }
44
+ /**
45
+ * Logs info to the console. Prepends `ℹ️` to each message.
46
+ * Respects the instance's `logOnlyIfVerbose` setting and the global `verboseLoggingEnabled` flag.
47
+ *
48
+ * @param msg - The message to log.
49
+ * @param skipNewline - If true, the message will be logged without a newline.
50
+ */
51
+ info(msg, skipNewline) {
52
+ if (this.shouldLog()) {
53
+ const printMessage = `ℹ️ ${msg}`;
54
+ if (skipNewline &&
55
+ typeof process !== 'undefined' &&
56
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
57
+ process.stdout.write) {
58
+ // Check for process.stdout.write for Node.js compatibility
59
+ process.stdout.write(printMessage);
60
+ }
61
+ else {
62
+ console.log(printMessage);
63
+ }
64
+ }
65
+ }
66
+ /**
67
+ * Static version of {@link ConsoleLogger.prototype.info}. Logs using a default instance.
68
+ *
69
+ * @param msg - The message to log.
70
+ * @param skipNewline - If true, the message will be logged without a newline.
71
+ */
72
+ static info(msg, skipNewline) {
73
+ new ConsoleLogger().info(msg, skipNewline);
74
+ }
75
+ /**
76
+ * Logs a success message to the console. Prepends `✅` to each message.
77
+ * Respects the instance's `logOnlyIfVerbose` setting and the global `verboseLoggingEnabled` flag.
78
+ *
79
+ * @param msg - The message to log.
80
+ */
81
+ success(msg) {
82
+ if (this.shouldLog()) {
83
+ console.log(`✅ ${msg}`);
84
+ }
85
+ }
86
+ /**
87
+ * Static version of {@link ConsoleLogger.prototype.success}. Logs using a default instance.
88
+ *
89
+ * @param msg - The message to log.
90
+ */
91
+ static success(msg) {
92
+ new ConsoleLogger().success(msg);
93
+ }
94
+ /**
95
+ * Logs a failure message to the console. Prepends `🔴` to each message.
96
+ * Uses `console.log`. See {@link error} for critical errors.
97
+ * Respects the instance's `logOnlyIfVerbose` setting and the global `verboseLoggingEnabled` flag.
98
+ *
99
+ * @param msg - The message to log.
100
+ */
101
+ failure(msg) {
102
+ if (this.shouldLog()) {
103
+ console.log(`🔴 ${msg}`);
104
+ }
105
+ }
106
+ /**
107
+ * Static version of {@link ConsoleLogger.prototype.failure}. Logs using a default instance.
108
+ *
109
+ * @param msg - The message to log.
110
+ */
111
+ static failure(msg) {
112
+ new ConsoleLogger().failure(msg);
113
+ }
114
+ /**
115
+ * Logs an error message to the console using `console.error`. Prepends `💀`.
116
+ * Use for potentially execution-stopping errors. See {@link failure} for non-critical issues.
117
+ * Respects the instance's `logOnlyIfVerbose` setting and the global `verboseLoggingEnabled` flag.
118
+ *
119
+ * @param msg - The message to log.
120
+ */
121
+ error(msg) {
122
+ if (this.shouldLog()) {
123
+ console.error(`💀 ${msg}`);
124
+ }
125
+ }
126
+ /**
127
+ * Static version of {@link ConsoleLogger.prototype.error}. Logs using a default instance.
128
+ *
129
+ * @param msg - The message to log.
130
+ */
131
+ static error(msg) {
132
+ new ConsoleLogger().error(msg);
133
+ }
134
+ /**
135
+ * Determines if the message should be logged based on the instance's verbose setting
136
+ * and the global verbose logging flag.
137
+ *
138
+ * @returns True if the message should be logged, false otherwise.
139
+ */
140
+ shouldLog() {
141
+ // Log if verbose logging is not required for this instance,
142
+ // OR if verbose logging IS required AND it's globally enabled.
143
+ return !this.logOnlyIfVerbose || ConsoleLogger.verboseLoggingEnabled;
144
+ }
145
+ }
146
+ //# sourceMappingURL=ConsoleLogger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConsoleLogger.js","sourceRoot":"./src/","sources":["utils/ConsoleLogger.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,aAAa;IAChC;;;OAGG;IACI,MAAM,CAAC,qBAAqB,GAAG,KAAK,CAAC;IAE5C;;OAEG;IACK,gBAAgB,GAAG,KAAK,CAAC;IAEjC;;;;;OAKG;IACH,YAAY,gBAA0B;QACpC,IAAI,gBAAgB,EAAE,CAAC;YACrB,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QAC3C,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACH,IAAI,OAAO;QACT,OAAO,IAAI,aAAa,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;IAED;;;;;OAKG;IACH,MAAM,KAAK,OAAO;QAChB,OAAO,IAAI,aAAa,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;IAED;;;;;;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AC,SAAS,EAAE,EAAE,CAAC;YACrB,OAAO,CAAC,KAAK,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,KAAK,CAAC,GAAW;QACtB,IAAI,aAAa,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACjC,CAAC;IAED;;;;;OAKG;IACK,SAAS;QACf,4DAA4D;QAC5D,+DAA+D;QAC/D,OAAO,CAAC,IAAI,CAAC,gBAAgB,IAAI,aAAa,CAAC,qBAAqB,CAAC;IACvE,CAAC"}
@@ -0,0 +1,161 @@
1
+ import { ILogger } from '../interfaces/ILogger.js';
2
+
3
+ /**
4
+ * A standard logger that logs messages to the console.
5
+ * Implements the ILogger interface.
6
+ */
7
+ export default class ConsoleLogger implements ILogger {
8
+ /**
9
+ * Indicates if verbose logging is enabled globally.
10
+ * Affects instances created via the `verbose` getter or constructor.
11
+ */
12
+ public static verboseLoggingEnabled = false;
13
+
14
+ /**
15
+ * Private flag indicating if this instance should only log when verbose mode is enabled.
16
+ */
17
+ private logOnlyIfVerbose = false;
18
+
19
+ /**
20
+ * Creates an instance of ConsoleLogger.
21
+ *
22
+ * @param logOnlyIfVerbose - If true, this instance will only log messages if
23
+ * `ConsoleLogger.verboseLoggingEnabled` is also true.
24
+ */
25
+ constructor(logOnlyIfVerbose?: boolean) {
26
+ if (logOnlyIfVerbose) {
27
+ this.logOnlyIfVerbose = logOnlyIfVerbose;
28
+ }
29
+ }
30
+
31
+ /**
32
+ * Gets a new ConsoleLogger instance configured for verbose logging.
33
+ * This instance will only log if `ConsoleLogger.verboseLoggingEnabled` is true.
34
+ *
35
+ * @returns A new ConsoleLogger instance set to log only when verbose mode is active.
36
+ */
37
+ get verbose(): ConsoleLogger {
38
+ return new ConsoleLogger(true);
39
+ }
40
+
41
+ /**
42
+ * Static getter for a verbose ConsoleLogger instance.
43
+ * Equivalent to `new ConsoleLogger().verbose`.
44
+ *
45
+ * @returns A new ConsoleLogger instance set to log only when verbose mode is active.
46
+ */
47
+ static get verbose(): ConsoleLogger {
48
+ return new ConsoleLogger(true);
49
+ }
50
+
51
+ /**
52
+ * Logs info to the console. Prepends `ℹ️` to each message.
53
+ * Respects the instance's `logOnlyIfVerbose` setting and the global `verboseLoggingEnabled` flag.
54
+ *
55
+ * @param msg - The message to log.
56
+ * @param skipNewline - If true, the message will be logged without a newline.
57
+ */
58
+ info(msg: string, skipNewline?: boolean): void {
59
+ if (this.shouldLog()) {
60
+ const printMessage = `ℹ️ ${msg}`;
61
+ if (
62
+ skipNewline &&
63
+ typeof process !== 'undefined' &&
64
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
65
+ process.stdout.write
66
+ ) {
67
+ // Check for process.stdout.write for Node.js compatibility
68
+ process.stdout.write(printMessage);
69
+ } else {
70
+ console.log(printMessage);
71
+ }
72
+ }
73
+ }
74
+
75
+ /**
76
+ * Static version of {@link ConsoleLogger.prototype.info}. Logs using a default instance.
77
+ *
78
+ * @param msg - The message to log.
79
+ * @param skipNewline - If true, the message will be logged without a newline.
80
+ */
81
+ static info(msg: string, skipNewline?: boolean): void {
82
+ new ConsoleLogger().info(msg, skipNewline);
83
+ }
84
+
85
+ /**
86
+ * Logs a success message to the console. Prepends `✅` to each message.
87
+ * Respects the instance's `logOnlyIfVerbose` setting and the global `verboseLoggingEnabled` flag.
88
+ *
89
+ * @param msg - The message to log.
90
+ */
91
+ success(msg: string): void {
92
+ if (this.shouldLog()) {
93
+ console.log(`✅ ${msg}`);
94
+ }
95
+ }
96
+
97
+ /**
98
+ * Static version of {@link ConsoleLogger.prototype.success}. Logs using a default instance.
99
+ *
100
+ * @param msg - The message to log.
101
+ */
102
+ static success(msg: string): void {
103
+ new ConsoleLogger().success(msg);
104
+ }
105
+
106
+ /**
107
+ * Logs a failure message to the console. Prepends `🔴` to each message.
108
+ * Uses `console.log`. See {@link error} for critical errors.
109
+ * Respects the instance's `logOnlyIfVerbose` setting and the global `verboseLoggingEnabled` flag.
110
+ *
111
+ * @param msg - The message to log.
112
+ */
113
+ failure(msg: string): void {
114
+ if (this.shouldLog()) {
115
+ console.log(`🔴 ${msg}`);
116
+ }
117
+ }
118
+
119
+ /**
120
+ * Static version of {@link ConsoleLogger.prototype.failure}. Logs using a default instance.
121
+ *
122
+ * @param msg - The message to log.
123
+ */
124
+ static failure(msg: string): void {
125
+ new ConsoleLogger().failure(msg);
126
+ }
127
+
128
+ /**
129
+ * Logs an error message to the console using `console.error`. Prepends `💀`.
130
+ * Use for potentially execution-stopping errors. See {@link failure} for non-critical issues.
131
+ * Respects the instance's `logOnlyIfVerbose` setting and the global `verboseLoggingEnabled` flag.
132
+ *
133
+ * @param msg - The message to log.
134
+ */
135
+ error(msg: string): void {
136
+ if (this.shouldLog()) {
137
+ console.error(`💀 ${msg}`);
138
+ }
139
+ }
140
+
141
+ /**
142
+ * Static version of {@link ConsoleLogger.prototype.error}. Logs using a default instance.
143
+ *
144
+ * @param msg - The message to log.
145
+ */
146
+ static error(msg: string): void {
147
+ new ConsoleLogger().error(msg);
148
+ }
149
+
150
+ /**
151
+ * Determines if the message should be logged based on the instance's verbose setting
152
+ * and the global verbose logging flag.
153
+ *
154
+ * @returns True if the message should be logged, false otherwise.
155
+ */
156
+ private shouldLog(): boolean {
157
+ // Log if verbose logging is not required for this instance,
158
+ // OR if verbose logging IS required AND it's globally enabled.
159
+ return !this.logOnlyIfVerbose || ConsoleLogger.verboseLoggingEnabled;
160
+ }
161
+ }
package/package.json CHANGED
@@ -2,9 +2,9 @@
2
2
  "name": "@aneuhold/core-ts-lib",
3
3
  "author": "Anton G. Neuhold Jr.",
4
4
  "license": "MIT",
5
- "version": "2.0.9",
5
+ "version": "2.1.0",
6
6
  "description": "A core library for all of my TypeScript projects",
7
- "packageManager": "yarn@4.5.1",
7
+ "packageManager": "yarn@4.6.0",
8
8
  "type": "module",
9
9
  "scripts": {
10
10
  "build": "rimraf lib && tsc --project tsconfig.build.json && tsx ./scripts/copyTsFiles.ts",
@@ -40,16 +40,16 @@
40
40
  "Node.js"
41
41
  ],
42
42
  "devDependencies": {
43
- "@aneuhold/eslint-config": "^1.0.54",
44
- "@types/jest": "^29.*",
45
- "@types/node": "^22.*",
46
- "eslint": "^9.19.0",
43
+ "@aneuhold/eslint-config": "^1.0.88",
44
+ "@types/jest": "^29.5.14",
45
+ "@types/node": "^22.15.2",
46
+ "eslint": "^9.25.1",
47
47
  "jest": "^29.7.*",
48
48
  "jsr": "*",
49
- "prettier": "^3.4.2",
49
+ "prettier": "^3.5.3",
50
50
  "rimraf": "^6.0.1",
51
- "ts-jest": "^29.2.5",
52
- "tsx": "^4.19.2",
53
- "typescript": "~5.7.3"
51
+ "ts-jest": "^29.3.2",
52
+ "tsx": "^4.19.3",
53
+ "typescript": "~5.8.3"
54
54
  }
55
55
  }
package/readme.md CHANGED
@@ -35,12 +35,15 @@ Run `deno add jsr:@aneuhold/core-ts-lib`
35
35
  Pull in one of the services and use it like so:
36
36
 
37
37
  ```ts
38
- import { Logger } from '@aneuhold/core-ts-lib';
38
+ import { DependencyRegistry, ILogger } from '@aneuhold/core-ts-lib';
39
39
  // If using Node with JSR
40
- // import { Logger } from '@jsr/aneuhold__core-ts-lib';
40
+ // import { DependencyRegistry, ILogger } from '@jsr/aneuhold__core-ts-lib';
41
+
42
+ // Get the logger instance from the registry
43
+ const logger: ILogger = DependencyRegistry.logger;
41
44
 
42
45
  export default function logSomething() {
43
- Logger.info('Something');
46
+ logger.info('Something');
44
47
  }
45
48
  ```
46
49
 
@@ -1,95 +0,0 @@
1
- /**
2
- * A standard logger that can be used to log messages to the console.
3
- */
4
- export default class Logger {
5
- /**
6
- * Indicates if verbose logging is enabled.
7
- */
8
- static verboseLoggingEnabled: boolean;
9
- /**
10
- * Private variable that sets if any logging on this instance of the Log
11
- * should only log if the `verboseLoggingEnabled` is set to true.
12
- */
13
- private logOnlyIfVerbose;
14
- /**
15
- * Creates an instance of Logger.
16
- *
17
- * @param logOnlyIfVerbose - If true, logging will only occur if verbose logging is enabled.
18
- */
19
- constructor(logOnlyIfVerbose?: boolean);
20
- /**
21
- * Sets the logging of the next chained function to only be activated
22
- * if verbose logging is turned on.
23
- *
24
- * @returns A new Logger instance with verbose logging enabled.
25
- */
26
- static get verbose(): Logger;
27
- /**
28
- * Logs info to the console. Prepends `ℹ️` to each message.
29
- *
30
- * @param msg - The message to log.
31
- * @param skipNewline - If true, the message will be logged without a newline.
32
- */
33
- info(msg: string, skipNewline?: boolean): void;
34
- /**
35
- * Static version of {@link Logger.prototype.info}.
36
- *
37
- * @param msg - The message to log.
38
- * @param skipNewline - If true, the message will be logged without a newline.
39
- * @see Logger.prototype.info
40
- */
41
- static info(msg: string, skipNewline?: boolean): void;
42
- /**
43
- * Logs a success message to the console. Prepends `✅` to each message.
44
- *
45
- * @param msg - The message to log.
46
- */
47
- success(msg: string): void;
48
- /**
49
- * Static version of {@link Logger.prototype.success}.
50
- *
51
- * @param msg - The message to log.
52
- * @see Logger.prototype.success
53
- */
54
- static success(msg: string): void;
55
- /**
56
- * Logs a failure message to the console. Prepends `🔴` to each message.
57
- *
58
- * See {@link error} for logging errors.
59
- *
60
- * This doesn't use a `console.error` entry. Just a `console.log` entry.
61
- *
62
- * @param msg - The message to log.
63
- */
64
- failure(msg: string): void;
65
- /**
66
- * Static version of {@link Logger.prototype.failure}.
67
- *
68
- * @param msg - The message to log.
69
- * @see Logger.prototype.failure
70
- */
71
- static failure(msg: string): void;
72
- /**
73
- * Logs an error message to the console. Only use this for errors that will
74
- * likely stop execution. Prepends `💀` to each message and uses `console.error`.
75
- *
76
- * See {@link failure} for logging simple failures.
77
- *
78
- * @param msg - The message to log.
79
- */
80
- error(msg: string): void;
81
- /**
82
- * Static version of {@link Logger.prototype.error}.
83
- *
84
- * @param msg - The message to log.
85
- * @see Logger.prototype.error
86
- */
87
- static error(msg: string): void;
88
- /**
89
- * Determines if the message should be logged based on the verbose logging settings.
90
- *
91
- * @returns True if the message should be logged, false otherwise.
92
- */
93
- private shouldLog;
94
- }
95
- //# sourceMappingURL=Logger.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Logger.d.ts","sourceRoot":"./src/","sources":["utils/Logger.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,MAAM;IACzB;;OAEG;IACH,OAAc,qBAAqB,UAAS;IAE5C;;;OAGG;IACH,OAAO,CAAC,gBAAgB,CAAS;IAEjC;;;;OAIG;gBACS,gBAAgB,CAAC,EAAE,OAAO;IAMtC;;;;;OAKG;IACH,MAAM,KAAK,OAAO,IAAI,MAAM,CAE3B;IAED;;;;;OAKG;IACH,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,OAAO,GAAG,IAAI;IAW9C;;;;;;OAMG;IACH,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,OAAO,GAAG,IAAI;IAIrD;;;;OAIG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAM1B;;;;;OAKG;IACH,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAIjC;;;;;;;;OAQG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAM1B;;;;;OAKG;IACH,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAIjC;;;;;;;OAOG;IACH,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAMxB;;;;;OAKG;IACH,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAI/B;;;;OAIG;IACH,OAAO,CAAC,SAAS;CAMlB"}
@@ -1,136 +0,0 @@
1
- /**
2
- * A standard logger that can be used to log messages to the console.
3
- */
4
- export default class Logger {
5
- /**
6
- * Indicates if verbose logging is enabled.
7
- */
8
- static verboseLoggingEnabled = false;
9
- /**
10
- * Private variable that sets if any logging on this instance of the Log
11
- * should only log if the `verboseLoggingEnabled` is set to true.
12
- */
13
- logOnlyIfVerbose = false;
14
- /**
15
- * Creates an instance of Logger.
16
- *
17
- * @param logOnlyIfVerbose - If true, logging will only occur if verbose logging is enabled.
18
- */
19
- constructor(logOnlyIfVerbose) {
20
- if (logOnlyIfVerbose) {
21
- this.logOnlyIfVerbose = logOnlyIfVerbose;
22
- }
23
- }
24
- /**
25
- * Sets the logging of the next chained function to only be activated
26
- * if verbose logging is turned on.
27
- *
28
- * @returns A new Logger instance with verbose logging enabled.
29
- */
30
- static get verbose() {
31
- return new Logger(true);
32
- }
33
- /**
34
- * Logs info to the console. Prepends `ℹ️` to each message.
35
- *
36
- * @param msg - The message to log.
37
- * @param skipNewline - If true, the message will be logged without a newline.
38
- */
39
- info(msg, skipNewline) {
40
- if (this.shouldLog()) {
41
- const printMessage = `ℹ️ ${msg}`;
42
- if (skipNewline) {
43
- process.stdout.write(printMessage);
44
- }
45
- else {
46
- console.log(printMessage);
47
- }
48
- }
49
- }
50
- /**
51
- * Static version of {@link Logger.prototype.info}.
52
- *
53
- * @param msg - The message to log.
54
- * @param skipNewline - If true, the message will be logged without a newline.
55
- * @see Logger.prototype.info
56
- */
57
- static info(msg, skipNewline) {
58
- new Logger().info(msg, skipNewline);
59
- }
60
- /**
61
- * Logs a success message to the console. Prepends `✅` to each message.
62
- *
63
- * @param msg - The message to log.
64
- */
65
- success(msg) {
66
- if (this.shouldLog()) {
67
- console.log(`✅ ${msg}`);
68
- }
69
- }
70
- /**
71
- * Static version of {@link Logger.prototype.success}.
72
- *
73
- * @param msg - The message to log.
74
- * @see Logger.prototype.success
75
- */
76
- static success(msg) {
77
- new Logger().success(msg);
78
- }
79
- /**
80
- * Logs a failure message to the console. Prepends `🔴` to each message.
81
- *
82
- * See {@link error} for logging errors.
83
- *
84
- * This doesn't use a `console.error` entry. Just a `console.log` entry.
85
- *
86
- * @param msg - The message to log.
87
- */
88
- failure(msg) {
89
- if (this.shouldLog()) {
90
- console.log(`🔴 ${msg}`);
91
- }
92
- }
93
- /**
94
- * Static version of {@link Logger.prototype.failure}.
95
- *
96
- * @param msg - The message to log.
97
- * @see Logger.prototype.failure
98
- */
99
- static failure(msg) {
100
- new Logger().failure(msg);
101
- }
102
- /**
103
- * Logs an error message to the console. Only use this for errors that will
104
- * likely stop execution. Prepends `💀` to each message and uses `console.error`.
105
- *
106
- * See {@link failure} for logging simple failures.
107
- *
108
- * @param msg - The message to log.
109
- */
110
- error(msg) {
111
- if (this.shouldLog()) {
112
- console.error(`💀 ${msg}`);
113
- }
114
- }
115
- /**
116
- * Static version of {@link Logger.prototype.error}.
117
- *
118
- * @param msg - The message to log.
119
- * @see Logger.prototype.error
120
- */
121
- static error(msg) {
122
- new Logger().error(msg);
123
- }
124
- /**
125
- * Determines if the message should be logged based on the verbose logging settings.
126
- *
127
- * @returns True if the message should be logged, false otherwise.
128
- */
129
- shouldLog() {
130
- if (!this.logOnlyIfVerbose || Logger.verboseLoggingEnabled) {
131
- return true;
132
- }
133
- return false;
134
- }
135
- }
136
- //# sourceMappingURL=Logger.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Logger.js","sourceRoot":"./src/","sources":["utils/Logger.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,MAAM;IACzB;;OAEG;IACI,MAAM,CAAC,qBAAqB,GAAG,KAAK,CAAC;IAE5C;;;OAGG;IACK,gBAAgB,GAAG,KAAK,CAAC;IAEjC;;;;OAIG;IACH,YAAY,gBAA0B;QACpC,IAAI,gBAAgB,EAAE,CAAC;YACrB,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QAC3C,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACH,MAAM,KAAK,OAAO;QAChB,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAED;;;;;OAKG;IACH,IAAI,CAAC,GAAW,EAAE,WAAqB;QACrC,IAAI,IAAI,C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