@eqxjs/nest-logger 3.1.0-beta.13 → 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.
Files changed (32) hide show
  1. package/README.md +646 -78
  2. package/dist/constants/action-message.constant.d.ts +171 -0
  3. package/dist/constants/action-message.constant.js +171 -0
  4. package/dist/constants/action-message.constant.js.map +1 -1
  5. package/dist/core/formatters/logger.formatter.d.ts +107 -0
  6. package/dist/core/formatters/logger.formatter.js +107 -0
  7. package/dist/core/formatters/logger.formatter.js.map +1 -1
  8. package/dist/core/loggers/app.logger.d.ts +33 -0
  9. package/dist/core/loggers/app.logger.js +51 -0
  10. package/dist/core/loggers/app.logger.js.map +1 -1
  11. package/dist/core/loggers/custom.logger.d.ts +111 -0
  12. package/dist/core/loggers/custom.logger.js +119 -0
  13. package/dist/core/loggers/custom.logger.js.map +1 -1
  14. package/dist/helpers/datetime.helper.d.ts +23 -0
  15. package/dist/helpers/datetime.helper.js +23 -0
  16. package/dist/helpers/datetime.helper.js.map +1 -1
  17. package/dist/helpers/log.helper.d.ts +81 -0
  18. package/dist/helpers/log.helper.js +81 -0
  19. package/dist/helpers/log.helper.js.map +1 -1
  20. package/dist/helpers/logger-builder.helper.d.ts +207 -2
  21. package/dist/helpers/logger-builder.helper.js +207 -2
  22. package/dist/helpers/logger-builder.helper.js.map +1 -1
  23. package/dist/helpers/message-formatter.helper.d.ts +74 -7
  24. package/dist/helpers/message-formatter.helper.js +74 -7
  25. package/dist/helpers/message-formatter.helper.js.map +1 -1
  26. package/dist/helpers/time-performance.helper.d.ts +61 -0
  27. package/dist/helpers/time-performance.helper.js +62 -1
  28. package/dist/helpers/time-performance.helper.js.map +1 -1
  29. package/dist/models/logger.dto.d.ts +43 -0
  30. package/dist/models/logger.dto.js +43 -0
  31. package/dist/models/logger.dto.js.map +1 -1
  32. package/package.json +1 -1
