@odg/json-log 0.0.1 → 1.0.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/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 +21 -0
- package/dist/Packages/JSONLogger.js.map +1 -0
- package/dist/{package → Packages}/JSONLoggerPlugin.d.ts +5 -4
- package/dist/{package → Packages}/JSONLoggerPlugin.js +34 -19
- package/dist/Packages/JSONLoggerPlugin.js.map +1 -0
- package/dist/Packages/index.d.ts +3 -0
- package/dist/Packages/index.js +20 -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 +9 -9
- 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.d.ts +0 -113
- 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.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
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { type LogLevel, type LoggerParserInterface, type LoggerPluginInterface } from "@odg/log";
|
|
2
|
-
import { type ResponseInterface, type RequestInterface } from "@odg/message";
|
|
3
|
-
import { type LoggerObjectRequestInterface, type ExceptionObjectLoggerInterface, type LoggerObjectInterface } from "../Interfaces";
|
|
4
|
-
export declare class JSONLoggerPlugin implements LoggerPluginInterface {
|
|
5
|
-
protected readonly appName: string;
|
|
6
|
-
protected readonly instanceId?: string | undefined;
|
|
7
|
-
protected readonly maxExceptionPreview: number;
|
|
8
|
-
/**
|
|
9
|
-
* Identifier for the current log
|
|
10
|
-
*
|
|
11
|
-
* @type {string}
|
|
12
|
-
*/
|
|
13
|
-
protected identifier?: string;
|
|
14
|
-
constructor(appName: string, instanceId?: string | undefined, maxExceptionPreview?: number);
|
|
15
|
-
/**
|
|
16
|
-
* Plugin parser Function return new message with JSON format
|
|
17
|
-
*
|
|
18
|
-
* @param {LoggerParserInterface} data Received Data params
|
|
19
|
-
* @returns {Promise<LoggerParserInterface>}
|
|
20
|
-
*/
|
|
21
|
-
parser(data: LoggerParserInterface): Promise<LoggerParserInterface>;
|
|
22
|
-
logJSON(level: LogLevel, message: unknown): Promise<LoggerObjectInterface>;
|
|
23
|
-
/**
|
|
24
|
-
* Define a unique identifier for the current request, for
|
|
25
|
-
* Example: Request ID, Transaction ID, Crawler Process, etc
|
|
26
|
-
*
|
|
27
|
-
* @param {string} identifier Unique identifier
|
|
28
|
-
* @memberof JSONLoggerPlugin
|
|
29
|
-
*/
|
|
30
|
-
setIdentifier(identifier: string): void;
|
|
31
|
-
/**
|
|
32
|
-
* Return instance HostName, identifier
|
|
33
|
-
*
|
|
34
|
-
* @returns {string}
|
|
35
|
-
*/
|
|
36
|
-
protected getInstance(): string;
|
|
37
|
-
/**
|
|
38
|
-
* Return git tag name
|
|
39
|
-
*
|
|
40
|
-
* @returns {Promise<string>}
|
|
41
|
-
*/
|
|
42
|
-
protected getGitRelease(): Promise<string>;
|
|
43
|
-
/**
|
|
44
|
-
* Return git tag name
|
|
45
|
-
*
|
|
46
|
-
* @returns {Promise<string>}
|
|
47
|
-
*/
|
|
48
|
-
protected getGitBranch(): Promise<string>;
|
|
49
|
-
/**
|
|
50
|
-
* If Message is a Exception, parse to ExceptionObjectLoggerInterface
|
|
51
|
-
*
|
|
52
|
-
* @param {unknown} exception Possible Exception
|
|
53
|
-
* @returns {Promise<ExceptionObjectLoggerInterface | undefined>}
|
|
54
|
-
*/
|
|
55
|
-
protected parseException(exception: unknown): Promise<ExceptionObjectLoggerInterface | undefined>;
|
|
56
|
-
/**
|
|
57
|
-
* If Message is a Exception, get All Exception Preview and parse to ExceptionObjectLoggerInterface
|
|
58
|
-
*
|
|
59
|
-
* @param {unknown} exception Possible Exception
|
|
60
|
-
* @returns {Promise<ExceptionObjectLoggerInterface | undefined>}
|
|
61
|
-
*/
|
|
62
|
-
protected parseExceptionPreview(exception: unknown): Promise<ExceptionObjectLoggerInterface[] | undefined>;
|
|
63
|
-
/**
|
|
64
|
-
* Parser Request and Response
|
|
65
|
-
*
|
|
66
|
-
* @protected
|
|
67
|
-
* @param {unknown} message Possible Message/Request
|
|
68
|
-
* @returns {Promise<LoggerObjectRequestInterface | undefined>}
|
|
69
|
-
* @memberof JSONLoggerPlugin
|
|
70
|
-
*/
|
|
71
|
-
protected parseRequest(message: unknown): Promise<LoggerObjectRequestInterface | undefined>;
|
|
72
|
-
/**
|
|
73
|
-
* Get Response
|
|
74
|
-
*
|
|
75
|
-
* @protected
|
|
76
|
-
* @param {unknown} message Possible Request/Message
|
|
77
|
-
* @returns {Promise<ResponseInterface<unknown, unknown> | undefined>}
|
|
78
|
-
* @memberof JSONLoggerPlugin
|
|
79
|
-
*/
|
|
80
|
-
protected getResponseMessage(message: unknown): Promise<ResponseInterface<unknown, unknown> | undefined>;
|
|
81
|
-
/**
|
|
82
|
-
* Get Request
|
|
83
|
-
*
|
|
84
|
-
* @protected
|
|
85
|
-
* @param {unknown} message Possible Request/Message
|
|
86
|
-
* @returns {Promise<ResponseInterface<unknown, unknown> | undefined>}
|
|
87
|
-
* @memberof JSONLoggerPlugin
|
|
88
|
-
*/
|
|
89
|
-
protected getRequestMessage(message: unknown): Promise<RequestInterface<unknown> | undefined>;
|
|
90
|
-
/**
|
|
91
|
-
* Check Is Message Response or Request or Exception Message
|
|
92
|
-
*
|
|
93
|
-
* @protected
|
|
94
|
-
* @param {unknown} message Possible Message/Request
|
|
95
|
-
* @returns {Promise<boolean>}
|
|
96
|
-
* @memberof JSONLoggerPlugin
|
|
97
|
-
*/
|
|
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
|
-
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
|
-
protected isRequestMessage(message: unknown): message is RequestInterface<unknown>;
|
|
113
|
-
}
|
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.JSONLoggerPlugin = void 0;
|
|
7
|
-
const node_child_process_1 = require("node:child_process");
|
|
8
|
-
const node_util_1 = require("node:util");
|
|
9
|
-
const exception_1 = require("@odg/exception");
|
|
10
|
-
const message_1 = require("@odg/message");
|
|
11
|
-
const error_stack_parser_1 = __importDefault(require("error-stack-parser"));
|
|
12
|
-
class JSONLoggerPlugin {
|
|
13
|
-
constructor(appName, instanceId, maxExceptionPreview = 10) {
|
|
14
|
-
this.appName = appName;
|
|
15
|
-
this.instanceId = instanceId;
|
|
16
|
-
this.maxExceptionPreview = maxExceptionPreview;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Plugin parser Function return new message with JSON format
|
|
20
|
-
*
|
|
21
|
-
* @param {LoggerParserInterface} data Received Data params
|
|
22
|
-
* @returns {Promise<LoggerParserInterface>}
|
|
23
|
-
*/
|
|
24
|
-
async parser(data) {
|
|
25
|
-
return {
|
|
26
|
-
...data,
|
|
27
|
-
message: await this.logJSON(data.level, data.message),
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
async logJSON(level, message) {
|
|
31
|
-
return {
|
|
32
|
-
"type": level,
|
|
33
|
-
"index": this.appName,
|
|
34
|
-
"instance": this.getInstance(),
|
|
35
|
-
"identifier": this.identifier,
|
|
36
|
-
"gitRelease": await this.getGitRelease().catch(() => void 0),
|
|
37
|
-
"gitBranch": await this.getGitBranch().catch(() => void 0),
|
|
38
|
-
"exception": await this.parseException(message),
|
|
39
|
-
"exceptionPreview": await this.parseExceptionPreview(message),
|
|
40
|
-
"request": await this.parseRequest(message),
|
|
41
|
-
"createdAt": new Date(),
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Define a unique identifier for the current request, for
|
|
46
|
-
* Example: Request ID, Transaction ID, Crawler Process, etc
|
|
47
|
-
*
|
|
48
|
-
* @param {string} identifier Unique identifier
|
|
49
|
-
* @memberof JSONLoggerPlugin
|
|
50
|
-
*/
|
|
51
|
-
setIdentifier(identifier) {
|
|
52
|
-
this.identifier = identifier;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Return instance HostName, identifier
|
|
56
|
-
*
|
|
57
|
-
* @returns {string}
|
|
58
|
-
*/
|
|
59
|
-
getInstance() {
|
|
60
|
-
return this.instanceId
|
|
61
|
-
|| process.env.HOSTNAME
|
|
62
|
-
|| process.env.CONTAINER_ID
|
|
63
|
-
|| "unknown";
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Return git tag name
|
|
67
|
-
*
|
|
68
|
-
* @returns {Promise<string>}
|
|
69
|
-
*/
|
|
70
|
-
async getGitRelease() {
|
|
71
|
-
const command = (0, node_util_1.promisify)(node_child_process_1.exec);
|
|
72
|
-
const gitVersion = await command("git describe --tags --abbrev=41");
|
|
73
|
-
return gitVersion.stdout.trim();
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Return git tag name
|
|
77
|
-
*
|
|
78
|
-
* @returns {Promise<string>}
|
|
79
|
-
*/
|
|
80
|
-
async getGitBranch() {
|
|
81
|
-
const command = (0, node_util_1.promisify)(node_child_process_1.exec);
|
|
82
|
-
const gitVersion = await command("git rev-parse --abbrev-ref HEAD");
|
|
83
|
-
return gitVersion.stdout.trim();
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* If Message is a Exception, parse to ExceptionObjectLoggerInterface
|
|
87
|
-
*
|
|
88
|
-
* @param {unknown} exception Possible Exception
|
|
89
|
-
* @returns {Promise<ExceptionObjectLoggerInterface | undefined>}
|
|
90
|
-
*/
|
|
91
|
-
async parseException(exception) {
|
|
92
|
-
var _a, _b, _c, _d;
|
|
93
|
-
if (!(exception instanceof Error))
|
|
94
|
-
return;
|
|
95
|
-
const trace = exception.stack ? error_stack_parser_1.default.parse(exception) : undefined;
|
|
96
|
-
return {
|
|
97
|
-
"type": exception.name,
|
|
98
|
-
"message": exception.message,
|
|
99
|
-
"fileException": (_a = trace === null || trace === void 0 ? void 0 : trace[0]) === null || _a === void 0 ? void 0 : _a.getFileName(),
|
|
100
|
-
"functionName": (_b = trace === null || trace === void 0 ? void 0 : trace[0]) === null || _b === void 0 ? void 0 : _b.getFunctionName(),
|
|
101
|
-
"fileLine": (_c = trace === null || trace === void 0 ? void 0 : trace[0]) === null || _c === void 0 ? void 0 : _c.getLineNumber(),
|
|
102
|
-
"fileColumn": (_d = trace === null || trace === void 0 ? void 0 : trace[0]) === null || _d === void 0 ? void 0 : _d.getColumnNumber(),
|
|
103
|
-
"tracker": exception.stack,
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* If Message is a Exception, get All Exception Preview and parse to ExceptionObjectLoggerInterface
|
|
108
|
-
*
|
|
109
|
-
* @param {unknown} exception Possible Exception
|
|
110
|
-
* @returns {Promise<ExceptionObjectLoggerInterface | undefined>}
|
|
111
|
-
*/
|
|
112
|
-
async parseExceptionPreview(exception) {
|
|
113
|
-
if (!(exception instanceof exception_1.Exception))
|
|
114
|
-
return;
|
|
115
|
-
const exceptionCollection = [];
|
|
116
|
-
let exceptionBase = exception.preview;
|
|
117
|
-
let exceptionCount = 0;
|
|
118
|
-
do {
|
|
119
|
-
const parsedException = await this.parseException(exceptionBase);
|
|
120
|
-
if (parsedException)
|
|
121
|
-
exceptionCollection.push(parsedException);
|
|
122
|
-
exceptionBase = exceptionBase === null || exceptionBase === void 0 ? void 0 : exceptionBase.preview;
|
|
123
|
-
} while (exceptionBase && ++exceptionCount < this.maxExceptionPreview);
|
|
124
|
-
return exceptionCollection;
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Parser Request and Response
|
|
128
|
-
*
|
|
129
|
-
* @protected
|
|
130
|
-
* @param {unknown} message Possible Message/Request
|
|
131
|
-
* @returns {Promise<LoggerObjectRequestInterface | undefined>}
|
|
132
|
-
* @memberof JSONLoggerPlugin
|
|
133
|
-
*/
|
|
134
|
-
async parseRequest(message) {
|
|
135
|
-
if (!await this.isRequestOrResponseMessage(message))
|
|
136
|
-
return;
|
|
137
|
-
const request = await this.getRequestMessage(message);
|
|
138
|
-
const response = await this.getResponseMessage(message);
|
|
139
|
-
return {
|
|
140
|
-
...request,
|
|
141
|
-
response: response && {
|
|
142
|
-
...Object.fromEntries(Object.entries(response).filter(([key]) => key !== "request")),
|
|
143
|
-
},
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Get Response
|
|
148
|
-
*
|
|
149
|
-
* @protected
|
|
150
|
-
* @param {unknown} message Possible Request/Message
|
|
151
|
-
* @returns {Promise<ResponseInterface<unknown, unknown> | undefined>}
|
|
152
|
-
* @memberof JSONLoggerPlugin
|
|
153
|
-
*/
|
|
154
|
-
async getResponseMessage(message) {
|
|
155
|
-
if (message instanceof message_1.MessageException)
|
|
156
|
-
return message.response;
|
|
157
|
-
if (this.isResponseMessage(message))
|
|
158
|
-
return message;
|
|
159
|
-
return undefined;
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* Get Request
|
|
163
|
-
*
|
|
164
|
-
* @protected
|
|
165
|
-
* @param {unknown} message Possible Request/Message
|
|
166
|
-
* @returns {Promise<ResponseInterface<unknown, unknown> | undefined>}
|
|
167
|
-
* @memberof JSONLoggerPlugin
|
|
168
|
-
*/
|
|
169
|
-
async getRequestMessage(message) {
|
|
170
|
-
if (message instanceof message_1.MessageException)
|
|
171
|
-
return message.request;
|
|
172
|
-
if (this.isRequestMessage(message))
|
|
173
|
-
return message;
|
|
174
|
-
if (this.isResponseMessage(message))
|
|
175
|
-
return message.request;
|
|
176
|
-
return undefined;
|
|
177
|
-
}
|
|
178
|
-
/**
|
|
179
|
-
* Check Is Message Response or Request or Exception Message
|
|
180
|
-
*
|
|
181
|
-
* @protected
|
|
182
|
-
* @param {unknown} message Possible Message/Request
|
|
183
|
-
* @returns {Promise<boolean>}
|
|
184
|
-
* @memberof JSONLoggerPlugin
|
|
185
|
-
*/
|
|
186
|
-
async isRequestOrResponseMessage(message) {
|
|
187
|
-
return message instanceof message_1.MessageException
|
|
188
|
-
|| this.isResponseMessage(message)
|
|
189
|
-
|| this.isRequestMessage(message);
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
* Check is Response Message
|
|
193
|
-
*
|
|
194
|
-
* @param {unknown} message Possible Response/Message
|
|
195
|
-
* @returns {boolean}
|
|
196
|
-
*/
|
|
197
|
-
isResponseMessage(message) {
|
|
198
|
-
return Object.prototype.hasOwnProperty.call(message, "data")
|
|
199
|
-
&& Object.prototype.hasOwnProperty.call(message, "status")
|
|
200
|
-
&& Object.prototype.hasOwnProperty.call(message, "headers")
|
|
201
|
-
&& Object.prototype.hasOwnProperty.call(message, "request");
|
|
202
|
-
}
|
|
203
|
-
/**
|
|
204
|
-
* Check is Request Message
|
|
205
|
-
*
|
|
206
|
-
* @param {unknown} message Possible Request/Message
|
|
207
|
-
* @returns {boolean}
|
|
208
|
-
*/
|
|
209
|
-
isRequestMessage(message) {
|
|
210
|
-
return Object.prototype.hasOwnProperty.call(message, "url")
|
|
211
|
-
&& Object.prototype.hasOwnProperty.call(message, "method");
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
exports.JSONLoggerPlugin = JSONLoggerPlugin;
|
|
215
|
-
//# sourceMappingURL=JSONLoggerPlugin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"JSONLoggerPlugin.js","sourceRoot":"","sources":["../../src/lib/JSONLoggerPlugin.ts"],"names":[],"mappings":";;;;;;AAAA,2DAA0C;AAC1C,yCAAsC;AAEtC,8CAA2C;AAM3C,0CAA+F;AAC/F,4EAAkD;AAQlD,MAAa,gBAAgB;IASzB,YACuB,OAAe,EACf,UAAmB,EACnB,sBAA8B,EAAE;QAFhC,YAAO,GAAP,OAAO,CAAQ;QACf,eAAU,GAAV,UAAU,CAAS;QACnB,wBAAmB,GAAnB,mBAAmB,CAAa;IACnD,CAAC;IAEL;;;;;OAKG;IACI,KAAK,CAAC,MAAM,CAAC,IAA2B;QAC3C,OAAO;YACH,GAAG,IAAI;YACP,OAAO,EAAE,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAA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AgB,CAAC,OAAO,CAAC;YAAE,OAAO,OAAO,CAAC;QACnD,IAAI,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC;YAAE,OAAO,OAAO,CAAC,OAAO,CAAC;QAE5D,OAAO,SAAS,CAAC;IACrB,CAAC;IAED;;;;;;;OAOG;IACO,KAAK,CAAC,0BAA0B,CAAC,OAAgB;QACvD,OAAO,OAAO,YAAY,0BAAgB;eACnC,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC;eAC/B,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;IAED;;;;;OAKG;IACO,iBAAiB,CAAC,OAAgB;QACxC,OAAO,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC;eACrD,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC;eACvD,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC;eACxD,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IACpE,CAAC;IAED;;;;;OAKG;IACO,gBAAgB,CAAC,OAAgB;QACvC,OAAO,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC;eACpD,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACnE,CAAC;CAEJ;AAjOD,4CAiOC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ExceptionPluginLogger = void 0;
|
|
4
|
-
const exception_1 = require("@odg/exception");
|
|
5
|
-
class ExceptionPluginLogger extends exception_1.Exception {
|
|
6
|
-
}
|
|
7
|
-
exports.ExceptionPluginLogger = ExceptionPluginLogger;
|
|
8
|
-
//# sourceMappingURL=ParserException.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ParserException.js","sourceRoot":"","sources":["../../src/lib/ParserException.ts"],"names":[],"mappings":";;;AAAA,8CAA2C;AAE3C,MAAa,qBAAsB,SAAQ,qBAAS;CAEnD;AAFD,sDAEC"}
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { type LogLevel, type LoggerParserInterface, type LoggerPluginInterface } from "@odg/log";
|
|
2
|
-
import { type ResponseInterface, type RequestInterface } from "@odg/message";
|
|
3
|
-
import { type LoggerObjectRequestInterface, type ExceptionObjectLoggerInterface, type LoggerObjectInterface } from "../Interfaces";
|
|
4
|
-
export declare class JSONLoggerPlugin implements LoggerPluginInterface {
|
|
5
|
-
protected readonly appName: string;
|
|
6
|
-
protected readonly instanceId?: string | undefined;
|
|
7
|
-
protected readonly maxExceptionPreview: number;
|
|
8
|
-
/**
|
|
9
|
-
* Identifier for the current log
|
|
10
|
-
*
|
|
11
|
-
* @type {string}
|
|
12
|
-
*/
|
|
13
|
-
protected identifier?: string;
|
|
14
|
-
constructor(appName: string, instanceId?: string | undefined, maxExceptionPreview?: number);
|
|
15
|
-
/**
|
|
16
|
-
* Plugin parser Function return new message with JSON format
|
|
17
|
-
*
|
|
18
|
-
* @param {LoggerParserInterface} data Received Data params
|
|
19
|
-
* @returns {Promise<LoggerParserInterface>}
|
|
20
|
-
*/
|
|
21
|
-
parser(data: LoggerParserInterface): Promise<LoggerParserInterface>;
|
|
22
|
-
logJSON(level: LogLevel, message: unknown): Promise<LoggerObjectInterface>;
|
|
23
|
-
/**
|
|
24
|
-
* Define a unique identifier for the current request, for
|
|
25
|
-
* Example: Request ID, Transaction ID, Crawler Process, etc
|
|
26
|
-
*
|
|
27
|
-
* @param {string} identifier Unique identifier
|
|
28
|
-
* @memberof JSONLoggerPlugin
|
|
29
|
-
*/
|
|
30
|
-
setIdentifier(identifier: string): void;
|
|
31
|
-
/**
|
|
32
|
-
* Return instance HostName, identifier
|
|
33
|
-
*
|
|
34
|
-
* @returns {string}
|
|
35
|
-
*/
|
|
36
|
-
protected getInstance(): string;
|
|
37
|
-
/**
|
|
38
|
-
* Return git tag name
|
|
39
|
-
*
|
|
40
|
-
* @returns {Promise<string>}
|
|
41
|
-
*/
|
|
42
|
-
protected getGitRelease(): Promise<string>;
|
|
43
|
-
/**
|
|
44
|
-
* Return git tag name
|
|
45
|
-
*
|
|
46
|
-
* @returns {Promise<string>}
|
|
47
|
-
*/
|
|
48
|
-
protected getGitBranch(): Promise<string>;
|
|
49
|
-
/**
|
|
50
|
-
* If Message is a Exception, parse to ExceptionObjectLoggerInterface
|
|
51
|
-
*
|
|
52
|
-
* @param {unknown} exception Possible Exception
|
|
53
|
-
* @returns {Promise<ExceptionObjectLoggerInterface | undefined>}
|
|
54
|
-
*/
|
|
55
|
-
protected parseException(exception: unknown): Promise<ExceptionObjectLoggerInterface | undefined>;
|
|
56
|
-
/**
|
|
57
|
-
* If Message is a Exception, get All Exception Preview and parse to ExceptionObjectLoggerInterface
|
|
58
|
-
*
|
|
59
|
-
* @param {unknown} exception Possible Exception
|
|
60
|
-
* @returns {Promise<ExceptionObjectLoggerInterface | undefined>}
|
|
61
|
-
*/
|
|
62
|
-
protected parseExceptionPreview(exception: unknown): Promise<ExceptionObjectLoggerInterface[] | undefined>;
|
|
63
|
-
/**
|
|
64
|
-
* Parser Request and Response
|
|
65
|
-
*
|
|
66
|
-
* @protected
|
|
67
|
-
* @param {unknown} message Possible Message/Request
|
|
68
|
-
* @returns {Promise<LoggerObjectRequestInterface | undefined>}
|
|
69
|
-
* @memberof JSONLoggerPlugin
|
|
70
|
-
*/
|
|
71
|
-
protected parseRequest(message: unknown): Promise<LoggerObjectRequestInterface | undefined>;
|
|
72
|
-
/**
|
|
73
|
-
* Get Response
|
|
74
|
-
*
|
|
75
|
-
* @protected
|
|
76
|
-
* @param {unknown} message Possible Request/Message
|
|
77
|
-
* @returns {Promise<ResponseInterface<unknown, unknown> | undefined>}
|
|
78
|
-
* @memberof JSONLoggerPlugin
|
|
79
|
-
*/
|
|
80
|
-
protected getResponseMessage(message: unknown): Promise<ResponseInterface<unknown, unknown> | undefined>;
|
|
81
|
-
/**
|
|
82
|
-
* Get Request
|
|
83
|
-
*
|
|
84
|
-
* @protected
|
|
85
|
-
* @param {unknown} message Possible Request/Message
|
|
86
|
-
* @returns {Promise<ResponseInterface<unknown, unknown> | undefined>}
|
|
87
|
-
* @memberof JSONLoggerPlugin
|
|
88
|
-
*/
|
|
89
|
-
protected getRequestMessage(message: unknown): Promise<RequestInterface<unknown> | undefined>;
|
|
90
|
-
/**
|
|
91
|
-
* Check Is Message Response or Request or Exception Message
|
|
92
|
-
*
|
|
93
|
-
* @protected
|
|
94
|
-
* @param {unknown} message Possible Message/Request
|
|
95
|
-
* @returns {Promise<boolean>}
|
|
96
|
-
* @memberof JSONLoggerPlugin
|
|
97
|
-
*/
|
|
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
|
-
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
|
-
protected isRequestMessage(message: unknown): message is RequestInterface<unknown>;
|
|
113
|
-
}
|
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.JSONLoggerPlugin = void 0;
|
|
7
|
-
const node_child_process_1 = require("node:child_process");
|
|
8
|
-
const node_util_1 = require("node:util");
|
|
9
|
-
const exception_1 = require("@odg/exception");
|
|
10
|
-
const message_1 = require("@odg/message");
|
|
11
|
-
const error_stack_parser_1 = __importDefault(require("error-stack-parser"));
|
|
12
|
-
class JSONLoggerPlugin {
|
|
13
|
-
constructor(appName, instanceId, maxExceptionPreview = 10) {
|
|
14
|
-
this.appName = appName;
|
|
15
|
-
this.instanceId = instanceId;
|
|
16
|
-
this.maxExceptionPreview = maxExceptionPreview;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Plugin parser Function return new message with JSON format
|
|
20
|
-
*
|
|
21
|
-
* @param {LoggerParserInterface} data Received Data params
|
|
22
|
-
* @returns {Promise<LoggerParserInterface>}
|
|
23
|
-
*/
|
|
24
|
-
async parser(data) {
|
|
25
|
-
return {
|
|
26
|
-
...data,
|
|
27
|
-
message: await this.logJSON(data.level, data.message),
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
async logJSON(level, message) {
|
|
31
|
-
return {
|
|
32
|
-
"type": level,
|
|
33
|
-
"index": this.appName,
|
|
34
|
-
"instance": this.getInstance(),
|
|
35
|
-
"identifier": this.identifier,
|
|
36
|
-
"gitRelease": await this.getGitRelease().catch(() => void 0),
|
|
37
|
-
"gitBranch": await this.getGitBranch().catch(() => void 0),
|
|
38
|
-
"exception": await this.parseException(message),
|
|
39
|
-
"exceptionPreview": await this.parseExceptionPreview(message),
|
|
40
|
-
"request": await this.parseRequest(message),
|
|
41
|
-
"createdAt": new Date(),
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Define a unique identifier for the current request, for
|
|
46
|
-
* Example: Request ID, Transaction ID, Crawler Process, etc
|
|
47
|
-
*
|
|
48
|
-
* @param {string} identifier Unique identifier
|
|
49
|
-
* @memberof JSONLoggerPlugin
|
|
50
|
-
*/
|
|
51
|
-
setIdentifier(identifier) {
|
|
52
|
-
this.identifier = identifier;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Return instance HostName, identifier
|
|
56
|
-
*
|
|
57
|
-
* @returns {string}
|
|
58
|
-
*/
|
|
59
|
-
getInstance() {
|
|
60
|
-
return this.instanceId
|
|
61
|
-
|| process.env.HOSTNAME
|
|
62
|
-
|| process.env.CONTAINER_ID
|
|
63
|
-
|| "unknown";
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Return git tag name
|
|
67
|
-
*
|
|
68
|
-
* @returns {Promise<string>}
|
|
69
|
-
*/
|
|
70
|
-
async getGitRelease() {
|
|
71
|
-
const command = (0, node_util_1.promisify)(node_child_process_1.exec);
|
|
72
|
-
const gitVersion = await command("git describe --tags --abbrev=41");
|
|
73
|
-
return gitVersion.stdout.trim();
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Return git tag name
|
|
77
|
-
*
|
|
78
|
-
* @returns {Promise<string>}
|
|
79
|
-
*/
|
|
80
|
-
async getGitBranch() {
|
|
81
|
-
const command = (0, node_util_1.promisify)(node_child_process_1.exec);
|
|
82
|
-
const gitVersion = await command("git rev-parse --abbrev-ref HEAD");
|
|
83
|
-
return gitVersion.stdout.trim();
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* If Message is a Exception, parse to ExceptionObjectLoggerInterface
|
|
87
|
-
*
|
|
88
|
-
* @param {unknown} exception Possible Exception
|
|
89
|
-
* @returns {Promise<ExceptionObjectLoggerInterface | undefined>}
|
|
90
|
-
*/
|
|
91
|
-
async parseException(exception) {
|
|
92
|
-
var _a, _b, _c, _d;
|
|
93
|
-
if (!(exception instanceof Error))
|
|
94
|
-
return;
|
|
95
|
-
const trace = exception.stack ? error_stack_parser_1.default.parse(exception) : undefined;
|
|
96
|
-
return {
|
|
97
|
-
"type": exception.name,
|
|
98
|
-
"message": exception.message,
|
|
99
|
-
"fileException": (_a = trace === null || trace === void 0 ? void 0 : trace[0]) === null || _a === void 0 ? void 0 : _a.getFileName(),
|
|
100
|
-
"functionName": (_b = trace === null || trace === void 0 ? void 0 : trace[0]) === null || _b === void 0 ? void 0 : _b.getFunctionName(),
|
|
101
|
-
"fileLine": (_c = trace === null || trace === void 0 ? void 0 : trace[0]) === null || _c === void 0 ? void 0 : _c.getLineNumber(),
|
|
102
|
-
"fileColumn": (_d = trace === null || trace === void 0 ? void 0 : trace[0]) === null || _d === void 0 ? void 0 : _d.getColumnNumber(),
|
|
103
|
-
"tracker": exception.stack,
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* If Message is a Exception, get All Exception Preview and parse to ExceptionObjectLoggerInterface
|
|
108
|
-
*
|
|
109
|
-
* @param {unknown} exception Possible Exception
|
|
110
|
-
* @returns {Promise<ExceptionObjectLoggerInterface | undefined>}
|
|
111
|
-
*/
|
|
112
|
-
async parseExceptionPreview(exception) {
|
|
113
|
-
if (!(exception instanceof exception_1.Exception))
|
|
114
|
-
return;
|
|
115
|
-
const exceptionCollection = [];
|
|
116
|
-
let exceptionBase = exception.preview;
|
|
117
|
-
let exceptionCount = 0;
|
|
118
|
-
do {
|
|
119
|
-
const parsedException = await this.parseException(exceptionBase);
|
|
120
|
-
if (parsedException)
|
|
121
|
-
exceptionCollection.push(parsedException);
|
|
122
|
-
exceptionBase = exceptionBase === null || exceptionBase === void 0 ? void 0 : exceptionBase.preview;
|
|
123
|
-
} while (exceptionBase && ++exceptionCount < this.maxExceptionPreview);
|
|
124
|
-
return exceptionCollection;
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Parser Request and Response
|
|
128
|
-
*
|
|
129
|
-
* @protected
|
|
130
|
-
* @param {unknown} message Possible Message/Request
|
|
131
|
-
* @returns {Promise<LoggerObjectRequestInterface | undefined>}
|
|
132
|
-
* @memberof JSONLoggerPlugin
|
|
133
|
-
*/
|
|
134
|
-
async parseRequest(message) {
|
|
135
|
-
if (!await this.isRequestOrResponseMessage(message))
|
|
136
|
-
return;
|
|
137
|
-
const request = await this.getRequestMessage(message);
|
|
138
|
-
const response = await this.getResponseMessage(message);
|
|
139
|
-
return {
|
|
140
|
-
...request,
|
|
141
|
-
response: response && {
|
|
142
|
-
...Object.fromEntries(Object.entries(response).filter(([key]) => key !== "request")),
|
|
143
|
-
},
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Get Response
|
|
148
|
-
*
|
|
149
|
-
* @protected
|
|
150
|
-
* @param {unknown} message Possible Request/Message
|
|
151
|
-
* @returns {Promise<ResponseInterface<unknown, unknown> | undefined>}
|
|
152
|
-
* @memberof JSONLoggerPlugin
|
|
153
|
-
*/
|
|
154
|
-
async getResponseMessage(message) {
|
|
155
|
-
if (message instanceof message_1.MessageException)
|
|
156
|
-
return message.response;
|
|
157
|
-
if (this.isResponseMessage(message))
|
|
158
|
-
return message;
|
|
159
|
-
return undefined;
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* Get Request
|
|
163
|
-
*
|
|
164
|
-
* @protected
|
|
165
|
-
* @param {unknown} message Possible Request/Message
|
|
166
|
-
* @returns {Promise<ResponseInterface<unknown, unknown> | undefined>}
|
|
167
|
-
* @memberof JSONLoggerPlugin
|
|
168
|
-
*/
|
|
169
|
-
async getRequestMessage(message) {
|
|
170
|
-
if (message instanceof message_1.MessageException)
|
|
171
|
-
return message.request;
|
|
172
|
-
if (this.isRequestMessage(message))
|
|
173
|
-
return message;
|
|
174
|
-
if (this.isResponseMessage(message))
|
|
175
|
-
return message.request;
|
|
176
|
-
return undefined;
|
|
177
|
-
}
|
|
178
|
-
/**
|
|
179
|
-
* Check Is Message Response or Request or Exception Message
|
|
180
|
-
*
|
|
181
|
-
* @protected
|
|
182
|
-
* @param {unknown} message Possible Message/Request
|
|
183
|
-
* @returns {Promise<boolean>}
|
|
184
|
-
* @memberof JSONLoggerPlugin
|
|
185
|
-
*/
|
|
186
|
-
async isRequestOrResponseMessage(message) {
|
|
187
|
-
return message instanceof message_1.MessageException
|
|
188
|
-
|| this.isResponseMessage(message)
|
|
189
|
-
|| this.isRequestMessage(message);
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
* Check is Response Message
|
|
193
|
-
*
|
|
194
|
-
* @param {unknown} message Possible Response/Message
|
|
195
|
-
* @returns {boolean}
|
|
196
|
-
*/
|
|
197
|
-
isResponseMessage(message) {
|
|
198
|
-
return Object.prototype.hasOwnProperty.call(message, "data")
|
|
199
|
-
&& Object.prototype.hasOwnProperty.call(message, "status")
|
|
200
|
-
&& Object.prototype.hasOwnProperty.call(message, "headers")
|
|
201
|
-
&& Object.prototype.hasOwnProperty.call(message, "request");
|
|
202
|
-
}
|
|
203
|
-
/**
|
|
204
|
-
* Check is Request Message
|
|
205
|
-
*
|
|
206
|
-
* @param {unknown} message Possible Request/Message
|
|
207
|
-
* @returns {boolean}
|
|
208
|
-
*/
|
|
209
|
-
isRequestMessage(message) {
|
|
210
|
-
return Object.prototype.hasOwnProperty.call(message, "url")
|
|
211
|
-
&& Object.prototype.hasOwnProperty.call(message, "method");
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
exports.JSONLoggerPlugin = JSONLoggerPlugin;
|
|
215
|
-
//# sourceMappingURL=JSONLoggerPlugin.js.map
|