@eqxjs/nest-logger 3.1.0-beta.13 → 3.1.0-beta.15
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/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/interfaces/data-service.interface.d.ts +1 -1
- package/dist/interfaces/data.interface.d.ts +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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.formatter.js","sourceRoot":"","sources":["../../../src/core/formatters/logger.formatter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,uEAA8D;AAC9D,qFAA2E;AAC3E,kEAAoD;AAIpD,MAAa,YAAY;
|
|
1
|
+
{"version":3,"file":"logger.formatter.js","sourceRoot":"","sources":["../../../src/core/formatters/logger.formatter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,uEAA8D;AAC9D,qFAA2E;AAC3E,kEAAoD;AAIpD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAa,YAAY;IAWF;IAVb,MAAM,CAAgB;IAE9B;;;;;OAKG;IACH,YACE,MAAqB,EACF,WAAwB;QAAxB,gBAAW,GAAX,WAAW,CAAa;QAE3C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;;;;;;;;;OAUG;IACK,SAAS,CACf,KAAa,EACb,KAAa,EACb,MAAc,EACd,IAAS,EACT,OAAgB,EAChB,GAAe;QAEf,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC;YAAE,OAAO;QAC1C,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;IAChE,CAAC;IAED;;;;;;;;OAQG;IACI,KAAK,CAAC,KAAa,EAAE,MAAc,EAAE,IAAS,EAAE,OAAgB,EAAE,GAAe;QACtF,IAAI,CAAC,SAAS,CAAC,6BAAU,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;IACtE,CAAC;IAED;;;;;;;;OAQG;IACI,IAAI,CAAC,KAAa,EAAE,MAAc,EAAE,IAAS,EAAE,OAAgB,EAAE,GAAe;QACrF,IAAI,CAAC,SAAS,CAAC,6BAAU,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE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AAC,MAAM,CAAC,QAA+B,CAAQ,CAAC;QAClE,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;YAChC,KAAK,CAAC,IAAI,CACR,IAAI,CAAC,MAAM,EACX,OAAO,EACP,MAAM,EACN,MAAM,EAAE,UAAU,IAAI,SAAS,EAC/B,KAAK,EACL,MAAM,EAAE,OAAO,IAAI,SAAS,EAC5B,MAAM,EAAE,WAAW,IAAI,SAAS,EAChC,MAAM,EAAE,OAAO,IAAI,SAAS,EAC5B,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,EAAE,EAC7B,MAAM,EAAE,OAAO,IAAI,SAAS,EAC5B,MAAM,EAAE,WAAW,IAAI,SAAS,EAChC,MAAM,EAAE,QAAQ,EAAE,IAAI,IAAI,SAAS,EACnC,MAAM,EAAE,QAAQ,EAAE,MAAM,IAAI,SAAS,EACrC,MAAM,EAAE,QAAQ,EAAE,MAAM,IAAI,SAAS,EACrC,GAAG,CACJ,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AA1bD,oCA0bC"}
|
|
@@ -1,11 +1,44 @@
|
|
|
1
1
|
import { BaseAppLogger } from './base-app.logger';
|
|
2
2
|
import { LoggerFormat } from '../formatters/logger.formatter';
|
|
3
|
+
/**
|
|
4
|
+
* AppLogger - Unified logger providing access to all logger types.
|
|
5
|
+
*
|
|
6
|
+
* Provides a single entry point for accessing different logger implementations:
|
|
7
|
+
* - `app`: BaseAppLogger for standard structured logging
|
|
8
|
+
* - `loggerM1`: LoggerFormat for M1 message format (broker/queue operations)
|
|
9
|
+
* - `loggerM2`: LoggerFormat for M2 message format (HTTP/protocol operations)
|
|
10
|
+
* - `loggerM3`: LoggerFormat for M3 message format (service-to-service operations)
|
|
11
|
+
*
|
|
12
|
+
* This wrapper class simplifies logger initialization and provides consistent
|
|
13
|
+
* access patterns across different message formats.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const logger = new AppLogger('MyApp', 'MyService');
|
|
18
|
+
*
|
|
19
|
+
* // Use standard structured logger
|
|
20
|
+
* logger.app.info('Operation completed', '[INFO]');
|
|
21
|
+
*
|
|
22
|
+
* // Use M1 format for Kafka messages
|
|
23
|
+
* logger.loggerM1.info('order.topic', '[CONSUMING]', dataM1, 'Processing order');
|
|
24
|
+
*
|
|
25
|
+
* // Use M2 format for HTTP requests
|
|
26
|
+
* logger.loggerM2.info('api.endpoint', '[HTTP_REQUEST]', dataM2, 'Request received');
|
|
27
|
+
*
|
|
28
|
+
* // Use M3 format for database operations
|
|
29
|
+
* logger.loggerM3.debug('db.users', '[DB_REQUEST]', dataM3, 'Querying users');
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
3
32
|
export declare class AppLogger {
|
|
4
33
|
protected appName: string;
|
|
5
34
|
protected context?: string;
|
|
35
|
+
/** Standard structured logger with OpenTelemetry integration */
|
|
6
36
|
app: BaseAppLogger;
|
|
37
|
+
/** M1 format logger for broker/queue message operations */
|
|
7
38
|
loggerM1: LoggerFormat;
|
|
39
|
+
/** M2 format logger for HTTP/protocol operations */
|
|
8
40
|
loggerM2: LoggerFormat;
|
|
41
|
+
/** M3 format logger for service-to-service operations */
|
|
9
42
|
loggerM3: LoggerFormat;
|
|
10
43
|
constructor();
|
|
11
44
|
constructor(appName?: string);
|
|
@@ -16,13 +16,64 @@ exports.AppLogger = void 0;
|
|
|
16
16
|
const common_1 = require("@nestjs/common");
|
|
17
17
|
const base_app_logger_1 = require("./base-app.logger");
|
|
18
18
|
const logger_formatter_1 = require("../formatters/logger.formatter");
|
|
19
|
+
/**
|
|
20
|
+
* AppLogger - Unified logger providing access to all logger types.
|
|
21
|
+
*
|
|
22
|
+
* Provides a single entry point for accessing different logger implementations:
|
|
23
|
+
* - `app`: BaseAppLogger for standard structured logging
|
|
24
|
+
* - `loggerM1`: LoggerFormat for M1 message format (broker/queue operations)
|
|
25
|
+
* - `loggerM2`: LoggerFormat for M2 message format (HTTP/protocol operations)
|
|
26
|
+
* - `loggerM3`: LoggerFormat for M3 message format (service-to-service operations)
|
|
27
|
+
*
|
|
28
|
+
* This wrapper class simplifies logger initialization and provides consistent
|
|
29
|
+
* access patterns across different message formats.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* const logger = new AppLogger('MyApp', 'MyService');
|
|
34
|
+
*
|
|
35
|
+
* // Use standard structured logger
|
|
36
|
+
* logger.app.info('Operation completed', '[INFO]');
|
|
37
|
+
*
|
|
38
|
+
* // Use M1 format for Kafka messages
|
|
39
|
+
* logger.loggerM1.info('order.topic', '[CONSUMING]', dataM1, 'Processing order');
|
|
40
|
+
*
|
|
41
|
+
* // Use M2 format for HTTP requests
|
|
42
|
+
* logger.loggerM2.info('api.endpoint', '[HTTP_REQUEST]', dataM2, 'Request received');
|
|
43
|
+
*
|
|
44
|
+
* // Use M3 format for database operations
|
|
45
|
+
* logger.loggerM3.debug('db.users', '[DB_REQUEST]', dataM3, 'Querying users');
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
19
48
|
let AppLogger = class AppLogger {
|
|
20
49
|
appName;
|
|
21
50
|
context;
|
|
51
|
+
/** Standard structured logger with OpenTelemetry integration */
|
|
22
52
|
app;
|
|
53
|
+
/** M1 format logger for broker/queue message operations */
|
|
23
54
|
loggerM1;
|
|
55
|
+
/** M2 format logger for HTTP/protocol operations */
|
|
24
56
|
loggerM2;
|
|
57
|
+
/** M3 format logger for service-to-service operations */
|
|
25
58
|
loggerM3;
|
|
59
|
+
/**
|
|
60
|
+
* Creates a new AppLogger instance with all logger types initialized.
|
|
61
|
+
*
|
|
62
|
+
* @param appName - Name of the application (default: 'EQXJS')
|
|
63
|
+
* @param context - Optional context or component name
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```typescript
|
|
67
|
+
* // Default initialization
|
|
68
|
+
* const logger1 = new AppLogger();
|
|
69
|
+
*
|
|
70
|
+
* // With app name
|
|
71
|
+
* const logger2 = new AppLogger('MyApp');
|
|
72
|
+
*
|
|
73
|
+
* // With app name and context
|
|
74
|
+
* const logger3 = new AppLogger('MyApp', 'UserService');
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
26
77
|
constructor(appName = 'EQXJS', context) {
|
|
27
78
|
this.appName = appName;
|
|
28
79
|
this.context = context;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.logger.js","sourceRoot":"","sources":["../../../src/core/loggers/app.logger.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA0C;AAC1C,uDAAkD;AAClD,qEAA8D;AAE9D,IAAa,SAAS,GAAtB,MAAa,SAAS;
|
|
1
|
+
{"version":3,"file":"app.logger.js","sourceRoot":"","sources":["../../../src/core/loggers/app.logger.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA0C;AAC1C,uDAAkD;AAClD,qEAA8D;AAE9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,IAAa,SAAS,GAAtB,MAAa,SAAS;IAmCI;IACA;IAnCxB,gEAAgE;IACzD,GAAG,CAAgB;IAE1B,2DAA2D;IACpD,QAAQ,CAAe;IAE9B,oDAAoD;IAC7C,QAAQ,CAAe;IAE9B,yDAAyD;IAClD,QAAQ,CAAe;IAK9B;;;;;;;;;;;;;;;;;OAiBG;IACH,YACwB,UAAkB,OAAO,EACzB,OAAgB;QADhB,YAAO,GAAP,OAAO,CAAkB;QACzB,YAAO,GAAP,OAAO,CAAS;QAEtC,IAAI,CAAC,GAAG,GAAG,IAAI,+BAAa,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QACzD,IAAI,CAAC,QAAQ,GAAG,IAAI,+BAAY,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QACjD,IAAI,CAAC,QAAQ,GAAG,IAAI,+BAAY,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QACjD,IAAI,CAAC,QAAQ,GAAG,IAAI,+BAAY,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACnD,CAAC;CACF,CAAA;AA3CY,8BAAS;oBAAT,SAAS;IAmCjB,WAAA,IAAA,iBAAQ,GAAE,CAAA;IACV,WAAA,IAAA,iBAAQ,GAAE,CAAA;;GApCF,SAAS,CA2CrB"}
|
|
@@ -1,16 +1,127 @@
|
|
|
1
1
|
import { LoggerService } from '@nestjs/common';
|
|
2
|
+
/**
|
|
3
|
+
* CustomLogger - Basic logger implementation with standard log levels.
|
|
4
|
+
*
|
|
5
|
+
* Implements NestJS LoggerService interface and uses Winston for actual logging.
|
|
6
|
+
* Provides simple logging methods (log, error, warn, debug, verbose) for basic use cases.
|
|
7
|
+
*
|
|
8
|
+
* For advanced structured logging with OpenTelemetry integration, use BaseAppLogger or AppLogger.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* const logger = new CustomLogger('MyService');
|
|
13
|
+
* logger.log('Application started');
|
|
14
|
+
* logger.error('An error occurred', 'Error stack trace');
|
|
15
|
+
* logger.warn('Warning message');
|
|
16
|
+
* logger.debug('Debug information');
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @implements {LoggerService}
|
|
20
|
+
*/
|
|
2
21
|
export declare class CustomLogger implements LoggerService {
|
|
3
22
|
protected appName: string;
|
|
4
23
|
private logger;
|
|
5
24
|
protected readonly cachedHostname: string;
|
|
6
25
|
constructor();
|
|
7
26
|
constructor(appName?: string);
|
|
27
|
+
/**
|
|
28
|
+
* Formats a Date object to ISO 8601 string with UTC+7 timezone offset.
|
|
29
|
+
*
|
|
30
|
+
* @param date - The date to format
|
|
31
|
+
* @returns ISO 8601 formatted string (e.g., "2026-01-12T10:00:00.000Z")
|
|
32
|
+
* @protected
|
|
33
|
+
*/
|
|
8
34
|
protected dateFormat(date: Date): string;
|
|
35
|
+
/**
|
|
36
|
+
* Initializes a LoggerDto with basic log information.
|
|
37
|
+
*
|
|
38
|
+
* Creates a structured log entry from the provided message and parameters.
|
|
39
|
+
* Handles message formatting, truncation, and sets default values for required fields.
|
|
40
|
+
*
|
|
41
|
+
* @param level - Log level
|
|
42
|
+
* @param message - Log message (any type)
|
|
43
|
+
* @param optionalParams - Additional parameters (last parameter becomes componentName)
|
|
44
|
+
* @returns Initialized LoggerDto object
|
|
45
|
+
* @private
|
|
46
|
+
*/
|
|
9
47
|
private initializeLogger;
|
|
48
|
+
/**
|
|
49
|
+
* Logs an informational message.
|
|
50
|
+
* Alias for standard console.log behavior in NestJS applications.
|
|
51
|
+
*
|
|
52
|
+
* @param message - Message to log (any type)
|
|
53
|
+
* @param optionalParams - Additional parameters (last one becomes component name)
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* logger.log('User created successfully');
|
|
58
|
+
* logger.log('Request processed', 'UserController');
|
|
59
|
+
* logger.log({ userId: 123, action: 'create' });
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
10
62
|
log(message: any, ...optionalParams: any[]): void;
|
|
63
|
+
/**
|
|
64
|
+
* Logs an error message.
|
|
65
|
+
* Use for logging error conditions and failures.
|
|
66
|
+
*
|
|
67
|
+
* @param message - Error message (any type)
|
|
68
|
+
* @param optionalParams - Additional parameters (last one becomes component name)
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```typescript
|
|
72
|
+
* logger.error('Database connection failed');
|
|
73
|
+
* logger.error('Query error', 'DatabaseService');
|
|
74
|
+
* logger.error(new Error('Something went wrong'));
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
11
77
|
error(message: any, ...optionalParams: any[]): void;
|
|
78
|
+
/**
|
|
79
|
+
* Logs a warning message.
|
|
80
|
+
* Use for potentially harmful situations or deprecated functionality.
|
|
81
|
+
*
|
|
82
|
+
* @param message - Warning message (any type)
|
|
83
|
+
* @param optionalParams - Additional parameters (last one becomes component name)
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```typescript
|
|
87
|
+
* logger.warn('API rate limit approaching');
|
|
88
|
+
* logger.warn('Using deprecated method', 'PaymentService');
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
12
91
|
warn(message: any, ...optionalParams: any[]): void;
|
|
92
|
+
/**
|
|
93
|
+
* Logs a debug message.
|
|
94
|
+
* Use for detailed diagnostic information during development.
|
|
95
|
+
*
|
|
96
|
+
* @param message - Debug message (any type)
|
|
97
|
+
* @param optionalParams - Additional parameters (last one becomes component name)
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```typescript
|
|
101
|
+
* logger.debug('Processing request payload');
|
|
102
|
+
* logger.debug({ requestId: '123', payload: data }, 'RequestHandler');
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
13
105
|
debug(message: any, ...optionalParams: any[]): void;
|
|
106
|
+
/**
|
|
107
|
+
* Logs a verbose message.
|
|
108
|
+
* Use for the most detailed information, typically only needed for deep debugging.
|
|
109
|
+
*
|
|
110
|
+
* @param message - Verbose message (any type)
|
|
111
|
+
* @param optionalParams - Additional parameters (last one becomes component name)
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```typescript
|
|
115
|
+
* logger.verbose('Internal state dump');
|
|
116
|
+
* logger.verbose({ state: internalState }, 'StateMachine');
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
14
119
|
verbose(message: any, ...optionalParams: any[]): void;
|
|
120
|
+
/**
|
|
121
|
+
* Flushes the log message to Winston logger.
|
|
122
|
+
*
|
|
123
|
+
* @param message - Message to be logged
|
|
124
|
+
* @protected
|
|
125
|
+
*/
|
|
15
126
|
protected flushLog(message: any): void;
|
|
16
127
|
}
|
|
@@ -57,10 +57,37 @@ const logger_dto_1 = require("../../models/logger.dto");
|
|
|
57
57
|
const logger_constants_1 = require("../../constants/logger.constants");
|
|
58
58
|
const message_formatter_helper_1 = require("../../helpers/message-formatter.helper");
|
|
59
59
|
const logUtil = __importStar(require("../../helpers/log.helper"));
|
|
60
|
+
/**
|
|
61
|
+
* CustomLogger - Basic logger implementation with standard log levels.
|
|
62
|
+
*
|
|
63
|
+
* Implements NestJS LoggerService interface and uses Winston for actual logging.
|
|
64
|
+
* Provides simple logging methods (log, error, warn, debug, verbose) for basic use cases.
|
|
65
|
+
*
|
|
66
|
+
* For advanced structured logging with OpenTelemetry integration, use BaseAppLogger or AppLogger.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```typescript
|
|
70
|
+
* const logger = new CustomLogger('MyService');
|
|
71
|
+
* logger.log('Application started');
|
|
72
|
+
* logger.error('An error occurred', 'Error stack trace');
|
|
73
|
+
* logger.warn('Warning message');
|
|
74
|
+
* logger.debug('Debug information');
|
|
75
|
+
* ```
|
|
76
|
+
*
|
|
77
|
+
* @implements {LoggerService}
|
|
78
|
+
*/
|
|
60
79
|
let CustomLogger = class CustomLogger {
|
|
61
80
|
appName;
|
|
62
81
|
logger;
|
|
63
82
|
cachedHostname;
|
|
83
|
+
/**
|
|
84
|
+
* Creates a new CustomLogger instance.
|
|
85
|
+
*
|
|
86
|
+
* Initializes Winston logger with console transport and caches the hostname
|
|
87
|
+
* for performance optimization.
|
|
88
|
+
*
|
|
89
|
+
* @param appName - Name of the application (default: 'EQXJS')
|
|
90
|
+
*/
|
|
64
91
|
constructor(appName = logger_constants_1.DEFAULT_VALUES.DEFAULT_APP_NAME) {
|
|
65
92
|
this.appName = appName;
|
|
66
93
|
this.logger = winston.createLogger({
|
|
@@ -69,9 +96,28 @@ let CustomLogger = class CustomLogger {
|
|
|
69
96
|
});
|
|
70
97
|
this.cachedHostname = os.hostname();
|
|
71
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* Formats a Date object to ISO 8601 string with UTC+7 timezone offset.
|
|
101
|
+
*
|
|
102
|
+
* @param date - The date to format
|
|
103
|
+
* @returns ISO 8601 formatted string (e.g., "2026-01-12T10:00:00.000Z")
|
|
104
|
+
* @protected
|
|
105
|
+
*/
|
|
72
106
|
dateFormat(date) {
|
|
73
107
|
return (0, moment_1.default)(date).utcOffset('+0700').format('YYYY-MM-DDTHH:mm:ss.SSS\\Z');
|
|
74
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* Initializes a LoggerDto with basic log information.
|
|
111
|
+
*
|
|
112
|
+
* Creates a structured log entry from the provided message and parameters.
|
|
113
|
+
* Handles message formatting, truncation, and sets default values for required fields.
|
|
114
|
+
*
|
|
115
|
+
* @param level - Log level
|
|
116
|
+
* @param message - Log message (any type)
|
|
117
|
+
* @param optionalParams - Additional parameters (last parameter becomes componentName)
|
|
118
|
+
* @returns Initialized LoggerDto object
|
|
119
|
+
* @private
|
|
120
|
+
*/
|
|
75
121
|
initializeLogger(level, message, ...optionalParams) {
|
|
76
122
|
const componentName = optionalParams.length > 0 ? optionalParams.pop() : undefined;
|
|
77
123
|
const formattedMessage = (0, message_formatter_helper_1.formatMessage)(message);
|
|
@@ -99,36 +145,109 @@ let CustomLogger = class CustomLogger {
|
|
|
99
145
|
dto.public = logger_constants_1.DEFAULT_VALUES.NONE;
|
|
100
146
|
return dto;
|
|
101
147
|
}
|
|
148
|
+
/**
|
|
149
|
+
* Logs an informational message.
|
|
150
|
+
* Alias for standard console.log behavior in NestJS applications.
|
|
151
|
+
*
|
|
152
|
+
* @param message - Message to log (any type)
|
|
153
|
+
* @param optionalParams - Additional parameters (last one becomes component name)
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* ```typescript
|
|
157
|
+
* logger.log('User created successfully');
|
|
158
|
+
* logger.log('Request processed', 'UserController');
|
|
159
|
+
* logger.log({ userId: 123, action: 'create' });
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
102
162
|
log(message, ...optionalParams) {
|
|
103
163
|
if (!logUtil.isLevelEnable(logger_constants_1.LOG_LEVELS.LOG))
|
|
104
164
|
return;
|
|
105
165
|
const loggerDto = this.initializeLogger(logger_constants_1.LOG_LEVELS.INFO, message, ...optionalParams);
|
|
106
166
|
this.logger.log(loggerDto);
|
|
107
167
|
}
|
|
168
|
+
/**
|
|
169
|
+
* Logs an error message.
|
|
170
|
+
* Use for logging error conditions and failures.
|
|
171
|
+
*
|
|
172
|
+
* @param message - Error message (any type)
|
|
173
|
+
* @param optionalParams - Additional parameters (last one becomes component name)
|
|
174
|
+
*
|
|
175
|
+
* @example
|
|
176
|
+
* ```typescript
|
|
177
|
+
* logger.error('Database connection failed');
|
|
178
|
+
* logger.error('Query error', 'DatabaseService');
|
|
179
|
+
* logger.error(new Error('Something went wrong'));
|
|
180
|
+
* ```
|
|
181
|
+
*/
|
|
108
182
|
error(message, ...optionalParams) {
|
|
109
183
|
if (!logUtil.isLevelEnable(logger_constants_1.LOG_LEVELS.ERROR))
|
|
110
184
|
return;
|
|
111
185
|
const loggerDto = this.initializeLogger(logger_constants_1.LOG_LEVELS.ERROR, message, ...optionalParams);
|
|
112
186
|
this.logger.log(loggerDto);
|
|
113
187
|
}
|
|
188
|
+
/**
|
|
189
|
+
* Logs a warning message.
|
|
190
|
+
* Use for potentially harmful situations or deprecated functionality.
|
|
191
|
+
*
|
|
192
|
+
* @param message - Warning message (any type)
|
|
193
|
+
* @param optionalParams - Additional parameters (last one becomes component name)
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* ```typescript
|
|
197
|
+
* logger.warn('API rate limit approaching');
|
|
198
|
+
* logger.warn('Using deprecated method', 'PaymentService');
|
|
199
|
+
* ```
|
|
200
|
+
*/
|
|
114
201
|
warn(message, ...optionalParams) {
|
|
115
202
|
if (!logUtil.isLevelEnable(logger_constants_1.LOG_LEVELS.WARN))
|
|
116
203
|
return;
|
|
117
204
|
const loggerDto = this.initializeLogger(logger_constants_1.LOG_LEVELS.WARN, message, ...optionalParams);
|
|
118
205
|
this.logger.log(loggerDto);
|
|
119
206
|
}
|
|
207
|
+
/**
|
|
208
|
+
* Logs a debug message.
|
|
209
|
+
* Use for detailed diagnostic information during development.
|
|
210
|
+
*
|
|
211
|
+
* @param message - Debug message (any type)
|
|
212
|
+
* @param optionalParams - Additional parameters (last one becomes component name)
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* ```typescript
|
|
216
|
+
* logger.debug('Processing request payload');
|
|
217
|
+
* logger.debug({ requestId: '123', payload: data }, 'RequestHandler');
|
|
218
|
+
* ```
|
|
219
|
+
*/
|
|
120
220
|
debug(message, ...optionalParams) {
|
|
121
221
|
if (!logUtil.isLevelEnable(logger_constants_1.LOG_LEVELS.DEBUG))
|
|
122
222
|
return;
|
|
123
223
|
const loggerDto = this.initializeLogger(logger_constants_1.LOG_LEVELS.DEBUG, message, ...optionalParams);
|
|
124
224
|
this.logger.log(loggerDto);
|
|
125
225
|
}
|
|
226
|
+
/**
|
|
227
|
+
* Logs a verbose message.
|
|
228
|
+
* Use for the most detailed information, typically only needed for deep debugging.
|
|
229
|
+
*
|
|
230
|
+
* @param message - Verbose message (any type)
|
|
231
|
+
* @param optionalParams - Additional parameters (last one becomes component name)
|
|
232
|
+
*
|
|
233
|
+
* @example
|
|
234
|
+
* ```typescript
|
|
235
|
+
* logger.verbose('Internal state dump');
|
|
236
|
+
* logger.verbose({ state: internalState }, 'StateMachine');
|
|
237
|
+
* ```
|
|
238
|
+
*/
|
|
126
239
|
verbose(message, ...optionalParams) {
|
|
127
240
|
if (!logUtil.isLevelEnable(logger_constants_1.LOG_LEVELS.VERBOSE))
|
|
128
241
|
return;
|
|
129
242
|
const loggerDto = this.initializeLogger(logger_constants_1.LOG_LEVELS.VERBOSE, message, ...optionalParams);
|
|
130
243
|
this.logger.log(loggerDto);
|
|
131
244
|
}
|
|
245
|
+
/**
|
|
246
|
+
* Flushes the log message to Winston logger.
|
|
247
|
+
*
|
|
248
|
+
* @param message - Message to be logged
|
|
249
|
+
* @protected
|
|
250
|
+
*/
|
|
132
251
|
flushLog(message) {
|
|
133
252
|
this.logger.log(message);
|
|
134
253
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom.logger.js","sourceRoot":"","sources":["../../../src/core/loggers/custom.logger.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAyD;AACzD,oDAA4B;AAC5B,uCAAyB;AACzB,iDAAmC;AACnC,wDAAoD;AACpD,uEAA8E;AAE9E,qFAAwF;AACxF,kEAAoD;AAEpD,IAAa,YAAY,GAAzB,MAAa,YAAY;
|
|
1
|
+
{"version":3,"file":"custom.logger.js","sourceRoot":"","sources":["../../../src/core/loggers/custom.logger.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAyD;AACzD,oDAA4B;AAC5B,uCAAyB;AACzB,iDAAmC;AACnC,wDAAoD;AACpD,uEAA8E;AAE9E,qFAAwF;AACxF,kEAAoD;AAEpD;;;;;;;;;;;;;;;;;;GAkBG;AACH,IAAa,YAAY,GAAzB,MAAa,YAAY;IAcW;IAb1B,MAAM,CAAiB;IACZ,cAAc,CAAS;IAI1C;;;;;;;OAOG;IACH,YAAkC,UAAkB,iCAAc,CAAC,gBAAgB;QAAjD,YAAO,GAAP,OAAO,CAA0C;QACjF,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;YACjC,KAAK,EAAE,OAAO;YACd,UAAU,EAAE,CAAC,IAAI,OAAO,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;SAC/C,CAAC,CAAC;QACH,IAAI,CAAC,cAAc,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC;IACtC,CAAC;IAED;;;;;;OAMG;IACO,UAAU,CAAC,IAAU;QAC7B,OAAO,IAAA,gBAAM,EAAC,IAAI,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,4BAA4B,CAAC,CAAC;IAC9E,CAAC;IAED;;;;;;;;;;;OAWG;IACK,gBAAgB,CACtB,KAAa,EACb,OAAY,EACZ,GAAG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K,CAAC,OAAY,EAAE,GAAG,cAAqB;QAC1C,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,6BAAU,CAAC,KAAK,CAAC;YAAE,OAAO;QACrD,MAAM,SAAS,GAAG,IAAI,CAAC,gBAAgB,CAAC,6BAAU,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,cAAc,CAAC,CAAC;QACtF,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAC7B,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,OAAY,EAAE,GAAG,cAAqB;QAC5C,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,6BAAU,CAAC,OAAO,CAAC;YAAE,OAAO;QACvD,MAAM,SAAS,GAAG,IAAI,CAAC,gBAAgB,CAAC,6BAAU,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,cAAc,CAAC,CAAC;QACxF,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAC7B,CAAC;IAED;;;;;OAKG;IACO,QAAQ,CAAC,OAAY;QAC7B,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC3B,CAAC;CACF,CAAA;AAzLY,oCAAY;uBAAZ,YAAY;IAcV,WAAA,IAAA,iBAAQ,GAAE,CAAA;;GAdZ,YAAY,CAyLxB"}
|
|
@@ -1 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formats the current date and time to ISO 8601 format with UTC+7 timezone offset.
|
|
3
|
+
*
|
|
4
|
+
* Returns a string representation of the current timestamp in the format:
|
|
5
|
+
* `YYYY-MM-DDTHH:mm:ss.SSSZ` (e.g., "2026-01-12T15:30:45.123Z")
|
|
6
|
+
*
|
|
7
|
+
* The timestamp is adjusted to UTC+7 timezone (Bangkok/Jakarta timezone).
|
|
8
|
+
*
|
|
9
|
+
* @returns ISO 8601 formatted timestamp string with UTC+7 offset
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const timestamp = dateFormat();
|
|
14
|
+
* console.log(timestamp); // "2026-01-12T15:30:45.123Z"
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* // Use in logging
|
|
20
|
+
* const dto = new LoggerDto();
|
|
21
|
+
* dto.timestamp = dateFormat();
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
1
24
|
export declare function dateFormat(): string;
|
|
@@ -5,6 +5,29 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.dateFormat = dateFormat;
|
|
7
7
|
const moment_1 = __importDefault(require("moment"));
|
|
8
|
+
/**
|
|
9
|
+
* Formats the current date and time to ISO 8601 format with UTC+7 timezone offset.
|
|
10
|
+
*
|
|
11
|
+
* Returns a string representation of the current timestamp in the format:
|
|
12
|
+
* `YYYY-MM-DDTHH:mm:ss.SSSZ` (e.g., "2026-01-12T15:30:45.123Z")
|
|
13
|
+
*
|
|
14
|
+
* The timestamp is adjusted to UTC+7 timezone (Bangkok/Jakarta timezone).
|
|
15
|
+
*
|
|
16
|
+
* @returns ISO 8601 formatted timestamp string with UTC+7 offset
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const timestamp = dateFormat();
|
|
21
|
+
* console.log(timestamp); // "2026-01-12T15:30:45.123Z"
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* // Use in logging
|
|
27
|
+
* const dto = new LoggerDto();
|
|
28
|
+
* dto.timestamp = dateFormat();
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
8
31
|
function dateFormat() {
|
|
9
32
|
return (0, moment_1.default)(new Date())
|
|
10
33
|
.utcOffset('+0700')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datetime.helper.js","sourceRoot":"","sources":["../../src/helpers/datetime.helper.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"datetime.helper.js","sourceRoot":"","sources":["../../src/helpers/datetime.helper.ts"],"names":[],"mappings":";;;;;AAyBA,gCAIC;AA7BD,oDAA4B;AAE5B;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,SAAgB,UAAU;IACxB,OAAO,IAAA,gBAAM,EAAC,IAAI,IAAI,EAAE,CAAC;SACtB,SAAS,CAAC,OAAO,CAAC;SAClB,MAAM,CAAC,4BAA4B,CAAC,CAAC;AAC1C,CAAC"}
|
|
@@ -1,3 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if a specific log level is enabled based on the LOG_LEVEL environment variable.
|
|
3
|
+
*
|
|
4
|
+
* The LOG_LEVEL environment variable should contain a comma-separated list of enabled levels.
|
|
5
|
+
* Common log levels: 'debug', 'info', 'log', 'warn', 'error', 'verbose'
|
|
6
|
+
*
|
|
7
|
+
* @param level - The log level to check (e.g., 'info', 'debug', 'error')
|
|
8
|
+
* @returns True if the level is enabled, false otherwise
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* process.env.LOG_LEVEL = 'info,error,warn';
|
|
13
|
+
*
|
|
14
|
+
* if (isLevelEnable('debug')) {
|
|
15
|
+
* // Won't execute - debug is not enabled
|
|
16
|
+
* console.log('Debug info');
|
|
17
|
+
* }
|
|
18
|
+
*
|
|
19
|
+
* if (isLevelEnable('info')) {
|
|
20
|
+
* // Will execute - info is enabled
|
|
21
|
+
* console.log('Info message');
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
1
25
|
export declare function isLevelEnable(level: string): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* JSON replacer function that masks sensitive field values.
|
|
28
|
+
*
|
|
29
|
+
* Used with JSON.stringify to automatically replace sensitive field values with '*****'.
|
|
30
|
+
* Sensitive fields are configured via the LOG_MASK_KEYS environment variable.
|
|
31
|
+
*
|
|
32
|
+
* @param key - The property key being stringified
|
|
33
|
+
* @param value - The property value being stringified
|
|
34
|
+
* @returns The original value if not sensitive, or '*****' if the key is in the mask list
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* process.env.LOG_MASK_KEYS = 'password,apiKey,secret';
|
|
39
|
+
*
|
|
40
|
+
* const data = {
|
|
41
|
+
* username: 'john',
|
|
42
|
+
* password: 'secret123',
|
|
43
|
+
* apiKey: 'abc-def-ghi'
|
|
44
|
+
* };
|
|
45
|
+
*
|
|
46
|
+
* const masked = JSON.stringify(data, maskMessageReplacer);
|
|
47
|
+
* // {"username":"john","password":"*****","apiKey":"*****"}
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* @see logStringify
|
|
51
|
+
*/
|
|
2
52
|
export declare function maskMessageReplacer(key: string, value: any): any;
|
|
53
|
+
/**
|
|
54
|
+
* Converts any value to a string with automatic masking of sensitive fields.
|
|
55
|
+
*
|
|
56
|
+
* Handles various input types:
|
|
57
|
+
* - Strings: returned as-is
|
|
58
|
+
* - Objects: JSON stringified with automatic masking via maskMessageReplacer
|
|
59
|
+
* - Others: converted using String()
|
|
60
|
+
*
|
|
61
|
+
* Sensitive fields are masked based on the LOG_MASK_KEYS environment variable.
|
|
62
|
+
*
|
|
63
|
+
* @param message - The value to stringify (can be any type)
|
|
64
|
+
* @returns String representation of the message with sensitive fields masked
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```typescript
|
|
68
|
+
* process.env.LOG_MASK_KEYS = 'password,token';
|
|
69
|
+
*
|
|
70
|
+
* // String input
|
|
71
|
+
* logStringify('Hello'); // "Hello"
|
|
72
|
+
*
|
|
73
|
+
* // Object with sensitive data
|
|
74
|
+
* const user = { name: 'John', password: 'secret' };
|
|
75
|
+
* logStringify(user); // '{"name":"John","password":"*****"}'
|
|
76
|
+
*
|
|
77
|
+
* // Nested objects
|
|
78
|
+
* const data = { user: { token: 'abc123' }, message: 'test' };
|
|
79
|
+
* logStringify(data); // '{"user":{"token":"*****"},"message":"test"}'
|
|
80
|
+
* ```
|
|
81
|
+
*
|
|
82
|
+
* @see maskMessageReplacer
|
|
83
|
+
*/
|
|
3
84
|
export declare function logStringify(message: any): string;
|