@@ -1,16 +1,187 @@
1
+ /**
2
+ * ActionMessage - Provides standardized action tags for consistent logging across the application.
3
+ *
4
+ * This class contains static methods that return predefined action tags used for categorizing
5
+ * and filtering log entries. Using these constants ensures consistency in log formatting and
6
+ * makes it easier to search and analyze logs.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * import { ActionMessage } from '@eqxjs/nest-logger';
11
+ *
12
+ * // Use in logging
13
+ * logger.info('Processing message', ActionMessage.consume());
14
+ * logger.info('Request received', ActionMessage.httpRequest());
15
+ * logger.error('Operation failed', ActionMessage.exception());
16
+ * ```
17
+ */
1
18
  export declare class ActionMessage {
19
+ /**
20
+ * Returns the action tag for message consumption in progress.
21
+ * Used when starting to consume a message from a queue or broker.
22
+ *
23
+ * @returns The string '[CONSUMING]'
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * logger.info('Starting to consume', ActionMessage.consume());
28
+ * ```
29
+ */
2
30
  static consume(): string;
31
+ /**
32
+ * Returns the action tag for completed message consumption.
33
+ * Used when a message has been successfully consumed from a queue or broker.
34
+ *
35
+ * @returns The string '[CONSUMED]'
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * logger.info('Message consumed', ActionMessage.consumed());
40
+ * ```
41
+ */
3
42
  static consumed(): string;
43
+ /**
44
+ * Returns the action tag for message production in progress.
45
+ * Used when starting to produce/publish a message to a queue or broker.
46
+ *
47
+ * @returns The string '[PRODUCING]'
48
+ *
49
+ * @example
50
+ * ```typescript
51
+ * logger.info('Publishing message', ActionMessage.produce());
52
+ * ```
53
+ */
4
54
  static produce(): string;
55
+ /**
56
+ * Returns the action tag for completed message production.
57
+ * Used when a message has been successfully produced/published.
58
+ *
59
+ * @returns The string '[PRODUCED]'
60
+ *
61
+ * @example
62
+ * ```typescript
63
+ * logger.info('Message published', ActionMessage.produced());
64
+ * ```
65
+ */
5
66
  static produced(): string;
67
+ /**
68
+ * Returns the action tag for HTTP request operations.
69
+ * Used when receiving or sending HTTP requests.
70
+ *
71
+ * @returns The string '[HTTP_REQUEST]'
72
+ *
73
+ * @example
74
+ * ```typescript
75
+ * logger.info('HTTP request received', ActionMessage.httpRequest());
76
+ * ```
77
+ */
6
78
  static httpRequest(): string;
79
+ /**
80
+ * Returns the action tag for HTTP response operations.
81
+ * Used when sending or receiving HTTP responses.
82
+ *
83
+ * @returns The string '[HTTP_RESPONSE]'
84
+ *
85
+ * @example
86
+ * ```typescript
87
+ * logger.info('Sending response', ActionMessage.httpResponse());
88
+ * ```
89
+ */
7
90
  static httpResponse(): string;
91
+ /**
92
+ * Returns the action tag for WebSocket message reception.
93
+ * Used when receiving messages via WebSocket.
94
+ *
95
+ * @returns The string '[WS_RECEIVED]'
96
+ *
97
+ * @example
98
+ * ```typescript
99
+ * logger.info('WebSocket message received', ActionMessage.wsRecv());
100
+ * ```
101
+ */
8
102
  static wsRecv(): string;
103
+ /**
104
+ * Returns the action tag for WebSocket message sending.
105
+ * Used when sending messages via WebSocket.
106
+ *
107
+ * @returns The string '[WS_SENT]'
108
+ *
109
+ * @example
110
+ * ```typescript
111
+ * logger.info('WebSocket message sent', ActionMessage.wsSent());
112
+ * ```
113
+ */
9
114
  static wsSent(): string;
115
+ /**
116
+ * Returns the action tag for database request operations.
117
+ * Used when initiating database queries or operations.
118
+ *
119
+ * @returns The string '[DB_REQUEST]'
120
+ *
121
+ * @example
122
+ * ```typescript
123
+ * logger.debug('Executing query', ActionMessage.dbRequest());
124
+ * ```
125
+ */
10
126
  static dbRequest(): string;
127
+ /**
128
+ * Returns the action tag for database response operations.
129
+ * Used when receiving results from database queries or operations.
130
+ *
131
+ * @returns The string '[DB_RESPONSE]'
132
+ *
133
+ * @example
134
+ * ```typescript
135
+ * logger.debug('Query completed', ActionMessage.dbResponse());
136
+ * ```
137
+ */
11
138
  static dbResponse(): string;
139
+ /**
140
+ * Returns the action tag for application logic operations.
141
+ * Used for business logic processing and internal operations.
142
+ *
143
+ * @returns The string '[APP_LOGIC]'
144
+ *
145
+ * @example
146
+ * ```typescript
147
+ * logger.info('Processing business logic', ActionMessage.appLogic());
148
+ * ```
149
+ */
12
150
  static appLogic(): string;
151
+ /**
152
+ * Returns the action tag for inbound operations.
153
+ * Used when receiving data from external services or systems.
154
+ *
155
+ * @returns The string '[INBOUND]'
156
+ *
157
+ * @example
158
+ * ```typescript
159
+ * logger.info('Receiving data', ActionMessage.inbound());
160
+ * ```
161
+ */
13
162
  static inbound(): string;
163
+ /**
164
+ * Returns the action tag for outbound operations.
165
+ * Used when sending data to external services or systems.
166
+ *
167
+ * @returns The string '[OUTBOUND]'
168
+ *
169
+ * @example
170
+ * ```typescript
171
+ * logger.info('Sending data to external API', ActionMessage.outbound());
172
+ * ```
173
+ */
14
174
  static outbound(): string;
175
+ /**
176
+ * Returns the action tag for exception/error conditions.
177
+ * Used when logging exceptions, errors, or failure scenarios.
178
+ *
179
+ * @returns The string '[EXCEPTION]'
180
+ *
181
+ * @example
182
+ * ```typescript
183
+ * logger.error('Operation failed', ActionMessage.exception());
184
+ * ```
185
+ */
15
186
  static exception(): string;
16
187
  }
