@quandis/qbo4.logging 4.0.1-CI-20240328-192659

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/license.js +41 -0
  2. package/package.json +47 -0
  3. package/readme.md +11 -0
  4. package/src/ApplicationInsights.d.ts +27 -0
  5. package/src/ApplicationInsights.js +87 -0
  6. package/src/ApplicationInsights.js.map +1 -0
  7. package/src/ApplicationInsights.ts +85 -0
  8. package/src/ConsoleLogger.d.ts +10 -0
  9. package/src/ConsoleLogger.js +50 -0
  10. package/src/ConsoleLogger.js.map +1 -0
  11. package/src/ConsoleLogger.ts +57 -0
  12. package/src/ILogEntry.d.ts +7 -0
  13. package/src/ILogEntry.js +2 -0
  14. package/src/ILogEntry.js.map +1 -0
  15. package/src/ILogEntry.ts +9 -0
  16. package/src/ILogReader.d.ts +10 -0
  17. package/src/ILogReader.js +5 -0
  18. package/src/ILogReader.js.map +1 -0
  19. package/src/ILogReader.ts +12 -0
  20. package/src/ILogger.d.ts +22 -0
  21. package/src/ILogger.js +14 -0
  22. package/src/ILogger.js.map +1 -0
  23. package/src/ILogger.ts +39 -0
  24. package/src/ILoggerService.d.ts +13 -0
  25. package/src/ILoggerService.js +5 -0
  26. package/src/ILoggerService.js.map +1 -0
  27. package/src/ILoggerService.ts +14 -0
  28. package/src/LoggerService.d.ts +24 -0
  29. package/src/LoggerService.js +91 -0
  30. package/src/LoggerService.js.map +1 -0
  31. package/src/LoggerService.ts +83 -0
  32. package/src/MemoryLogger.d.ts +24 -0
  33. package/src/MemoryLogger.js +48 -0
  34. package/src/MemoryLogger.js.map +1 -0
  35. package/src/MemoryLogger.ts +58 -0
  36. package/src/Program.d.ts +26 -0
  37. package/src/Program.js +47 -0
  38. package/src/Program.js.map +1 -0
  39. package/src/Program.ts +55 -0
  40. package/src/declarations.d.ts +4 -0
  41. package/src/qbo-find.d.ts +1 -0
  42. package/src/qbo-find.js +79 -0
  43. package/src/qbo-find.js.map +1 -0
  44. package/src/qbo-find.ts +63 -0
  45. package/src/qbo-logging.d.ts +34 -0
  46. package/src/qbo-logging.js +187 -0
  47. package/src/qbo-logging.js.map +1 -0
  48. package/src/qbo-logging.ts +175 -0
  49. package/src/styles.d.ts +3 -0
  50. package/src/styles.js +14 -0
  51. package/src/styles.js.map +1 -0
  52. package/src/styles.ts +16 -0
  53. package/wwwroot/js/license.txt +41 -0
  54. package/wwwroot/js/qbo4.logging.js +35756 -0
  55. package/wwwroot/js/qbo4.logging.min.js +56 -0
  56. package/wwwroot/js/qbo4.logging.min.js.LICENSE.txt +41 -0
  57. package/wwwroot/js/qbo4.logging.min.js.map +1 -0
  58. package/wwwroot/readme.html +19 -0
