@eqxjs/nest-logger 3.1.0-beta.12 → 3.1.0-beta.14
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 +646 -78
- package/dist/constants/action-message.constant.d.ts +171 -0
- package/dist/constants/action-message.constant.js +171 -0
- package/dist/constants/action-message.constant.js.map +1 -1
- package/dist/core/formatters/logger.formatter.d.ts +107 -0
- package/dist/core/formatters/logger.formatter.js +107 -0
- package/dist/core/formatters/logger.formatter.js.map +1 -1
- package/dist/core/loggers/app.logger.d.ts +33 -0
- package/dist/core/loggers/app.logger.js +51 -0
- package/dist/core/loggers/app.logger.js.map +1 -1
- package/dist/core/loggers/base-app.logger.js +2 -3
- package/dist/core/loggers/base-app.logger.js.map +1 -1
- package/dist/core/loggers/custom.logger.d.ts +111 -0
- package/dist/core/loggers/custom.logger.js +119 -0
- package/dist/core/loggers/custom.logger.js.map +1 -1
- package/dist/helpers/datetime.helper.d.ts +23 -0
- package/dist/helpers/datetime.helper.js +23 -0
- package/dist/helpers/datetime.helper.js.map +1 -1
- package/dist/helpers/log.helper.d.ts +81 -0
- package/dist/helpers/log.helper.js +81 -0
- package/dist/helpers/log.helper.js.map +1 -1
- package/dist/helpers/logger-builder.helper.d.ts +207 -2
- package/dist/helpers/logger-builder.helper.js +207 -2
- package/dist/helpers/logger-builder.helper.js.map +1 -1
- package/dist/helpers/message-formatter.helper.d.ts +74 -7
- package/dist/helpers/message-formatter.helper.js +74 -7
- package/dist/helpers/message-formatter.helper.js.map +1 -1
- package/dist/helpers/time-performance.helper.d.ts +61 -0
- package/dist/helpers/time-performance.helper.js +62 -1
- package/dist/helpers/time-performance.helper.js.map +1 -1
- package/dist/models/logger.dto.d.ts +43 -0
- package/dist/models/logger.dto.js +43 -0
- package/dist/models/logger.dto.js.map +1 -1
- package/package.json +1 -1
|
@@ -2,17 +2,78 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TimeDiff = void 0;
|
|
4
4
|
const perf_hooks_1 = require("perf_hooks");
|
|
5
|
+
/**
|
|
6
|
+
* TimeDiff - High-resolution timer for measuring elapsed time.
|
|
7
|
+
*
|
|
8
|
+
* Uses Node.js performance API to provide precise time measurements in milliseconds.
|
|
9
|
+
* Useful for tracking operation duration, performance monitoring, and logging service times.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const timer = new TimeDiff();
|
|
14
|
+
* await someOperation();
|
|
15
|
+
* const duration = timer.diff();
|
|
16
|
+
* console.log(`Operation took ${duration}ms`);
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* // Using static start method
|
|
22
|
+
* const timer = TimeDiff.start();
|
|
23
|
+
* processData();
|
|
24
|
+
* console.log(`Elapsed: ${timer.end()}ms`);
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
5
27
|
class TimeDiff {
|
|
6
28
|
startTime;
|
|
29
|
+
/**
|
|
30
|
+
* Creates a new TimeDiff instance and starts the timer.
|
|
31
|
+
* The start time is captured immediately using high-resolution performance timer.
|
|
32
|
+
*/
|
|
7
33
|
constructor() {
|
|
8
34
|
this.startTime = perf_hooks_1.performance.now();
|
|
9
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Static factory method to create and start a new timer instance.
|
|
38
|
+
*
|
|
39
|
+
* @returns A new TimeDiff instance with the timer started
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* const timer = TimeDiff.start();
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
10
46
|
static start() {
|
|
11
47
|
return new TimeDiff();
|
|
12
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Calculates and returns the elapsed time since the timer was started.
|
|
51
|
+
* Returns the duration in milliseconds with 3 decimal places precision.
|
|
52
|
+
*
|
|
53
|
+
* @returns Elapsed time in milliseconds (e.g., 123.456)
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* const timer = new TimeDiff();
|
|
58
|
+
* await operation();
|
|
59
|
+
* const ms = timer.diff(); // e.g., 150.234
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
13
62
|
diff() {
|
|
14
|
-
return
|
|
63
|
+
return parseFloat((perf_hooks_1.performance.now() - this.startTime).toFixed(3));
|
|
15
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* Alias for diff() method. Returns the elapsed time since the timer was started.
|
|
67
|
+
*
|
|
68
|
+
* @returns Elapsed time in milliseconds
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```typescript
|
|
72
|
+
* const timer = TimeDiff.start();
|
|
73
|
+
* processData();
|
|
74
|
+
* const duration = timer.end();
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
16
77
|
end() {
|
|
17
78
|
return this.diff();
|
|
18
79
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time-performance.helper.js","sourceRoot":"","sources":["../../src/helpers/time-performance.helper.ts"],"names":[],"mappings":";;;AAAA,2CAAyC;AAEzC,MAAa,QAAQ;IACX,SAAS,CAAS;IAE1B;QACE,IAAI,CAAC,SAAS,GAAG,wBAAW,CAAC,GAAG,EAAE,CAAC;IACrC,CAAC;
|
|
1
|
+
{"version":3,"file":"time-performance.helper.js","sourceRoot":"","sources":["../../src/helpers/time-performance.helper.ts"],"names":[],"mappings":";;;AAAA,2CAAyC;AAEzC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAa,QAAQ;IACX,SAAS,CAAS;IAE1B;;;OAGG;IACH;QACE,IAAI,CAAC,SAAS,GAAG,wBAAW,CAAC,GAAG,EAAE,CAAC;IACrC,CAAC;IAED;;;;;;;;;OASG;IACI,MAAM,CAAC,KAAK;QACjB,OAAO,IAAI,QAAQ,EAAE,CAAC;IACxB,CAAC;IAED;;;;;;;;;;;;OAYG;IACI,IAAI;QACT,OAAO,UAAU,CAAC,CAAC,wBAAW,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IACrE,CAAC;IAED;;;;;;;;;;;OAWG;IACI,GAAG;QACR,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;IACrB,CAAC;CACF;AAzDD,4BAyDC"}
|
|
@@ -1,28 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LoggerDto - Data Transfer Object for structured log entries.
|
|
3
|
+
*
|
|
4
|
+
* Represents a complete log record with all metadata fields used throughout the logging system.
|
|
5
|
+
* This DTO is used to standardize log format across different logger types and ensure
|
|
6
|
+
* consistent structure for log aggregation, analysis, and monitoring.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const dto = new LoggerDto();
|
|
11
|
+
* dto.level = 'info';
|
|
12
|
+
* dto.timestamp = '2026-01-12T10:00:00.000Z';
|
|
13
|
+
* dto.message = 'User logged in';
|
|
14
|
+
* dto.appName = 'MyApp';
|
|
15
|
+
* dto.sessionId = 'sess-123';
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
1
18
|
export declare class LoggerDto {
|
|
19
|
+
/** Log level (e.g., 'debug', 'info', 'warn', 'error', 'verbose') */
|
|
2
20
|
level: string;
|
|
21
|
+
/** ISO 8601 formatted timestamp of the log entry */
|
|
3
22
|
timestamp: string;
|
|
23
|
+
/** Name of the application generating the log */
|
|
4
24
|
appName: string;
|
|
25
|
+
/** Name of the component or service within the application */
|
|
5
26
|
componentName: string;
|
|
27
|
+
/** Version of the component */
|
|
6
28
|
componentVersion: string;
|
|
29
|
+
/** Device identifier(s) - can be a single string or array of strings */
|
|
7
30
|
device: string | string[];
|
|
31
|
+
/** Action tag categorizing the log entry (e.g., '[HTTP_REQUEST]', '[DB_QUERY]') */
|
|
8
32
|
action: string;
|
|
33
|
+
/** The main log message content */
|
|
9
34
|
message: string;
|
|
35
|
+
/** Global unique identifier for the log entry */
|
|
10
36
|
guid: string;
|
|
37
|
+
/** Instance identifier (hostname, container ID, or pod name) */
|
|
11
38
|
instance: string;
|
|
39
|
+
/** Name of the service that originated the log */
|
|
12
40
|
originateServiceName: string;
|
|
41
|
+
/** Record identifier (e.g., order ID, user ID, transaction reference) */
|
|
13
42
|
recordName: string;
|
|
43
|
+
/** Type of record ('detail' for regular logs, 'summary' for aggregated logs) */
|
|
14
44
|
recordType: string;
|
|
45
|
+
/** Session identifier for tracking user sessions */
|
|
15
46
|
sessionId: string;
|
|
47
|
+
/** Transaction identifier for distributed tracing */
|
|
16
48
|
transactionId: string;
|
|
49
|
+
/** Public identifier(s) - can be a single string or array */
|
|
17
50
|
public: string | string[];
|
|
51
|
+
/** Message broker identifier (e.g., 'kafka', 'rabbitmq', 'redis') */
|
|
18
52
|
broker: string;
|
|
53
|
+
/** Communication channel (e.g., 'web', 'mobile', 'api', 'queue') */
|
|
19
54
|
channel: string;
|
|
55
|
+
/** Use case name being executed */
|
|
20
56
|
useCase: string;
|
|
57
|
+
/** Specific step within the use case */
|
|
21
58
|
useCaseStep: string;
|
|
59
|
+
/** User identifier (email, username, or user ID) */
|
|
22
60
|
user: string;
|
|
61
|
+
/** Application result description (e.g., 'Success', 'Failed', 'Completed') */
|
|
23
62
|
appResult: string;
|
|
63
|
+
/** Application result code (e.g., '200', '500', 'ERR_001') */
|
|
24
64
|
appResultCode: string;
|
|
65
|
+
/** Service processing time in milliseconds */
|
|
25
66
|
serviceTime: number;
|
|
67
|
+
/** Error stack trace as array of strings (populated for error logs) */
|
|
26
68
|
stack: string[];
|
|
69
|
+
/** DateTime string (alternative timestamp format, optional) */
|
|
27
70
|
dateTime?: string;
|
|
28
71
|
}
|
|
@@ -1,32 +1,75 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LoggerDto = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* LoggerDto - Data Transfer Object for structured log entries.
|
|
6
|
+
*
|
|
7
|
+
* Represents a complete log record with all metadata fields used throughout the logging system.
|
|
8
|
+
* This DTO is used to standardize log format across different logger types and ensure
|
|
9
|
+
* consistent structure for log aggregation, analysis, and monitoring.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const dto = new LoggerDto();
|
|
14
|
+
* dto.level = 'info';
|
|
15
|
+
* dto.timestamp = '2026-01-12T10:00:00.000Z';
|
|
16
|
+
* dto.message = 'User logged in';
|
|
17
|
+
* dto.appName = 'MyApp';
|
|
18
|
+
* dto.sessionId = 'sess-123';
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
4
21
|
class LoggerDto {
|
|
22
|
+
/** Log level (e.g., 'debug', 'info', 'warn', 'error', 'verbose') */
|
|
5
23
|
level;
|
|
24
|
+
/** ISO 8601 formatted timestamp of the log entry */
|
|
6
25
|
timestamp;
|
|
26
|
+
/** Name of the application generating the log */
|
|
7
27
|
appName;
|
|
28
|
+
/** Name of the component or service within the application */
|
|
8
29
|
componentName;
|
|
30
|
+
/** Version of the component */
|
|
9
31
|
componentVersion;
|
|
32
|
+
/** Device identifier(s) - can be a single string or array of strings */
|
|
10
33
|
device;
|
|
34
|
+
/** Action tag categorizing the log entry (e.g., '[HTTP_REQUEST]', '[DB_QUERY]') */
|
|
11
35
|
action;
|
|
36
|
+
/** The main log message content */
|
|
12
37
|
message;
|
|
38
|
+
/** Global unique identifier for the log entry */
|
|
13
39
|
guid;
|
|
40
|
+
/** Instance identifier (hostname, container ID, or pod name) */
|
|
14
41
|
instance;
|
|
42
|
+
/** Name of the service that originated the log */
|
|
15
43
|
originateServiceName;
|
|
44
|
+
/** Record identifier (e.g., order ID, user ID, transaction reference) */
|
|
16
45
|
recordName;
|
|
46
|
+
/** Type of record ('detail' for regular logs, 'summary' for aggregated logs) */
|
|
17
47
|
recordType;
|
|
48
|
+
/** Session identifier for tracking user sessions */
|
|
18
49
|
sessionId;
|
|
50
|
+
/** Transaction identifier for distributed tracing */
|
|
19
51
|
transactionId;
|
|
52
|
+
/** Public identifier(s) - can be a single string or array */
|
|
20
53
|
public;
|
|
54
|
+
/** Message broker identifier (e.g., 'kafka', 'rabbitmq', 'redis') */
|
|
21
55
|
broker;
|
|
56
|
+
/** Communication channel (e.g., 'web', 'mobile', 'api', 'queue') */
|
|
22
57
|
channel;
|
|
58
|
+
/** Use case name being executed */
|
|
23
59
|
useCase;
|
|
60
|
+
/** Specific step within the use case */
|
|
24
61
|
useCaseStep;
|
|
62
|
+
/** User identifier (email, username, or user ID) */
|
|
25
63
|
user;
|
|
64
|
+
/** Application result description (e.g., 'Success', 'Failed', 'Completed') */
|
|
26
65
|
appResult;
|
|
66
|
+
/** Application result code (e.g., '200', '500', 'ERR_001') */
|
|
27
67
|
appResultCode;
|
|
68
|
+
/** Service processing time in milliseconds */
|
|
28
69
|
serviceTime;
|
|
70
|
+
/** Error stack trace as array of strings (populated for error logs) */
|
|
29
71
|
stack;
|
|
72
|
+
/** DateTime string (alternative timestamp format, optional) */
|
|
30
73
|
dateTime;
|
|
31
74
|
}
|
|
32
75
|
exports.LoggerDto = LoggerDto;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.dto.js","sourceRoot":"","sources":["../../src/models/logger.dto.ts"],"names":[],"mappings":";;;AAAA,MAAa,SAAS;IACpB,KAAK,CAAU;
|
|
1
|
+
{"version":3,"file":"logger.dto.js","sourceRoot":"","sources":["../../src/models/logger.dto.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAa,SAAS;IACpB,oEAAoE;IACpE,KAAK,CAAU;IAEf,oDAAoD;IACpD,SAAS,CAAU;IAEnB,iDAAiD;IACjD,OAAO,CAAU;IAEjB,8DAA8D;IAC9D,aAAa,CAAU;IAEvB,+BAA+B;IAC/B,gBAAgB,CAAU;IAE1B,wEAAwE;IACxE,MAAM,CAAqB;IAE3B,mFAAmF;IACnF,MAAM,CAAU;IAEhB,mCAAmC;IACnC,OAAO,CAAU;IAEjB,iDAAiD;IACjD,IAAI,CAAU;IAEd,gEAAgE;IAChE,QAAQ,CAAU;IAElB,kDAAkD;IAClD,oBAAoB,CAAU;IAE9B,yEAAyE;IACzE,UAAU,CAAU;IAEpB,gFAAgF;IAChF,UAAU,CAAU;IAEpB,oDAAoD;IACpD,SAAS,CAAU;IAEnB,qDAAqD;IACrD,aAAa,CAAU;IAEvB,6DAA6D;IAC7D,MAAM,CAAqB;IAE3B,qEAAqE;IACrE,MAAM,CAAU;IAEhB,oEAAoE;IACpE,OAAO,CAAU;IAEjB,mCAAmC;IACnC,OAAO,CAAU;IAEjB,wCAAwC;IACxC,WAAW,CAAU;IAErB,oDAAoD;IACpD,IAAI,CAAU;IAEd,8EAA8E;IAC9E,SAAS,CAAU;IAEnB,8DAA8D;IAC9D,aAAa,CAAU;IAEvB,8CAA8C;IAC9C,WAAW,CAAU;IAErB,uEAAuE;IACvE,KAAK,CAAY;IAEjB,+DAA+D;IAC/D,QAAQ,CAAU;CACnB;AA9ED,8BA8EC"}
|