@@ -1,46 +1,217 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ActionMessage = void 0;
4
+ /**
5
+ * ActionMessage - Provides standardized action tags for consistent logging across the application.
6
+ *
7
+ * This class contains static methods that return predefined action tags used for categorizing
8
+ * and filtering log entries. Using these constants ensures consistency in log formatting and
9
+ * makes it easier to search and analyze logs.
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * import { ActionMessage } from '@eqxjs/nest-logger';
14
+ *
15
+ * // Use in logging
16
+ * logger.info('Processing message', ActionMessage.consume());
17
+ * logger.info('Request received', ActionMessage.httpRequest());
18
+ * logger.error('Operation failed', ActionMessage.exception());
19
+ * ```
20
+ */
4
21
  class ActionMessage {
22
+ /**
23
+ * Returns the action tag for message consumption in progress.
24
+ * Used when starting to consume a message from a queue or broker.
25
+ *
26
+ * @returns The string '[CONSUMING]'
27
+ *
28
+ * @example
29
+ * ```typescript
30
+ * logger.info('Starting to consume', ActionMessage.consume());
31
+ * ```
32
+ */
5
33
  static consume() {
6
34
  return `[CONSUMING]`;
7
35
  }
36
+ /**
37
+ * Returns the action tag for completed message consumption.
38
+ * Used when a message has been successfully consumed from a queue or broker.
39
+ *
40
+ * @returns The string '[CONSUMED]'
41
+ *
42
+ * @example
43
+ * ```typescript
44
+ * logger.info('Message consumed', ActionMessage.consumed());
45
+ * ```
46
+ */
8
47
  static consumed() {
9
48
  return `[CONSUMED]`;
10
49
  }
50
+ /**
51
+ * Returns the action tag for message production in progress.
52
+ * Used when starting to produce/publish a message to a queue or broker.
53
+ *
54
+ * @returns The string '[PRODUCING]'
55
+ *
56
+ * @example
57
+ * ```typescript
58
+ * logger.info('Publishing message', ActionMessage.produce());
59
+ * ```
60
+ */
11
61
  static produce() {
12
62
  return `[PRODUCING]`;
13
63
  }
64
+ /**
65
+ * Returns the action tag for completed message production.
66
+ * Used when a message has been successfully produced/published.
67
+ *
68
+ * @returns The string '[PRODUCED]'
69
+ *
70
+ * @example
71
+ * ```typescript
72
+ * logger.info('Message published', ActionMessage.produced());
73
+ * ```
74
+ */
14
75
  static produced() {
15
76
  return `[PRODUCED]`;
16
77
  }
78
+ /**
79
+ * Returns the action tag for HTTP request operations.
80
+ * Used when receiving or sending HTTP requests.
81
+ *
82
+ * @returns The string '[HTTP_REQUEST]'
83
+ *
84
+ * @example
85
+ * ```typescript
86
+ * logger.info('HTTP request received', ActionMessage.httpRequest());
87
+ * ```
88
+ */
17
89
  static httpRequest() {
18
90
  return `[HTTP_REQUEST]`;
19
91
  }
92
+ /**
93
+ * Returns the action tag for HTTP response operations.
94
+ * Used when sending or receiving HTTP responses.
95
+ *
96
+ * @returns The string '[HTTP_RESPONSE]'
97
+ *
98
+ * @example
99
+ * ```typescript
100
+ * logger.info('Sending response', ActionMessage.httpResponse());
101
+ * ```
102
+ */
20
103
  static httpResponse() {
21
104
  return `[HTTP_RESPONSE]`;
22
105
  }
106
+ /**
107
+ * Returns the action tag for WebSocket message reception.
108
+ * Used when receiving messages via WebSocket.
109
+ *
110
+ * @returns The string '[WS_RECEIVED]'
111
+ *
112
+ * @example
113
+ * ```typescript
114
+ * logger.info('WebSocket message received', ActionMessage.wsRecv());
115
+ * ```
116
+ */
23
117
  static wsRecv() {
24
118
  return `[WS_RECEIVED]`;
25
119
  }
120
+ /**
121
+ * Returns the action tag for WebSocket message sending.
122
+ * Used when sending messages via WebSocket.
123
+ *
124
+ * @returns The string '[WS_SENT]'
125
+ *
126
+ * @example
127
+ * ```typescript
128
+ * logger.info('WebSocket message sent', ActionMessage.wsSent());
129
+ * ```
130
+ */
26
131
  static wsSent() {
27
132
  return `[WS_SENT]`;
28
133
  }
134
+ /**
135
+ * Returns the action tag for database request operations.
136
+ * Used when initiating database queries or operations.
137
+ *
138
+ * @returns The string '[DB_REQUEST]'
139
+ *
140
+ * @example
141
+ * ```typescript
142
+ * logger.debug('Executing query', ActionMessage.dbRequest());
143
+ * ```
144
+ */
29
145
  static dbRequest() {
30
146
  return `[DB_REQUEST]`;
31
147
  }
148
+ /**
149
+ * Returns the action tag for database response operations.
150
+ * Used when receiving results from database queries or operations.
151
+ *
152
+ * @returns The string '[DB_RESPONSE]'
153
+ *
154
+ * @example
155
+ * ```typescript
156
+ * logger.debug('Query completed', ActionMessage.dbResponse());
157
+ * ```
158
+ */
32
159
  static dbResponse() {
33
160
  return `[DB_RESPONSE]`;
34
161
  }
162
+ /**
163
+ * Returns the action tag for application logic operations.
164
+ * Used for business logic processing and internal operations.
165
+ *
166
+ * @returns The string '[APP_LOGIC]'
167
+ *
168
+ * @example
169
+ * ```typescript
170
+ * logger.info('Processing business logic', ActionMessage.appLogic());
171
+ * ```
172
+ */
35
173
  static appLogic() {
36
174
  return `[APP_LOGIC]`;
37
175
  }
176
+ /**
177
+ * Returns the action tag for inbound operations.
178
+ * Used when receiving data from external services or systems.
179
+ *
180
+ * @returns The string '[INBOUND]'
181
+ *
182
+ * @example
183
+ * ```typescript
184
+ * logger.info('Receiving data', ActionMessage.inbound());
185
+ * ```
186
+ */
38
187
  static inbound() {
39
188
  return `[INBOUND]`;
40
189
  }
190
+ /**
191
+ * Returns the action tag for outbound operations.
192
+ * Used when sending data to external services or systems.
193
+ *
194
+ * @returns The string '[OUTBOUND]'
195
+ *
196
+ * @example
197
+ * ```typescript
198
+ * logger.info('Sending data to external API', ActionMessage.outbound());
199
+ * ```
200
+ */
41
201
  static outbound() {
42
202
  return `[OUTBOUND]`;
43
203
  }
204
+ /**
205
+ * Returns the action tag for exception/error conditions.
206
+ * Used when logging exceptions, errors, or failure scenarios.
207
+ *
208
+ * @returns The string '[EXCEPTION]'
209
+ *
210
+ * @example
211
+ * ```typescript
212
+ * logger.error('Operation failed', ActionMessage.exception());
213
+ * ```
214
+ */
44
215
  static exception() {
45
216
  return '[EXCEPTION]';
46
217
  }
@@ -1 +1 @@
1
- {"version":3,"file":"action-message.constant.js","sourceRoot":"","sources":["../../src/constants/action-message.constant.ts"],"names":[],"mappings":";;;AAAA,MAAa,aAAa;IACjB,MAAM,CAAC,OAAO;QACnB,OAAO,aAAa,CAAC;IACvB,CAAC;IAEM,MAAM,CAAC,QAAQ;QACpB,OAAO,YAAY,CAAC;IACtB,CAAC;IAEM,MAAM,CAAC,OAAO;QACnB,OAAO,aAAa,CAAC;IACvB,CAAC;IAEM,MAAM,CAAC,QAAQ;QACpB,OAAO,YAAY,CAAC;IACtB,CAAC;IAEM,MAAM,CAAC,WAAW;QACvB,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IAEM,MAAM,CAAC,YAAY;QACxB,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IAEM,MAAM,CAAC,MAAM;QAClB,OAAO,eAAe,CAAC;IACzB,CAAC;IAEM,MAAM,CAAC,MAAM;QAClB,OAAO,WAAW,CAAC;IACrB,CAAC;IAEM,MAAM,CAAC,SAAS;QACrB,OAAO,cAAc,CAAC;IACxB,CAAC;IAEM,MAAM,CAAC,UAAU;QACtB,OAAO,eAAe,CAAC;IACzB,CAAC;IAEM,MAAM,CAAC,QAAQ;QACpB,OAAO,aAAa,CAAC;IACvB,CAAC;IAEM,MAAM,CAAC,OAAO;QACnB,OAAO,WAAW,CAAC;IACrB,CAAC;IAEM,MAAM,CAAC,QAAQ;QACpB,OAAO,YAAY,CAAC;IACtB,CAAC;IAEM,MAAM,CAAC,SAAS;QACrB,OAAO,aAAa,CAAC;IACvB,CAAC;CACF;AAxDD,sCAwDC"}
1
+ {"version":3,"file":"action-message.constant.js","sourceRoot":"","sources":["../../src/constants/action-message.constant.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAa,aAAa;IACxB;;;;;;;;;;OAUG;IACI,MAAM,CAAC,OAAO;QACnB,OAAO,aAAa,CAAC;IACvB,CAAC;IAED;;;;;;;;;;OAUG;IACI,MAAM,CAAC,QAAQ;QACpB,OAAO,YAAY,CAAC;IACtB,CAAC;IAED;;;;;;;;;;OAUG;IACI,MAAM,CAAC,OAAO;QACnB,OAAO,aAAa,CAAC;IACvB,CAAC;IAED;;;;;;;;;;OAUG;IACI,MAAM,CAAC,QAAQ;QACpB,OAAO,YAAY,CAAC;IACtB,CAAC;IAED;;;;;;;;;;OAUG;IACI,MAAM,CAAC,WAAW;QACvB,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IAED;;;;;;;;;;OAUG;IACI,MAAM,CAAC,YAAY;QACxB,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IAED;;;;;;;;;;OAUG;IACI,MAAM,CAAC,MAAM;QAClB,OAAO,eAAe,CAAC;IACzB,CAAC;IAED;;;;;;;;;;OAUG;IACI,MAAM,CAAC,MAAM;QAClB,OAAO,WAAW,CAAC;IACrB,CAAC;IAED;;;;;;;;;;OAUG;IACI,MAAM,CAAC,SAAS;QACrB,OAAO,cAAc,CAAC;IACxB,CAAC;IAED;;;;;;;;;;OAUG;IACI,MAAM,CAAC,UAAU;QACtB,OAAO,eAAe,CAAC;IACzB,CAAC;IAED;;;;;;;;;;OAUG;IACI,MAAM,CAAC,QAAQ;QACpB,OAAO,aAAa,CAAC;IACvB,CAAC;IAED;;;;;;;;;;OAUG;IACI,MAAM,CAAC,OAAO;QACnB,OAAO,WAAW,CAAC;IACrB,CAAC;IAED;;;;;;;;;;OAUG;IACI,MAAM,CAAC,QAAQ;QACpB,OAAO,YAAY,CAAC;IACtB,CAAC;IAED;;;;;;;;;;OAUG;IACI,MAAM,CAAC,SAAS;QACrB,OAAO,aAAa,CAAC;IACvB,CAAC;CACF;AAlND,sCAkNC"}
@@ -3,17 +3,124 @@ import { LoggerDto } from '../../models/logger.dto';
3
3
  import { LoggerOpt } from '../../interfaces/logger-opt.interface';
4
4
  import { DataM, DataM1I, DataM2I, DataM3I } from '../../interfaces/data.interface';
5
5
  type MessageType = 'M1' | 'M2' | 'M3';
6
+ /**
7
+ * LoggerFormat - Format-specific logger for M1, M2, and M3 message protocols.
8
+ *
9
+ * Provides logging capabilities for different message formats used in distributed systems:
10
+ * - **M1**: Message broker/queue operations (Kafka, RabbitMQ, etc.)
11
+ * - **M2**: HTTP/protocol operations (REST APIs, GraphQL, etc.)
12
+ * - **M3**: Service-to-service operations (gRPC, internal services, databases, etc.)
13
+ *
14
+ * Each format requires specific data structures with appropriate header and metadata fields.
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * // M1 Format
19
+ * const loggerM1 = new LoggerFormat(baseLogger, 'M1');
20
+ * loggerM1.info('order.topic', '[CONSUMING]', dataM1, 'Processing order');
21
+ *
22
+ * // M2 Format
23
+ * const loggerM2 = new LoggerFormat(baseLogger, 'M2');
24
+ * loggerM2.info('api.users', '[HTTP_REQUEST]', dataM2, 'User creation');
25
+ *
26
+ * // M3 Format
27
+ * const loggerM3 = new LoggerFormat(baseLogger, 'M3');
28
+ * loggerM3.debug('db.users', '[DB_REQUEST]', dataM3, 'Query users');
29
+ * ```
30
+ */
6
31
  export declare class LoggerFormat {
7
32
  protected readonly messageType: MessageType;
8
33
  private logger;
34
+ /**
35
+ * Creates a new LoggerFormat instance.
36
+ *
37
+ * @param logger - BaseAppLogger instance for actual logging
38
+ * @param messageType - Message format type ('M1', 'M2', or 'M3')
39
+ */
9
40
  constructor(logger: BaseAppLogger, messageType: MessageType);
41
+ /**
42
+ * Internal method to handle log level checking and routing.
43
+ *
44
+ * @param level - Log level
45
+ * @param topic - Topic identifier
46
+ * @param action - Action tag
47
+ * @param data - Message data
48
+ * @param message - Optional message text
49
+ * @param opt - Optional configuration
50
+ * @private
51
+ */
10
52
  private logMethod;
53
+ /**
54
+ * Logs a debug-level message for detailed diagnostic information.
55
+ *
56
+ * @param topic - Topic or identifier (e.g., 'payment.topic', 'api.users')
57
+ * @param action - Action tag (e.g., '[CONSUMING]', '[HTTP_REQUEST]')
58
+ * @param data - Message data (DataM1I, DataM2I, or DataM3I)
59
+ * @param message - Optional descriptive message
60
+ * @param opt - Optional logging configuration
61
+ */
11
62
  debug(topic: string, action: string, data: any, message?: string, opt?: LoggerOpt): void;
63
+ /**
64
+ * Logs an info-level message for general information.
65
+ *
66
+ * @param topic - Topic or identifier
67
+ * @param action - Action tag
68
+ * @param data - Message data (DataM1I, DataM2I, or DataM3I)
69
+ * @param message - Optional descriptive message
70
+ * @param opt - Optional logging configuration
71
+ */
12
72
  info(topic: string, action: string, data: any, message?: string, opt?: LoggerOpt): void;
73
+ /**
74
+ * Logs an info-level message (alias for info method).
75
+ *
76
+ * @param topic - Topic or identifier
77
+ * @param action - Action tag
78
+ * @param data - Message data (DataM1I, DataM2I, or DataM3I)
79
+ * @param message - Optional descriptive message
80
+ * @param opt - Optional logging configuration
81
+ */
13
82
  log(topic: string, action: string, data: any, message?: string, opt?: LoggerOpt): void;
83
+ /**
84
+ * Logs an error-level message for error conditions.
85
+ *
86
+ * @param topic - Topic or identifier
87
+ * @param action - Action tag (typically '[EXCEPTION]')
88
+ * @param data - Message data (DataM1I, DataM2I, or DataM3I)
89
+ * @param message - Optional error message
90
+ * @param opt - Optional logging configuration
91
+ */
14
92
  error(topic: string, action: string, data: any, message?: string, opt?: LoggerOpt): void;
93
+ /**
94
+ * Logs a warning-level message for potentially harmful situations.
95
+ *
96
+ * @param topic - Topic or identifier
97
+ * @param action - Action tag
98
+ * @param data - Message data (DataM1I, DataM2I, or DataM3I)
99
+ * @param message - Optional warning message
100
+ * @param opt - Optional logging configuration
101
+ */
15
102
  warn(topic: string, action: string, data: any, message?: string, opt?: LoggerOpt): void;
103
+ /**
104
+ * Logs a verbose-level message for most detailed information.
105
+ *
106
+ * @param topic - Topic or identifier
107
+ * @param action - Action tag
108
+ * @param data - Message data (DataM1I, DataM2I, or DataM3I)
109
+ * @param message - Optional verbose message
110
+ * @param opt - Optional logging configuration
111
+ */
16
112
  verbose(topic: string, action: string, data: any, message?: string, opt?: LoggerOpt): void;
113
+ /**
114
+ * Routes the message to the appropriate format-specific logger (M1/M2/M3).
115
+ *
116
+ * @param serverity - Log severity level
117
+ * @param action - Action tag
118
+ * @param message - Log message
119
+ * @param data - Message data
120
+ * @param topic - Topic identifier
121
+ * @param opt - Optional configuration
122
+ * @public
123
+ */
17
124
  messageLog(serverity: string, action: string, message: any, data: DataM, topic: string, opt?: LoggerOpt): void;
18
125
  summarySuccess(topic: string, appResult: string, appResultCode: string, serviceTime: number, data: DataM, opt?: LoggerOpt): LoggerDto;
19
126
  summaryError(topic: string, appResult: string, appResultCode: string, serviceTime: number, data: DataM, stack?: string[], opt?: LoggerOpt): LoggerDto;
@@ -37,36 +37,143 @@ exports.LoggerFormat = void 0;
37
37
  const logger_constants_1 = require("../../constants/logger.constants");
38
38
  const message_formatter_helper_1 = require("../../helpers/message-formatter.helper");
39
39
  const logUtil = __importStar(require("../../helpers/log.helper"));
40
+ /**
41
+ * LoggerFormat - Format-specific logger for M1, M2, and M3 message protocols.
42
+ *
43
+ * Provides logging capabilities for different message formats used in distributed systems:
44
+ * - **M1**: Message broker/queue operations (Kafka, RabbitMQ, etc.)
45
+ * - **M2**: HTTP/protocol operations (REST APIs, GraphQL, etc.)
46
+ * - **M3**: Service-to-service operations (gRPC, internal services, databases, etc.)
47
+ *
48
+ * Each format requires specific data structures with appropriate header and metadata fields.
49
+ *
50
+ * @example
51
+ * ```typescript
52
+ * // M1 Format
53
+ * const loggerM1 = new LoggerFormat(baseLogger, 'M1');
54
+ * loggerM1.info('order.topic', '[CONSUMING]', dataM1, 'Processing order');
55
+ *
56
+ * // M2 Format
57
+ * const loggerM2 = new LoggerFormat(baseLogger, 'M2');
58
+ * loggerM2.info('api.users', '[HTTP_REQUEST]', dataM2, 'User creation');
59
+ *
60
+ * // M3 Format
61
+ * const loggerM3 = new LoggerFormat(baseLogger, 'M3');
62
+ * loggerM3.debug('db.users', '[DB_REQUEST]', dataM3, 'Query users');
63
+ * ```
64
+ */
40
65
  class LoggerFormat {
41
66
  messageType;
42
67
  logger;
68
+ /**
69
+ * Creates a new LoggerFormat instance.
70
+ *
71
+ * @param logger - BaseAppLogger instance for actual logging
72
+ * @param messageType - Message format type ('M1', 'M2', or 'M3')
73
+ */
43
74
  constructor(logger, messageType) {
44
75
  this.messageType = messageType;
45
76
  this.logger = logger;
46
77
  }
78
+ /**
79
+ * Internal method to handle log level checking and routing.
80
+ *
81
+ * @param level - Log level
82
+ * @param topic - Topic identifier
83
+ * @param action - Action tag
84
+ * @param data - Message data
85
+ * @param message - Optional message text
86
+ * @param opt - Optional configuration
87
+ * @private
88
+ */
47
89
  logMethod(level, topic, action, data, message, opt) {
48
90
  if (!logUtil.isLevelEnable(level))
49
91
  return;
50
92
  this.writeLogCommon(level, topic, action, data, message, opt);
51
93
  }
94
+ /**
95
+ * Logs a debug-level message for detailed diagnostic information.
96
+ *
97
+ * @param topic - Topic or identifier (e.g., 'payment.topic', 'api.users')
98
+ * @param action - Action tag (e.g., '[CONSUMING]', '[HTTP_REQUEST]')
99
+ * @param data - Message data (DataM1I, DataM2I, or DataM3I)
100
+ * @param message - Optional descriptive message
101
+ * @param opt - Optional logging configuration
102
+ */
52
103
  debug(topic, action, data, message, opt) {
53
104
  this.logMethod(logger_constants_1.LOG_LEVELS.DEBUG, topic, action, data, message, opt);
54
105
  }
106
+ /**
107
+ * Logs an info-level message for general information.
108
+ *
109
+ * @param topic - Topic or identifier
110
+ * @param action - Action tag
111
+ * @param data - Message data (DataM1I, DataM2I, or DataM3I)
112
+ * @param message - Optional descriptive message
113
+ * @param opt - Optional logging configuration
114
+ */
55
115
  info(topic, action, data, message, opt) {
56
116
  this.logMethod(logger_constants_1.LOG_LEVELS.INFO, topic, action, data, message, opt);
57
117
  }
118
+ /**
119
+ * Logs an info-level message (alias for info method).
120
+ *
121
+ * @param topic - Topic or identifier
122
+ * @param action - Action tag
123
+ * @param data - Message data (DataM1I, DataM2I, or DataM3I)
124
+ * @param message - Optional descriptive message
125
+ * @param opt - Optional logging configuration
126
+ */
58
127
  log(topic, action, data, message, opt) {
59
128
  this.logMethod(logger_constants_1.LOG_LEVELS.INFO, topic, action, data, message, opt);
60
129
  }
130
+ /**
131
+ * Logs an error-level message for error conditions.
132
+ *
133
+ * @param topic - Topic or identifier
134
+ * @param action - Action tag (typically '[EXCEPTION]')
135
+ * @param data - Message data (DataM1I, DataM2I, or DataM3I)
136
+ * @param message - Optional error message
137
+ * @param opt - Optional logging configuration
138
+ */
61
139
  error(topic, action, data, message, opt) {
62
140
  this.logMethod(logger_constants_1.LOG_LEVELS.ERROR, topic, action, data, message, opt);
63
141
  }
142
+ /**
143
+ * Logs a warning-level message for potentially harmful situations.
144
+ *
145
+ * @param topic - Topic or identifier
146
+ * @param action - Action tag
147
+ * @param data - Message data (DataM1I, DataM2I, or DataM3I)
148
+ * @param message - Optional warning message
149
+ * @param opt - Optional logging configuration
150
+ */
64
151
  warn(topic, action, data, message, opt) {
65
152
  this.logMethod(logger_constants_1.LOG_LEVELS.WARN, topic, action, data, message, opt);
66
153
  }
154
+ /**
155
+ * Logs a verbose-level message for most detailed information.
156
+ *
157
+ * @param topic - Topic or identifier
158
+ * @param action - Action tag
159
+ * @param data - Message data (DataM1I, DataM2I, or DataM3I)
160
+ * @param message - Optional verbose message
161
+ * @param opt - Optional logging configuration
162
+ */
67
163
  verbose(topic, action, data, message, opt) {
68
164
  this.logMethod(logger_constants_1.LOG_LEVELS.VERBOSE, topic, action, data, message, opt);
69
165
  }
166
+ /**
167
+ * Routes the message to the appropriate format-specific logger (M1/M2/M3).
168
+ *
169
+ * @param serverity - Log severity level
170
+ * @param action - Action tag
171
+ * @param message - Log message
172
+ * @param data - Message data
173
+ * @param topic - Topic identifier
174
+ * @param opt - Optional configuration
175
+ * @public
176
+ */
70
177
  messageLog(serverity, action, message, data, topic, opt) {
71
178
  switch (this.messageType) {
72
179
  case 'M1':