package/license.js ADDED
@@ -0,0 +1,41 @@
1
+ import { promises as fs } from 'fs';
2
+ // import { glob } from 'glob';
3
+ import globModule from 'glob'
4
+ import { promisify } from 'util';
5
+
6
+ const globPromise = promisify(globModule);
7
+
8
+ const licenseFilesPattern = './wwwroot/js/*.min.*.LICENSE.txt';
9
+ const outputLicenseFile = './wwwroot/js/license.txt';
10
+
11
+ const deleteFile = async (file) => {
12
+ try {
13
+ await fs.unlink(file);
14
+ console.log(`Deleted file: ${file}`);
15
+ } catch (unlinkErr) {
16
+ console.error(`Error deleting file: ${file}`, unlinkErr);
17
+ }
18
+ };
19
+
20
+ const aggregateLicenses = async () => {
21
+ try {
22
+ const files = await globPromise(licenseFilesPattern);
23
+ console.log(files);
24
+ let aggregatedLicenses = '';
25
+ for (let file of files) {
26
+ const licenseContent = await fs.readFile(file, 'utf8');
27
+ aggregatedLicenses += licenseContent + '\n\n';
28
+
29
+ // Delete the file after its content has been added to the aggregation
30
+ console.log(`Deleting file: ${file}`);
31
+ await deleteFile(file);
32
+ }
33
+
34
+ await fs.writeFile(outputLicenseFile, aggregatedLicenses.trim());
35
+ console.log('Aggregated license file created:', outputLicenseFile);
36
+ } catch (err) {
37
+ console.error('An error occurred:', err);
38
+ }
39
+ };
40
+
41
+ await aggregateLicenses();
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@quandis/qbo4.logging",
3
+ "version": "4.0.1-CI-20240328-192659",
4
+ "type": "module",
5
+ "types": "./src/Program.d.ts",
6
+ "exports": {
7
+ ".": {
8
+ "import": "./src/Program.js"
9
+ }
10
+ },
11
+ "files": [
12
+ "wwwroot/js/",
13
+ "src/"
14
+ ],
15
+ "dependencies": {
16
+ "@microsoft/applicationinsights-web": "^3.1.1",
17
+ "@quandis/qbo4.configuration": "^4.0.1-CI-20240328-123132",
18
+ "bootstrap": "^5.3.3",
19
+ "bootstrap-icons": "^1.11.3",
20
+ "lit": "^3.1.2",
21
+ "reflect-metadata": "^0.2.1",
22
+ "tsyringe": "^4.8.0"
23
+ },
24
+ "devDependencies": {
25
+ "@fullhuman/postcss-purgecss": "^5.0.0",
26
+ "autoprefixer": "^10.4.18",
27
+ "clean-css": "^5.3.3",
28
+ "glob": "^10.3.10",
29
+ "mini-css-extract-plugin": "^2.8.1",
30
+ "postcss-cli": "^11.0.0",
31
+ "postcss-loader": "^8.1.1",
32
+ "sass": "^1.72.0",
33
+ "sass-loader": "^14.1.1",
34
+ "style-loader": "^3.3.4",
35
+ "typescript": "^5.4.2",
36
+ "webpack": "^5.90.3",
37
+ "webpack-cli": "^5.1.4",
38
+ "webpack-merge": "^5.10.0"
39
+ },
40
+ "scripts": {
41
+ "sass": "sass scss/:wwwroot/css && node cssshake.js",
42
+ "postcss": "postcss \"wwwroot/css/*.css\" --use autoprefixer --replace",
43
+ "packdev": "webpack --config webpack.dev.js --no-color",
44
+ "packprod": "webpack --config webpack.prod.js --no-color",
45
+ "build": "npm run sass && tsc && npm run packdev && npm run packprod && rm *.tgz && npm pack && mv *.tgz qbo4.logging.tgz"
46
+ }
47
+ }
package/readme.md ADDED
@@ -0,0 +1,11 @@
1
+ 
2
+
3
+ # Node Setup
4
+
5
+ # Setup
6
+
7
+ ```bash
8
+ npm install lit tsyringe reflect-metadata
9
+ npm install webpack webpack-cli webpack-merge clean-webpack-plugin css-loader mini-css-extract-plugin autoprefixer copy-webpack-plugin --save-dev
10
+ ```
11
+
@@ -0,0 +1,27 @@
1
+ import { ApplicationInsights, IConfig, IConfiguration, Snippet } from '@microsoft/applicationinsights-web';
2
+ import { ILogger, LogLevel } from './ILogger.js';
3
+ import { InjectionToken } from 'tsyringe';
4
+ export declare class AppInsightsConfiguration implements Snippet {
5
+ config: IConfiguration & IConfig;
6
+ queue?: (() => void)[];
7
+ sv?: string;
8
+ version?: number;
9
+ trackPageView?: boolean;
10
+ }
11
+ /**
12
+ * Define a token for the ILoggerService interface
13
+ */
14
+ export declare const AppInsightsConfigurationToken: InjectionToken<AppInsightsConfiguration>;
15
+ export declare class AppInsightsLogger implements ILogger {
16
+ private config;
17
+ instance: ApplicationInsights | undefined;
18
+ constructor(config: AppInsightsConfiguration);
19
+ logTrace(message: string, ...args: any[]): void;
20
+ logDebug(message: string, ...args: any[]): void;
21
+ logInformation(message: string, ...args: any[]): void;
22
+ logWarning(message: string, ...args: any[]): void;
23
+ logError(message: string, error?: Error, ...args: any[]): void;
24
+ logCritical(message: string, error?: Error, ...args: any[]): void;
25
+ log(level: LogLevel, message: string, error?: Error, ...args: any[]): void;
26
+ private formatMessage;
27
+ }
@@ -0,0 +1,87 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
11
+ return function (target, key) { decorator(target, key, paramIndex); }
12
+ };
13
+ import { ApplicationInsights } from '@microsoft/applicationinsights-web';
14
+ import { services } from '@quandis/qbo4.configuration';
15
+ import { ILoggerToken } from './ILogger.js';
16
+ import { IConfigurationToken } from '@quandis/qbo4.configuration';
17
+ import { inject, injectable } from 'tsyringe';
18
+ export class AppInsightsConfiguration {
19
+ constructor() {
20
+ this.config = {};
21
+ this.trackPageView = false;
22
+ }
23
+ }
24
+ /**
25
+ * Define a token for the ILoggerService interface
26
+ */
27
+ export const AppInsightsConfigurationToken = 'AppInsightsConfigurationToken';
28
+ let AppInsightsLogger = class AppInsightsLogger {
29
+ constructor(config) {
30
+ this.config = config;
31
+ if (config.config?.connectionString || config.config?.instrumentationKey) {
32
+ this.instance = new ApplicationInsights(config);
33
+ this.instance.loadAppInsights();
34
+ if (config.trackPageView)
35
+ this.instance.trackPageView();
36
+ }
37
+ else
38
+ console.warn(`AppInsightsLogger configuraiton has no connectionString or instrumentaitonKey.`);
39
+ this.config = config;
40
+ }
41
+ logTrace(message, ...args) {
42
+ this.instance?.trackTrace({ message: this.formatMessage(message, args), severityLevel: 0 });
43
+ }
44
+ logDebug(message, ...args) {
45
+ this.instance?.trackTrace({ message: this.formatMessage(message, args), severityLevel: 1 });
46
+ }
47
+ logInformation(message, ...args) {
48
+ this.instance?.trackTrace({ message: this.formatMessage(message, args), severityLevel: 2 });
49
+ }
50
+ logWarning(message, ...args) {
51
+ this.instance?.trackTrace({ message: this.formatMessage(message, args), severityLevel: 3 });
52
+ }
53
+ logError(message, error, ...args) {
54
+ this.instance?.trackException({ exception: error ?? new Error(this.formatMessage(message, args)) });
55
+ }
56
+ logCritical(message, error, ...args) {
57
+ // Assuming you might want to treat critical errors differently
58
+ this.instance?.trackException({ exception: error ?? new Error(this.formatMessage(message, args)), properties: { severity: 'critical' } });
59
+ }
60
+ log(level, message, error, ...args) {
61
+ if (error)
62
+ this.instance?.trackException({ exception: error, properties: { message: this.formatMessage(message, args) } });
63
+ else
64
+ this.instance?.trackTrace({ message: this.formatMessage(message, args), severityLevel: level });
65
+ }
66
+ formatMessage(message, args) {
67
+ return args.length > 0 ? `${message}, ${args.join(', ')}` : message;
68
+ }
69
+ };
70
+ AppInsightsLogger = __decorate([
71
+ injectable(),
72
+ __param(0, inject(AppInsightsConfigurationToken)),
73
+ __metadata("design:paramtypes", [AppInsightsConfiguration])
74
+ ], AppInsightsLogger);
75
+ export { AppInsightsLogger };
76
+ function myFactory() {
77
+ const config = services.container.resolve(IConfigurationToken);
78
+ const aiConfig = config.getSection('ApplicationInsights').bind(AppInsightsConfiguration);
79
+ return aiConfig;
80
+ }
81
+ // const config = services.container.resolve<QboConfig>(IConfigurationToken);
82
+ // const aiConfig = config.get('ApplicationInsights').bind(AppInsightsConfiguration);
83
+ // services.container.register(AppInsightsConfiguration, { useValue: aiConfig });
84
+ services.container.registerSingleton(AppInsightsLogger);
85
+ services.container.register(ILoggerToken, { useToken: AppInsightsLogger });
86
+ services.container.register(AppInsightsConfigurationToken, { useFactory: myFactory });
87
+ //# sourceMappingURL=ApplicationInsights.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApplicationInsights.js","sourceRoot":"","sources":["ApplicationInsights.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,mBAAmB,EAAoC,MAAM,oCAAoC,CAAC;AAC3G,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAW,YAAY,EAAY,MAAM,cAAc,CAAC;AAC/D,OAAO,EAA+B,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAC/F,OAAO,EAAkB,MAAM,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAG9D,MAAM,OAAO,wBAAwB;IAArC;QACI,WAAM,GAA6B,EAAE,CAAC;QAItC,kBAAa,GAAa,KAAK,CAAC;IACpC,CAAC;CAAA;AAED;;GAEG;AACH,M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AAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;IACxE,CAAC;CACJ,CAAA;AAjDY,iBAAiB;IAD7B,UAAU,EAAE;IAGI,WAAA,MAAM,CAAC,6BAA6B,CAAC,CAAA;qCAAiB,wBAAwB;GAFlF,iBAAiB,CAiD7B;;AAED,SAAS,SAAS;IACd,MAAM,MAAM,GAAG,QAAQ,CAAC,SAAS,CAAC,OAAO,CAAY,mBAAmB,CAAC,CAAC;IAC1E,MAAM,QAAQ,GAAG,MAAM,CAAC,UAAU,CAAC,qBAAqB,CAAC,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;IACzF,OAAO,QAAQ,CAAC;AACpB,CAAC;AACD,6EAA6E;AAC7E,qFAAqF;AACrF,iFAAiF;AACjF,QAAQ,CAAC,SAAS,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;AACxD,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAU,YAAY,EAAE,EAAE,QAAQ,EAAE,iBAAiB,EAAE,CAAC,CAAC;AACpF,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAA2B,6BAA6B,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC,CAAC"}
@@ -0,0 +1,85 @@
1
+ import { ApplicationInsights, IConfig, IConfiguration, Snippet } from '@microsoft/applicationinsights-web';
2
+ import { services } from '@quandis/qbo4.configuration';
3
+ import { ILogger, ILoggerToken, LogLevel } from './ILogger.js';
4
+ import { IConfiguration as QboConfig, IConfigurationToken } from '@quandis/qbo4.configuration';
5
+ import { InjectionToken, inject, injectable } from 'tsyringe';
6
+
7
+
8
+ export class AppInsightsConfiguration implements Snippet {
9
+ config: IConfiguration & IConfig = {};
10
+ queue?: (() => void)[];
11
+ sv?: string;
12
+ version?: number;
13
+ trackPageView?: boolean = false;
14
+ }
15
+
16
+ /**
17
+ * Define a token for the ILoggerService interface
18
+ */
19
+ export const AppInsightsConfigurationToken: InjectionToken<AppInsightsConfiguration> = 'AppInsightsConfigurationToken';
20
+
21
+
22
+ @injectable()
23
+ export class AppInsightsLogger implements ILogger {
24
+ public instance: ApplicationInsights | undefined;
25
+ constructor(@inject(AppInsightsConfigurationToken) private config: AppInsightsConfiguration)
26
+ {
27
+ if (config.config?.connectionString || config.config?.instrumentationKey) {
28
+ this.instance = new ApplicationInsights(config);
29
+ this.instance.loadAppInsights();
30
+ if (config.trackPageView)
31
+ this.instance.trackPageView();
32
+ } else
33
+ console.warn(`AppInsightsLogger configuraiton has no connectionString or instrumentaitonKey.`)
34
+ this.config = config;
35
+ }
36
+
37
+ logTrace(message: string, ...args: any[]): void {
38
+ this.instance?.trackTrace({ message: this.formatMessage(message, args), severityLevel: 0 });
39
+ }
40
+
41
+ logDebug(message: string, ...args: any[]): void {
42
+ this.instance?.trackTrace({ message: this.formatMessage(message, args), severityLevel: 1 });
43
+ }
44
+
45
+ logInformation(message: string, ...args: any[]): void {
46
+ this.instance?.trackTrace({ message: this.formatMessage(message, args), severityLevel: 2 });
47
+ }
48
+
49
+ logWarning(message: string, ...args: any[]): void {
50
+ this.instance?.trackTrace({ message: this.formatMessage(message, args), severityLevel: 3 });
51
+ }
52
+
53
+ logError(message: string, error?: Error, ...args: any[]): void {
54
+ this.instance?.trackException({ exception: error ?? new Error(this.formatMessage(message, args)) });
55
+ }
56
+
57
+ logCritical(message: string, error?: Error, ...args: any[]): void {
58
+ // Assuming you might want to treat critical errors differently
59
+ this.instance?.trackException({ exception: error ?? new Error(this.formatMessage(message, args)), properties: { severity: 'critical' } });
60
+ }
61
+
62
+ log(level: LogLevel, message: string, error?: Error, ...args: any[]): void {
63
+ if (error)
64
+ this.instance?.trackException({ exception: error, properties: { message: this.formatMessage(message, args) } });
65
+ else
66
+ this.instance?.trackTrace({ message: this.formatMessage(message, args), severityLevel: level });
67
+ }
68
+
69
+ private formatMessage(message: string, args: any[]): string {
70
+ return args.length > 0 ? `${message}, ${args.join(', ')}` : message;
71
+ }
72
+ }
73
+
74
+ function myFactory(): AppInsightsConfiguration {
75
+ const config = services.container.resolve<QboConfig>(IConfigurationToken);
76
+ const aiConfig = config.getSection('ApplicationInsights').bind(AppInsightsConfiguration);
77
+ return aiConfig;
78
+ }
79
+ // const config = services.container.resolve<QboConfig>(IConfigurationToken);
80
+ // const aiConfig = config.get('ApplicationInsights').bind(AppInsightsConfiguration);
81
+ // services.container.register(AppInsightsConfiguration, { useValue: aiConfig });
82
+ services.container.registerSingleton(AppInsightsLogger);
83
+ services.container.register<ILogger>(ILoggerToken, { useToken: AppInsightsLogger });
84
+ services.container.register<AppInsightsConfiguration>(AppInsightsConfigurationToken, { useFactory: myFactory });
85
+
@@ -0,0 +1,10 @@
1
+ import { ILogger, LogLevel } from './ILogger.js';
2
+ export declare class ConsoleLogger implements ILogger {
3
+ logTrace(message: string, ...args: any[]): void;
4
+ logDebug(message: string, ...args: any[]): void;
5
+ logInformation(message: string, ...args: any[]): void;
6
+ logWarning(message: string, ...args: any[]): void;
7
+ logError(message: string, error?: Error, ...args: any[]): void;
8
+ logCritical(message: string, error?: Error, ...args: any[]): void;
9
+ log(level: LogLevel, message: string, error?: Error, ...args: any[]): void;
10
+ }
@@ -0,0 +1,50 @@
1
+ import { Lifecycle } from 'tsyringe';
2
+ import { ILoggerToken, LogLevel } from './ILogger.js';
3
+ import { services } from '@quandis/qbo4.configuration';
4
+ export class ConsoleLogger {
5
+ logTrace(message, ...args) {
6
+ console.debug(message, ...args);
7
+ }
8
+ logDebug(message, ...args) {
9
+ console.debug(message, ...args);
10
+ }
11
+ logInformation(message, ...args) {
12
+ console.info(message, ...args);
13
+ }
14
+ logWarning(message, ...args) {
15
+ console.warn(message, ...args);
16
+ }
17
+ logError(message, error, ...args) {
18
+ console.error(message, ...(error ? [error, ...args] : args));
19
+ }
20
+ logCritical(message, error, ...args) {
21
+ console.error(`CRITICAL: ${message}`, ...(error ? [error, ...args] : args));
22
+ }
23
+ log(level, message, error, ...args) {
24
+ switch (level) {
25
+ case LogLevel.Trace:
26
+ this.logTrace(message, ...args);
27
+ break;
28
+ case LogLevel.Debug:
29
+ this.logDebug(message, ...args);
30
+ break;
31
+ case LogLevel.Information:
32
+ this.logInformation(message, ...args);
33
+ break;
34
+ case LogLevel.Warning:
35
+ this.logWarning(message, ...args);
36
+ break;
37
+ case LogLevel.Error:
38
+ this.logError(message, error, ...args);
39
+ break;
40
+ case LogLevel.Critical:
41
+ this.logCritical(message, error, ...args);
42
+ break;
43
+ default:
44
+ console.log(message, ...args);
45
+ break;
46
+ }
47
+ }
48
+ }
49
+ services.container.register(ILoggerToken, { useClass: ConsoleLogger }, { lifecycle: Lifecycle.Singleton });
50
+ //# sourceMappingURL=ConsoleLogger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConsoleLogger.js","sourceRoot":"","sources":["ConsoleLogger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAW,YAAY,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,MAAM,OAAO,aAAa;IAEtB,QAAQ,CAAC,OAAe,EAAE,GAAG,IAAW;QACpC,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;IACpC,CAAC;IAED,QAAQ,CAAC,OAAe,EAAE,GAAG,IAAW;QACpC,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;IACpC,CAAC;IAED,cAAc,CAAC,OAAe,EAAE,GAAG,IAAW;QAC1C,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;IACnC,CAAC;IAED,UAAU,CAAC,OAAe,EAAE,GAAG,IAAW;QACtC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;IACnC,CAAC;IAED,QAAQ,CAAC,OAAe,EAAE,KAAa,EAAE,GAAG,I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AAO,EAAE,GAAG,IAAI,CAAC,CAAC;gBAC9B,MAAM;QACd,CAAC;IACL,CAAC;CACJ;AAED,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAU,YAAY,EAAE,EAAE,QAAQ,EAAE,aAAa,EAAE,EAAE,EAAE,SAAS,EAAE,SAAS,CAAC,SAAS,EAAE,CAAC,CAAC"}
@@ -0,0 +1,57 @@
1
+ import { Lifecycle } from 'tsyringe';
2
+ import { ILogger, ILoggerToken, LogLevel } from './ILogger.js';
3
+ import { services } from '@quandis/qbo4.configuration';
4
+ export class ConsoleLogger implements ILogger {
5
+
6
+ logTrace(message: string, ...args: any[]): void {
7
+ console.debug(message, ...args);
8
+ }
9
+
10
+ logDebug(message: string, ...args: any[]): void {
11
+ console.debug(message, ...args);
12
+ }
13
+
14
+ logInformation(message: string, ...args: any[]): void {
15
+ console.info(message, ...args);
16
+ }
17
+
18
+ logWarning(message: string, ...args: any[]): void {
19
+ console.warn(message, ...args);
20
+ }
21
+
22
+ logError(message: string, error?: Error, ...args: any[]): void {
23
+ console.error(message, ...(error ? [error, ...args] : args));
24
+ }
25
+
26
+ logCritical(message: string, error?: Error, ...args: any[]): void {
27
+ console.error(`CRITICAL: ${message}`, ...(error ? [error, ...args] : args));
28
+ }
29
+
30
+ log(level: LogLevel, message: string, error?: Error, ...args: any[]): void {
31
+ switch (level) {
32
+ case LogLevel.Trace:
33
+ this.logTrace(message, ...args);
34
+ break;
35
+ case LogLevel.Debug:
36
+ this.logDebug(message, ...args);
37
+ break;
38
+ case LogLevel.Information:
39
+ this.logInformation(message, ...args);
40
+ break;
41
+ case LogLevel.Warning:
42
+ this.logWarning(message, ...args);
43
+ break;
44
+ case LogLevel.Error:
45
+ this.logError(message, error, ...args);
46
+ break;
47
+ case LogLevel.Critical:
48
+ this.logCritical(message, error, ...args);
49
+ break;
50
+ default:
51
+ console.log(message, ...args);
52
+ break;
53
+ }
54
+ }
55
+ }
56
+
57
+ services.container.register<ILogger>(ILoggerToken, { useClass: ConsoleLogger }, { lifecycle: Lifecycle.Singleton });
@@ -0,0 +1,7 @@
1
+ import { LogLevel } from "./ILogger.js";
2
+ export interface ILogEntry {
3
+ logLevel: LogLevel;
4
+ message: string;
5
+ error?: Error;
6
+ args: any[];
7
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ILogEntry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ILogEntry.js","sourceRoot":"","sources":["ILogEntry.ts"],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ import { LogLevel } from "./ILogger.js";
2
+
3
+ export interface ILogEntry {
4
+ logLevel: LogLevel,
5
+ message: string,
6
+ error?: Error,
7
+ args: any[]
8
+ }
9
+
@@ -0,0 +1,10 @@
1
+ import { InjectionToken } from 'tsyringe';
2
+ import { ILogEntry } from './ILogEntry.js';
3
+ export interface ILogReader {
4
+ getLogs(): ILogEntry[];
5
+ clearLogs(): void;
6
+ }
7
+ /**
8
+ * Define a token for the ILogReader interface
9
+ */
10
+ export declare const ILogReaderToken: InjectionToken<ILogReader>;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Define a token for the ILogReader interface
3
+ */
4
+ export const ILogReaderToken = 'LogReaderToken';
5
+ //# sourceMappingURL=ILogReader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ILogReader.js","sourceRoot":"","sources":["ILogReader.ts"],"names":[],"mappings":"AAQA;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAA+B,gBAAgB,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { InjectionToken } from 'tsyringe';
2
+ import { ILogEntry } from './ILogEntry.js';
3
+
4
+ export interface ILogReader {
5
+ getLogs(): ILogEntry[];
6
+ clearLogs(): void;
7
+ }
8
+
9
+ /**
10
+ * Define a token for the ILogReader interface
11
+ */
12
+ export const ILogReaderToken: InjectionToken<ILogReader> = 'LogReaderToken';
@@ -0,0 +1,22 @@
1
+ import { InjectionToken } from 'tsyringe';
2
+ export interface ILogger {
3
+ logTrace(message: string, ...args: any[]): void;
4
+ logDebug(message: string, ...args: any[]): void;
5
+ logInformation(message: string, ...args: any[]): void;
6
+ logWarning(message: string, ...args: any[]): void;
7
+ logError(message: string, error?: Error, ...args: any[]): void;
8
+ logCritical(message: string, error?: Error, ...args: any[]): void;
9
+ log(level: LogLevel, message: string, error?: Error, ...args: any[]): void;
10
+ }
11
+ /**
12
+ * Define a token for the ILogger interface
13
+ */
14
+ export declare const ILoggerToken: InjectionToken<ILogger>;
15
+ export declare enum LogLevel {
16
+ Trace = 0,
17
+ Debug = 1,
18
+ Information = 2,
19
+ Warning = 3,
20
+ Error = 4,
21
+ Critical = 5
22
+ }
package/src/ILogger.js ADDED
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Define a token for the ILogger interface
3
+ */
4
+ export const ILoggerToken = 'LoggerToken';
5
+ export var LogLevel;
6
+ (function (LogLevel) {
7
+ LogLevel[LogLevel["Trace"] = 0] = "Trace";
8
+ LogLevel[LogLevel["Debug"] = 1] = "Debug";
9
+ LogLevel[LogLevel["Information"] = 2] = "Information";
10
+ LogLevel[LogLevel["Warning"] = 3] = "Warning";
11
+ LogLevel[LogLevel["Error"] = 4] = "Error";
12
+ LogLevel[LogLevel["Critical"] = 5] = "Critical";
13
+ })(LogLevel || (LogLevel = {}));
14
+ //# sourceMappingURL=ILogger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ILogger.js","sourceRoot":"","sources":["ILogger.ts"],"names":[],"mappings":"AA0BA;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAA4B,aAAa,CAAC;AAEnE,MAAM,CAAN,IAAY,QAOX;AAPD,WAAY,QAAQ;IAChB,yCAAK,CAAA;IACL,yCAAK,CAAA;IACL,qDAAW,CAAA;IACX,6CAAO,CAAA;IACP,yCAAK,CAAA;IACL,+CAAQ,CAAA;AACZ,CAAC,EAPW,QAAQ,KAAR,QAAQ,QAOnB"}
package/src/ILogger.ts ADDED
@@ -0,0 +1,39 @@
1
+ import { InjectionToken } from 'tsyringe';
2
+
3
+ export interface ILogger {
4
+
5
+ // Logs a debug message
6
+ logTrace(message: string, ...args: any[]): void;
7
+
8
+ // Logs a debug message
9
+ logDebug(message: string, ...args: any[]): void;
10
+
11
+ // Logs an information message
12
+ logInformation(message: string, ...args: any[]): void;
13
+
14
+ // Logs a warning message
15
+ logWarning(message: string, ...args: any[]): void;
16
+
17
+ // Logs an error message
18
+ logError(message: string, error?: Error, ...args: any[]): void;
19
+
20
+ // Logs a critical error message
21
+ logCritical(message: string, error?: Error, ...args: any[]): void;
22
+
23
+ // Generic log method, if needed
24
+ log(level: LogLevel, message: string, error?: Error, ...args: any[]): void;
25
+ }
26
+
27
+ /**
28
+ * Define a token for the ILogger interface
29
+ */
30
+ export const ILoggerToken: InjectionToken<ILogger> = 'LoggerToken';
31
+
32
+ export enum LogLevel {
33
+ Trace,
34
+ Debug,
35
+ Information,
36
+ Warning,
37
+ Error,
38
+ Critical
39
+ }
@@ -0,0 +1,13 @@
1
+ import { InjectionToken } from 'tsyringe';
2
+ import { ILogReader } from './ILogReader.js';
3
+ import { ILogger } from './ILogger.js';
4
+ /**
5
+ * A service that provides logging capabilities.
6
+ * This will log to every registered ILogger, and read from every registered ILogReader.
7
+ */
8
+ export interface ILoggerService extends ILogger, ILogReader {
9
+ }
10
+ /**
11
+ * Define a token for the ILoggerService interface
12
+ */
13
+ export declare const ILoggerServiceToken: InjectionToken<ILoggerService>;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Define a token for the ILoggerService interface
3
+ */
4
+ export const ILoggerServiceToken = 'LoggerServiceToken';
5
+ //# sourceMappingURL=ILoggerService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ILoggerService.js","sourceRoot":"","sources":["ILoggerService.ts"],"names":[],"mappings":"AAUA;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAmC,oBAAoB,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { InjectionToken } from 'tsyringe';
2
+ import { ILogReader } from './ILogReader.js';
3
+ import { ILogger } from './ILogger.js';
4
+
5
+ /**
6
+ * A service that provides logging capabilities.
7
+ * This will log to every registered ILogger, and read from every registered ILogReader.
8
+ */
9
+ export interface ILoggerService extends ILogger, ILogReader { }
10
+
11
+ /**
12
+ * Define a token for the ILoggerService interface
13
+ */
14
+ export const ILoggerServiceToken: InjectionToken<ILoggerService> = 'LoggerServiceToken';
@@ -0,0 +1,24 @@
1
+ import { ILogEntry } from './ILogEntry.js';
2
+ import { ILogger, LogLevel } from './ILogger.js';
3
+ import { ILogReader } from './ILogReader.js';
4
+ import { ILoggerService } from './ILoggerService.js';
5
+ export declare class LoggerService implements ILoggerService {
6
+ private loggers;
7
+ private readers;
8
+ constructor(loggers: ILogger[], readers: ILogReader[]);
9
+ logTrace(message: string, ...args: any[]): void;
10
+ logDebug(message: string, ...args: any[]): void;
11
+ logInformation(message: string, ...args: any[]): void;
12
+ logWarning(message: string, ...args: any[]): void;
13
+ logError(message: string, error?: Error, ...args: any[]): void;
14
+ logCritical(message: string, error?: Error, ...args: any[]): void;
15
+ log(level: LogLevel, message: string, error?: Error, ...args: any[]): void;
16
+ /**
17
+ * Retrieves all log entries.
18
+ */
19
+ getLogs(): ILogEntry[];
20
+ /**
21
+ * Clears all log entries from memory.
22
+ */
23
+ clearLogs(): void;
24
+ }