@odg/json-log 0.0.1 → 1.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.
- package/README.md +5 -3
- package/dist/Exceptions/JSONParserUnknownException.d.ts +3 -0
- package/dist/Exceptions/JSONParserUnknownException.js +8 -0
- package/dist/Exceptions/JSONParserUnknownException.js.map +1 -0
- package/dist/Exceptions/index.d.ts +1 -0
- package/dist/Exceptions/index.js +18 -0
- package/dist/Exceptions/index.js.map +1 -0
- package/dist/Interfaces/LoggerObjectInterface.d.ts +11 -11
- package/dist/Packages/JSONLogger.d.ts +16 -0
- package/dist/Packages/JSONLogger.js +32 -0
- package/dist/Packages/JSONLogger.js.map +1 -0
- package/dist/{logs → Packages}/JSONLoggerPlugin.d.ts +11 -23
- package/dist/{package → Packages}/JSONLoggerPlugin.js +54 -44
- package/dist/Packages/JSONLoggerPlugin.js.map +1 -0
- package/dist/Packages/index.d.ts +2 -0
- package/dist/Packages/index.js +19 -0
- package/dist/Packages/index.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +23 -15
- package/dist/example.d.ts +0 -1
- package/dist/example.js +0 -8
- package/dist/example.js.map +0 -1
- package/dist/lib/JSONLoggerPlugin.d.ts +0 -113
- package/dist/lib/JSONLoggerPlugin.js +0 -215
- package/dist/lib/JSONLoggerPlugin.js.map +0 -1
- package/dist/lib/ParserException.d.ts +0 -3
- package/dist/lib/ParserException.js +0 -8
- package/dist/lib/ParserException.js.map +0 -1
- package/dist/logs/JSONLoggerPlugin.js +0 -215
- package/dist/logs/JSONLoggerPlugin.js.map +0 -1
- package/dist/logs/ParserException.d.ts +0 -3
- package/dist/logs/ParserException.js +0 -8
- package/dist/logs/ParserException.js.map +0 -1
- package/dist/package/JSONLoggerPlugin.d.ts +0 -113
- package/dist/package/JSONLoggerPlugin.js.map +0 -1
- package/dist/package/JSONParserException.d.ts +0 -3
- package/dist/package/JSONParserException.js +0 -8
- package/dist/package/JSONParserException.js.map +0 -1
- package/dist/package/ParserException.d.ts +0 -3
- package/dist/package/ParserException.js +0 -8
- package/dist/package/ParserException.js.map +0 -1
package/README.md
CHANGED
|
@@ -78,11 +78,13 @@ yarn add @odg/json-log
|
|
|
78
78
|
### 🎲 Implementation
|
|
79
79
|
|
|
80
80
|
```typescript
|
|
81
|
-
const logger = new
|
|
82
|
-
const
|
|
81
|
+
const logger = new Logger(); // Or Other Class Logger
|
|
82
|
+
const consoleLogger = new ConsoleLogger(); // Or Other Class Logger
|
|
83
|
+
const processor = new JSONLoggerPlugin(
|
|
83
84
|
"appName",
|
|
84
85
|
);
|
|
85
|
-
logger.
|
|
86
|
+
logger.pushHandler(consoleLogger);
|
|
87
|
+
logger.pushProcessor(processor);
|
|
86
88
|
|
|
87
89
|
plugin.setIdentifier(randomUUID());
|
|
88
90
|
```
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JSONParserUnknownException = void 0;
|
|
4
|
+
const exception_1 = require("@odg/exception");
|
|
5
|
+
class JSONParserUnknownException extends exception_1.UnknownException {
|
|
6
|
+
}
|
|
7
|
+
exports.JSONParserUnknownException = JSONParserUnknownException;
|
|
8
|
+
//# sourceMappingURL=JSONParserUnknownException.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JSONParserUnknownException.js","sourceRoot":"","sources":["../../src/Exceptions/JSONParserUnknownException.ts"],"names":[],"mappings":";;;AAAA,8CAAkD;AAElD,MAAa,0BAA2B,SAAQ,4BAAgB;CAE/D;AAFD,gEAEC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./JSONParserUnknownException";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./JSONParserUnknownException"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Exceptions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+DAA6C"}
|
|
@@ -8,20 +8,20 @@ export interface ExceptionObjectLoggerInterface {
|
|
|
8
8
|
"functionName"?: string;
|
|
9
9
|
"fileLine"?: number;
|
|
10
10
|
"fileColumn"?: number;
|
|
11
|
-
"
|
|
11
|
+
"stack"?: string;
|
|
12
12
|
}
|
|
13
13
|
export type LoggerObjectRequestInterface = RequestInterface<unknown> & {
|
|
14
14
|
response?: Omit<ResponseInterface<unknown, unknown>, "request">;
|
|
15
15
|
};
|
|
16
16
|
export interface LoggerObjectInterface {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
17
|
+
type: LogLevel;
|
|
18
|
+
index: string;
|
|
19
|
+
instance: string;
|
|
20
|
+
identifier?: string;
|
|
21
|
+
gitRelease?: string;
|
|
22
|
+
gitBranch?: string;
|
|
23
|
+
exception?: ExceptionObjectLoggerInterface;
|
|
24
|
+
exceptionPreview?: ExceptionObjectLoggerInterface[];
|
|
25
|
+
request?: LoggerObjectRequestInterface;
|
|
26
|
+
createdAt: Date;
|
|
27
27
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type LogLevel } from "@odg/log";
|
|
2
|
+
import { type LoggerObjectInterface, type ExceptionObjectLoggerInterface, type LoggerObjectRequestInterface } from "..";
|
|
3
|
+
export declare class JSONLogger implements LoggerObjectInterface {
|
|
4
|
+
type: LogLevel;
|
|
5
|
+
index: string;
|
|
6
|
+
instance: string;
|
|
7
|
+
message: unknown;
|
|
8
|
+
createdAt: Date;
|
|
9
|
+
identifier?: string | undefined;
|
|
10
|
+
gitRelease?: string | undefined;
|
|
11
|
+
gitBranch?: string | undefined;
|
|
12
|
+
exception?: ExceptionObjectLoggerInterface | undefined;
|
|
13
|
+
exceptionPreview?: ExceptionObjectLoggerInterface[] | undefined;
|
|
14
|
+
request?: LoggerObjectRequestInterface | undefined;
|
|
15
|
+
constructor(type: LogLevel, index: string, instance: string, message: unknown, createdAt: Date, identifier?: string | undefined, gitRelease?: string | undefined, gitBranch?: string | undefined, exception?: ExceptionObjectLoggerInterface | undefined, exceptionPreview?: ExceptionObjectLoggerInterface[] | undefined, request?: LoggerObjectRequestInterface | undefined);
|
|
16
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JSONLogger = void 0;
|
|
4
|
+
class JSONLogger {
|
|
5
|
+
type;
|
|
6
|
+
index;
|
|
7
|
+
instance;
|
|
8
|
+
message;
|
|
9
|
+
createdAt;
|
|
10
|
+
identifier;
|
|
11
|
+
gitRelease;
|
|
12
|
+
gitBranch;
|
|
13
|
+
exception;
|
|
14
|
+
exceptionPreview;
|
|
15
|
+
request;
|
|
16
|
+
// eslint-disable-next-line better-max-params/better-max-params
|
|
17
|
+
constructor(type, index, instance, message, createdAt, identifier, gitRelease, gitBranch, exception, exceptionPreview, request) {
|
|
18
|
+
this.type = type;
|
|
19
|
+
this.index = index;
|
|
20
|
+
this.instance = instance;
|
|
21
|
+
this.message = message;
|
|
22
|
+
this.createdAt = createdAt;
|
|
23
|
+
this.identifier = identifier;
|
|
24
|
+
this.gitRelease = gitRelease;
|
|
25
|
+
this.gitBranch = gitBranch;
|
|
26
|
+
this.exception = exception;
|
|
27
|
+
this.exceptionPreview = exceptionPreview;
|
|
28
|
+
this.request = request;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.JSONLogger = JSONLogger;
|
|
32
|
+
//# sourceMappingURL=JSONLogger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JSONLogger.js","sourceRoot":"","sources":["../../src/Packages/JSONLogger.ts"],"names":[],"mappings":";;;AAIA,MAAa,UAAU;IAIR;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAZX,+DAA+D;IAC/D,YACW,IAAc,EACd,KAAa,EACb,QAAgB,EAChB,OAAgB,EAChB,SAAe,EACf,UAAmB,EACnB,UAAmB,EACnB,SAAkB,EAClB,SAA0C,EAC1C,gBAAmD,EACnD,OAAsC;QAVtC,SAAI,GAAJ,IAAI,CAAU;QACd,UAAK,GAAL,KAAK,CAAQ;QACb,aAAQ,GAAR,QAAQ,CAAQ;QAChB,YAAO,GAAP,OAAO,CAAS;QAChB,cAAS,GAAT,SAAS,CAAM;QACf,eAAU,GAAV,UAAU,CAAS;QACnB,eAAU,GAAV,UAAU,CAAS;QACnB,cAAS,GAAT,SAAS,CAAS;QAClB,cAAS,GAAT,SAAS,CAAiC;QAC1C,qBAAgB,GAAhB,gBAAgB,CAAmC;QACnD,YAAO,GAAP,OAAO,CAA+B;IAEjD,CAAC;CAEJ;AAlBD,gCAkBC"}
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { type LogLevel, type LoggerParserInterface, type LoggerPluginInterface } from "@odg/log";
|
|
2
2
|
import { type ResponseInterface, type RequestInterface } from "@odg/message";
|
|
3
|
-
import { type LoggerObjectRequestInterface, type ExceptionObjectLoggerInterface
|
|
3
|
+
import { type LoggerObjectRequestInterface, type ExceptionObjectLoggerInterface } from "../Interfaces";
|
|
4
|
+
import { JSONLogger } from "./JSONLogger";
|
|
4
5
|
export declare class JSONLoggerPlugin implements LoggerPluginInterface {
|
|
5
6
|
protected readonly appName: string;
|
|
6
|
-
protected readonly instanceId?: string | undefined;
|
|
7
7
|
protected readonly maxExceptionPreview: number;
|
|
8
|
+
protected readonly instanceId?: string | undefined;
|
|
8
9
|
/**
|
|
9
10
|
* Identifier for the current log
|
|
10
11
|
*
|
|
11
12
|
* @type {string}
|
|
12
13
|
*/
|
|
13
14
|
protected identifier?: string;
|
|
14
|
-
constructor(appName: string, instanceId?: string | undefined
|
|
15
|
+
constructor(appName: string, maxExceptionPreview?: number, instanceId?: string | undefined);
|
|
15
16
|
/**
|
|
16
17
|
* Plugin parser Function return new message with JSON format
|
|
17
18
|
*
|
|
@@ -19,13 +20,12 @@ export declare class JSONLoggerPlugin implements LoggerPluginInterface {
|
|
|
19
20
|
* @returns {Promise<LoggerParserInterface>}
|
|
20
21
|
*/
|
|
21
22
|
parser(data: LoggerParserInterface): Promise<LoggerParserInterface>;
|
|
22
|
-
logJSON(level: LogLevel, message: unknown): Promise<
|
|
23
|
+
logJSON(level: LogLevel, message: unknown): Promise<JSONLogger>;
|
|
23
24
|
/**
|
|
24
25
|
* Define a unique identifier for the current request, for
|
|
25
26
|
* Example: Request ID, Transaction ID, Crawler Process, etc
|
|
26
27
|
*
|
|
27
28
|
* @param {string} identifier Unique identifier
|
|
28
|
-
* @memberof JSONLoggerPlugin
|
|
29
29
|
*/
|
|
30
30
|
setIdentifier(identifier: string): void;
|
|
31
31
|
/**
|
|
@@ -57,57 +57,45 @@ export declare class JSONLoggerPlugin implements LoggerPluginInterface {
|
|
|
57
57
|
* If Message is a Exception, get All Exception Preview and parse to ExceptionObjectLoggerInterface
|
|
58
58
|
*
|
|
59
59
|
* @param {unknown} exception Possible Exception
|
|
60
|
-
* @returns {Promise<ExceptionObjectLoggerInterface | undefined>}
|
|
60
|
+
* @returns {Promise<ExceptionObjectLoggerInterface[] | undefined>}
|
|
61
61
|
*/
|
|
62
62
|
protected parseExceptionPreview(exception: unknown): Promise<ExceptionObjectLoggerInterface[] | undefined>;
|
|
63
63
|
/**
|
|
64
64
|
* Parser Request and Response
|
|
65
65
|
*
|
|
66
|
+
* @memberof JSONLoggerPlugin
|
|
66
67
|
* @protected
|
|
67
68
|
* @param {unknown} message Possible Message/Request
|
|
68
69
|
* @returns {Promise<LoggerObjectRequestInterface | undefined>}
|
|
69
|
-
* @memberof JSONLoggerPlugin
|
|
70
70
|
*/
|
|
71
71
|
protected parseRequest(message: unknown): Promise<LoggerObjectRequestInterface | undefined>;
|
|
72
72
|
/**
|
|
73
73
|
* Get Response
|
|
74
74
|
*
|
|
75
|
+
* @memberof JSONLoggerPlugin
|
|
75
76
|
* @protected
|
|
76
77
|
* @param {unknown} message Possible Request/Message
|
|
77
78
|
* @returns {Promise<ResponseInterface<unknown, unknown> | undefined>}
|
|
78
|
-
* @memberof JSONLoggerPlugin
|
|
79
79
|
*/
|
|
80
80
|
protected getResponseMessage(message: unknown): Promise<ResponseInterface<unknown, unknown> | undefined>;
|
|
81
81
|
/**
|
|
82
82
|
* Get Request
|
|
83
83
|
*
|
|
84
|
+
* @memberof JSONLoggerPlugin
|
|
84
85
|
* @protected
|
|
85
86
|
* @param {unknown} message Possible Request/Message
|
|
86
|
-
* @returns {Promise<
|
|
87
|
-
* @memberof JSONLoggerPlugin
|
|
87
|
+
* @returns {Promise<RequestInterface<unknown> | undefined>}
|
|
88
88
|
*/
|
|
89
89
|
protected getRequestMessage(message: unknown): Promise<RequestInterface<unknown> | undefined>;
|
|
90
90
|
/**
|
|
91
91
|
* Check Is Message Response or Request or Exception Message
|
|
92
92
|
*
|
|
93
|
+
* @memberof JSONLoggerPlugin
|
|
93
94
|
* @protected
|
|
94
95
|
* @param {unknown} message Possible Message/Request
|
|
95
96
|
* @returns {Promise<boolean>}
|
|
96
|
-
* @memberof JSONLoggerPlugin
|
|
97
97
|
*/
|
|
98
98
|
protected isRequestOrResponseMessage(message: unknown): Promise<boolean>;
|
|
99
|
-
/**
|
|
100
|
-
* Check is Response Message
|
|
101
|
-
*
|
|
102
|
-
* @param {unknown} message Possible Response/Message
|
|
103
|
-
* @returns {boolean}
|
|
104
|
-
*/
|
|
105
99
|
protected isResponseMessage(message: unknown): message is ResponseInterface<unknown, unknown>;
|
|
106
|
-
/**
|
|
107
|
-
* Check is Request Message
|
|
108
|
-
*
|
|
109
|
-
* @param {unknown} message Possible Request/Message
|
|
110
|
-
* @returns {boolean}
|
|
111
|
-
*/
|
|
112
100
|
protected isRequestMessage(message: unknown): message is RequestInterface<unknown>;
|
|
113
101
|
}
|
|
@@ -1,20 +1,53 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
27
|
};
|
|
5
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
29
|
exports.JSONLoggerPlugin = void 0;
|
|
7
30
|
const node_child_process_1 = require("node:child_process");
|
|
8
|
-
const node_util_1 = require("node:util");
|
|
31
|
+
const node_util_1 = __importStar(require("node:util"));
|
|
9
32
|
const exception_1 = require("@odg/exception");
|
|
10
33
|
const message_1 = require("@odg/message");
|
|
11
34
|
const error_stack_parser_1 = __importDefault(require("error-stack-parser"));
|
|
12
|
-
const
|
|
35
|
+
const JSONParserUnknownException_1 = require("../Exceptions/JSONParserUnknownException");
|
|
36
|
+
const JSONLogger_1 = require("./JSONLogger");
|
|
13
37
|
class JSONLoggerPlugin {
|
|
14
|
-
|
|
38
|
+
appName;
|
|
39
|
+
maxExceptionPreview;
|
|
40
|
+
instanceId;
|
|
41
|
+
/**
|
|
42
|
+
* Identifier for the current log
|
|
43
|
+
*
|
|
44
|
+
* @type {string}
|
|
45
|
+
*/
|
|
46
|
+
identifier;
|
|
47
|
+
constructor(appName, maxExceptionPreview = 10, instanceId) {
|
|
15
48
|
this.appName = appName;
|
|
16
|
-
this.instanceId = instanceId;
|
|
17
49
|
this.maxExceptionPreview = maxExceptionPreview;
|
|
50
|
+
this.instanceId = instanceId;
|
|
18
51
|
}
|
|
19
52
|
/**
|
|
20
53
|
* Plugin parser Function return new message with JSON format
|
|
@@ -30,29 +63,17 @@ class JSONLoggerPlugin {
|
|
|
30
63
|
};
|
|
31
64
|
}
|
|
32
65
|
catch (error) {
|
|
33
|
-
throw new
|
|
66
|
+
throw new JSONParserUnknownException_1.JSONParserUnknownException("JSON Plugin Parser exception", error);
|
|
34
67
|
}
|
|
35
68
|
}
|
|
36
69
|
async logJSON(level, message) {
|
|
37
|
-
return
|
|
38
|
-
"type": level,
|
|
39
|
-
"index": this.appName,
|
|
40
|
-
"instance": this.getInstance(),
|
|
41
|
-
"identifier": this.identifier,
|
|
42
|
-
"gitRelease": await this.getGitRelease().catch(() => void 0),
|
|
43
|
-
"gitBranch": await this.getGitBranch().catch(() => void 0),
|
|
44
|
-
"exception": await this.parseException(message),
|
|
45
|
-
"exceptionPreview": await this.parseExceptionPreview(message),
|
|
46
|
-
"request": await this.parseRequest(message),
|
|
47
|
-
"createdAt": new Date(),
|
|
48
|
-
};
|
|
70
|
+
return new JSONLogger_1.JSONLogger(level, this.appName, this.getInstance(), JSON.stringify(message) || node_util_1.default.format(message), new Date(), this.identifier, await this.getGitRelease().catch(() => void 0), await this.getGitBranch().catch(() => void 0), await this.parseException(message), await this.parseExceptionPreview(message), await this.parseRequest(message));
|
|
49
71
|
}
|
|
50
72
|
/**
|
|
51
73
|
* Define a unique identifier for the current request, for
|
|
52
74
|
* Example: Request ID, Transaction ID, Crawler Process, etc
|
|
53
75
|
*
|
|
54
76
|
* @param {string} identifier Unique identifier
|
|
55
|
-
* @memberof JSONLoggerPlugin
|
|
56
77
|
*/
|
|
57
78
|
setIdentifier(identifier) {
|
|
58
79
|
this.identifier = identifier;
|
|
@@ -63,9 +84,11 @@ class JSONLoggerPlugin {
|
|
|
63
84
|
* @returns {string}
|
|
64
85
|
*/
|
|
65
86
|
getInstance() {
|
|
66
|
-
|
|
87
|
+
const instanceProperty = this.instanceId ?? "";
|
|
88
|
+
return instanceProperty
|
|
67
89
|
|| process.env.HOSTNAME
|
|
68
90
|
|| process.env.CONTAINER_ID
|
|
91
|
+
|| process.env.DOCKER_CONTAINER_UUID
|
|
69
92
|
|| "unknown";
|
|
70
93
|
}
|
|
71
94
|
/**
|
|
@@ -95,25 +118,24 @@ class JSONLoggerPlugin {
|
|
|
95
118
|
* @returns {Promise<ExceptionObjectLoggerInterface | undefined>}
|
|
96
119
|
*/
|
|
97
120
|
async parseException(exception) {
|
|
98
|
-
var _a, _b, _c, _d;
|
|
99
121
|
if (!(exception instanceof Error))
|
|
100
122
|
return;
|
|
101
123
|
const trace = exception.stack ? error_stack_parser_1.default.parse(exception) : undefined;
|
|
102
124
|
return {
|
|
103
125
|
"type": exception.name,
|
|
104
126
|
"message": exception.message,
|
|
105
|
-
"fileException":
|
|
106
|
-
"functionName":
|
|
107
|
-
"fileLine":
|
|
108
|
-
"fileColumn":
|
|
109
|
-
"
|
|
127
|
+
"fileException": trace?.[0]?.getFileName(),
|
|
128
|
+
"functionName": trace?.[0]?.getFunctionName(),
|
|
129
|
+
"fileLine": trace?.[0]?.getLineNumber(),
|
|
130
|
+
"fileColumn": trace?.[0]?.getColumnNumber(),
|
|
131
|
+
"stack": exception.stack,
|
|
110
132
|
};
|
|
111
133
|
}
|
|
112
134
|
/**
|
|
113
135
|
* If Message is a Exception, get All Exception Preview and parse to ExceptionObjectLoggerInterface
|
|
114
136
|
*
|
|
115
137
|
* @param {unknown} exception Possible Exception
|
|
116
|
-
* @returns {Promise<ExceptionObjectLoggerInterface | undefined>}
|
|
138
|
+
* @returns {Promise<ExceptionObjectLoggerInterface[] | undefined>}
|
|
117
139
|
*/
|
|
118
140
|
async parseExceptionPreview(exception) {
|
|
119
141
|
if (!(exception instanceof exception_1.Exception))
|
|
@@ -125,17 +147,17 @@ class JSONLoggerPlugin {
|
|
|
125
147
|
const parsedException = await this.parseException(exceptionBase);
|
|
126
148
|
if (parsedException)
|
|
127
149
|
exceptionCollection.push(parsedException);
|
|
128
|
-
exceptionBase = exceptionBase
|
|
150
|
+
exceptionBase = exceptionBase?.preview;
|
|
129
151
|
} while (exceptionBase && ++exceptionCount < this.maxExceptionPreview);
|
|
130
152
|
return exceptionCollection;
|
|
131
153
|
}
|
|
132
154
|
/**
|
|
133
155
|
* Parser Request and Response
|
|
134
156
|
*
|
|
157
|
+
* @memberof JSONLoggerPlugin
|
|
135
158
|
* @protected
|
|
136
159
|
* @param {unknown} message Possible Message/Request
|
|
137
160
|
* @returns {Promise<LoggerObjectRequestInterface | undefined>}
|
|
138
|
-
* @memberof JSONLoggerPlugin
|
|
139
161
|
*/
|
|
140
162
|
async parseRequest(message) {
|
|
141
163
|
if (!await this.isRequestOrResponseMessage(message))
|
|
@@ -152,10 +174,10 @@ class JSONLoggerPlugin {
|
|
|
152
174
|
/**
|
|
153
175
|
* Get Response
|
|
154
176
|
*
|
|
177
|
+
* @memberof JSONLoggerPlugin
|
|
155
178
|
* @protected
|
|
156
179
|
* @param {unknown} message Possible Request/Message
|
|
157
180
|
* @returns {Promise<ResponseInterface<unknown, unknown> | undefined>}
|
|
158
|
-
* @memberof JSONLoggerPlugin
|
|
159
181
|
*/
|
|
160
182
|
async getResponseMessage(message) {
|
|
161
183
|
if (message instanceof message_1.MessageException)
|
|
@@ -167,10 +189,10 @@ class JSONLoggerPlugin {
|
|
|
167
189
|
/**
|
|
168
190
|
* Get Request
|
|
169
191
|
*
|
|
192
|
+
* @memberof JSONLoggerPlugin
|
|
170
193
|
* @protected
|
|
171
194
|
* @param {unknown} message Possible Request/Message
|
|
172
|
-
* @returns {Promise<
|
|
173
|
-
* @memberof JSONLoggerPlugin
|
|
195
|
+
* @returns {Promise<RequestInterface<unknown> | undefined>}
|
|
174
196
|
*/
|
|
175
197
|
async getRequestMessage(message) {
|
|
176
198
|
if (message instanceof message_1.MessageException)
|
|
@@ -184,34 +206,22 @@ class JSONLoggerPlugin {
|
|
|
184
206
|
/**
|
|
185
207
|
* Check Is Message Response or Request or Exception Message
|
|
186
208
|
*
|
|
209
|
+
* @memberof JSONLoggerPlugin
|
|
187
210
|
* @protected
|
|
188
211
|
* @param {unknown} message Possible Message/Request
|
|
189
212
|
* @returns {Promise<boolean>}
|
|
190
|
-
* @memberof JSONLoggerPlugin
|
|
191
213
|
*/
|
|
192
214
|
async isRequestOrResponseMessage(message) {
|
|
193
215
|
return message instanceof message_1.MessageException
|
|
194
216
|
|| this.isResponseMessage(message)
|
|
195
217
|
|| this.isRequestMessage(message);
|
|
196
218
|
}
|
|
197
|
-
/**
|
|
198
|
-
* Check is Response Message
|
|
199
|
-
*
|
|
200
|
-
* @param {unknown} message Possible Response/Message
|
|
201
|
-
* @returns {boolean}
|
|
202
|
-
*/
|
|
203
219
|
isResponseMessage(message) {
|
|
204
220
|
return Object.prototype.hasOwnProperty.call(message, "data")
|
|
205
221
|
&& Object.prototype.hasOwnProperty.call(message, "status")
|
|
206
222
|
&& Object.prototype.hasOwnProperty.call(message, "headers")
|
|
207
223
|
&& Object.prototype.hasOwnProperty.call(message, "request");
|
|
208
224
|
}
|
|
209
|
-
/**
|
|
210
|
-
* Check is Request Message
|
|
211
|
-
*
|
|
212
|
-
* @param {unknown} message Possible Request/Message
|
|
213
|
-
* @returns {boolean}
|
|
214
|
-
*/
|
|
215
225
|
isRequestMessage(message) {
|
|
216
226
|
return Object.prototype.hasOwnProperty.call(message, "url")
|
|
217
227
|
&& Object.prototype.hasOwnProperty.call(message, "method");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JSONLoggerPlugin.js","sourceRoot":"","sources":["../../src/Packages/JSONLoggerPlugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2DAA0C;AAC1C,uDAA4C;AAE5C,8CAA2C;AAM3C,0CAA+F;AAC/F,4EAAkD;AAElD,yFAAsF;AAMtF,6CAA0C;AAE1C,MAAa,gBAAgB;IAUF;IACA;IACA;IAVvB;;;;OAIG;IACO,UAAU,CAAU;IAE9B,YACuB,OAAe,EACf,sBAA8B,EAAE,EAChC,UAAmB;QAFnB,YAAO,GAAP,OAAO,CAAQ;QACf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0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./JSONLoggerPlugin"), exports);
|
|
18
|
+
__exportStar(require("./JSONLogger"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Packages/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC;AACnC,+CAA6B"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -14,5 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./Exceptions"), exports);
|
|
17
18
|
__exportStar(require("./Interfaces"), exports);
|
|
19
|
+
__exportStar(require("./Packages"), exports);
|
|
18
20
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,+CAA6B;AAC7B,6CAA2B"}
|