@heavybit/logger-ts 3.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.
@@ -0,0 +1,8 @@
1
+ export { initLogger, getLogger, createLogger, formatLogEntry, default as logger, } from './lib/logger';
2
+ export { initConfig, getConfig, resetConfig, mergeConfig, createDefaultConfig, getLogLevelForClass, DEFAULT_SENSITIVE_FIELDS, DEFAULT_CLASS_LEVELS, } from './config';
3
+ export { AOPLogger, default as aopLogger } from './lib/aopLogger';
4
+ export { logMethodsWithAOP, LogMethod, LogClass, wrapRoutesWithLogging, withLogging, } from './lib/aopLoggerUtils';
5
+ export { createLoggingMiddleware, loggingMiddleware, errorLoggingMiddleware, morganStyleMiddleware, default as loggingMiddlewareDefault, } from './middleware/loggingMiddleware';
6
+ export { sanitizeData, sanitizeHeaders, truncateValue, prepareForLogging, } from './utils/sanitize';
7
+ export type { LogLevel, ClassType, LogTarget, FileLogConfig, ConsoleLogConfig, LoggerConfig, BaseLogEntry, RequestLogEntry, AOPContext, AdviceType, AdvicePhase, AdviceFunction, LoggingRequest, LoggingMiddleware, MiddlewareOptions, ExtendedLogger, SanitizableObject, FormattedLogEntry, LoggerEnvVars, } from './types';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,UAAU,EACV,SAAS,EACT,YAAY,EACZ,cAAc,EACd,OAAO,IAAI,MAAM,GAClB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,UAAU,EACV,SAAS,EACT,WAAW,EACX,WAAW,EACX,mBAAmB,EACnB,mBAAmB,EACnB,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,UAAU,CAAC;AAGlB,OAAO,EAAE,SAAS,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAElE,OAAO,EACL,iBAAiB,EACjB,SAAS,EACT,QAAQ,EACR,qBAAqB,EACrB,WAAW,GACZ,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EACL,uBAAuB,EACvB,iBAAiB,EACjB,sBAAsB,EACtB,qBAAqB,EACrB,OAAO,IAAI,wBAAwB,GACpC,MAAM,gCAAgC,CAAC;AAGxC,OAAO,EACL,YAAY,EACZ,eAAe,EACf,aAAa,EACb,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAG1B,YAAY,EAEV,QAAQ,EACR,SAAS,EACT,SAAS,EACT,aAAa,EACb,gBAAgB,EAChB,YAAY,EAGZ,YAAY,EACZ,eAAe,EACf,UAAU,EACV,UAAU,EACV,WAAW,EACX,cAAc,EAGd,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EAGjB,cAAc,EAGd,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,GACd,MAAM,SAAS,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ // Main entry point for the logger package
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.prepareForLogging = exports.truncateValue = exports.sanitizeHeaders = exports.sanitizeData = exports.loggingMiddlewareDefault = exports.morganStyleMiddleware = exports.errorLoggingMiddleware = exports.loggingMiddleware = exports.createLoggingMiddleware = exports.withLogging = exports.wrapRoutesWithLogging = exports.LogClass = exports.LogMethod = exports.logMethodsWithAOP = exports.aopLogger = exports.AOPLogger = exports.DEFAULT_CLASS_LEVELS = exports.DEFAULT_SENSITIVE_FIELDS = exports.getLogLevelForClass = exports.createDefaultConfig = exports.mergeConfig = exports.resetConfig = exports.getConfig = exports.initConfig = exports.logger = exports.formatLogEntry = exports.createLogger = exports.getLogger = exports.initLogger = void 0;
8
+ // Logger and configuration
9
+ var logger_1 = require("./lib/logger");
10
+ Object.defineProperty(exports, "initLogger", { enumerable: true, get: function () { return logger_1.initLogger; } });
11
+ Object.defineProperty(exports, "getLogger", { enumerable: true, get: function () { return logger_1.getLogger; } });
12
+ Object.defineProperty(exports, "createLogger", { enumerable: true, get: function () { return logger_1.createLogger; } });
13
+ Object.defineProperty(exports, "formatLogEntry", { enumerable: true, get: function () { return logger_1.formatLogEntry; } });
14
+ Object.defineProperty(exports, "logger", { enumerable: true, get: function () { return __importDefault(logger_1).default; } });
15
+ var config_1 = require("./config");
16
+ Object.defineProperty(exports, "initConfig", { enumerable: true, get: function () { return config_1.initConfig; } });
17
+ Object.defineProperty(exports, "getConfig", { enumerable: true, get: function () { return config_1.getConfig; } });
18
+ Object.defineProperty(exports, "resetConfig", { enumerable: true, get: function () { return config_1.resetConfig; } });
19
+ Object.defineProperty(exports, "mergeConfig", { enumerable: true, get: function () { return config_1.mergeConfig; } });
20
+ Object.defineProperty(exports, "createDefaultConfig", { enumerable: true, get: function () { return config_1.createDefaultConfig; } });
21
+ Object.defineProperty(exports, "getLogLevelForClass", { enumerable: true, get: function () { return config_1.getLogLevelForClass; } });
22
+ Object.defineProperty(exports, "DEFAULT_SENSITIVE_FIELDS", { enumerable: true, get: function () { return config_1.DEFAULT_SENSITIVE_FIELDS; } });
23
+ Object.defineProperty(exports, "DEFAULT_CLASS_LEVELS", { enumerable: true, get: function () { return config_1.DEFAULT_CLASS_LEVELS; } });
24
+ // AOP Logger
25
+ var aopLogger_1 = require("./lib/aopLogger");
26
+ Object.defineProperty(exports, "AOPLogger", { enumerable: true, get: function () { return aopLogger_1.AOPLogger; } });
27
+ Object.defineProperty(exports, "aopLogger", { enumerable: true, get: function () { return __importDefault(aopLogger_1).default; } });
28
+ var aopLoggerUtils_1 = require("./lib/aopLoggerUtils");
29
+ Object.defineProperty(exports, "logMethodsWithAOP", { enumerable: true, get: function () { return aopLoggerUtils_1.logMethodsWithAOP; } });
30
+ Object.defineProperty(exports, "LogMethod", { enumerable: true, get: function () { return aopLoggerUtils_1.LogMethod; } });
31
+ Object.defineProperty(exports, "LogClass", { enumerable: true, get: function () { return aopLoggerUtils_1.LogClass; } });
32
+ Object.defineProperty(exports, "wrapRoutesWithLogging", { enumerable: true, get: function () { return aopLoggerUtils_1.wrapRoutesWithLogging; } });
33
+ Object.defineProperty(exports, "withLogging", { enumerable: true, get: function () { return aopLoggerUtils_1.withLogging; } });
34
+ // Middleware
35
+ var loggingMiddleware_1 = require("./middleware/loggingMiddleware");
36
+ Object.defineProperty(exports, "createLoggingMiddleware", { enumerable: true, get: function () { return loggingMiddleware_1.createLoggingMiddleware; } });
37
+ Object.defineProperty(exports, "loggingMiddleware", { enumerable: true, get: function () { return loggingMiddleware_1.loggingMiddleware; } });
38
+ Object.defineProperty(exports, "errorLoggingMiddleware", { enumerable: true, get: function () { return loggingMiddleware_1.errorLoggingMiddleware; } });
39
+ Object.defineProperty(exports, "morganStyleMiddleware", { enumerable: true, get: function () { return loggingMiddleware_1.morganStyleMiddleware; } });
40
+ Object.defineProperty(exports, "loggingMiddlewareDefault", { enumerable: true, get: function () { return __importDefault(loggingMiddleware_1).default; } });
41
+ // Utilities
42
+ var sanitize_1 = require("./utils/sanitize");
43
+ Object.defineProperty(exports, "sanitizeData", { enumerable: true, get: function () { return sanitize_1.sanitizeData; } });
44
+ Object.defineProperty(exports, "sanitizeHeaders", { enumerable: true, get: function () { return sanitize_1.sanitizeHeaders; } });
45
+ Object.defineProperty(exports, "truncateValue", { enumerable: true, get: function () { return sanitize_1.truncateValue; } });
46
+ Object.defineProperty(exports, "prepareForLogging", { enumerable: true, get: function () { return sanitize_1.prepareForLogging; } });
47
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,0CAA0C;;;;;;AAE1C,2BAA2B;AAC3B,uCAMsB;AALpB,oGAAA,UAAU,OAAA;AACV,mGAAA,SAAS,OAAA;AACT,sGAAA,YAAY,OAAA;AACZ,wGAAA,cAAc,OAAA;AACd,iHAAA,OAAO,OAAU;AAGnB,mCASkB;AARhB,oGAAA,UAAU,OAAA;AACV,mGAAA,SAAS,OAAA;AACT,qGAAA,WAAW,OAAA;AACX,qGAAA,WAAW,OAAA;AACX,6GAAA,mBAAmB,OAAA;AACnB,6GAAA,mBAAmB,OAAA;AACnB,kHAAA,wBAAwB,OAAA;AACxB,8GAAA,oBAAoB,OAAA;AAGtB,aAAa;AACb,6CAAkE;AAAzD,sGAAA,SAAS,OAAA;AAAE,uHAAA,OAAO,OAAa;AAExC,uDAM8B;AAL5B,mHAAA,iBAAiB,OAAA;AACjB,2GAAA,SAAS,OAAA;AACT,0GAAA,QAAQ,OAAA;AACR,uHAAA,qBAAqB,OAAA;AACrB,6GAAA,WAAW,OAAA;AAGb,aAAa;AACb,oEAMwC;AALtC,4HAAA,uBAAuB,OAAA;AACvB,sHAAA,iBAAiB,OAAA;AACjB,2HAAA,sBAAsB,OAAA;AACtB,0HAAA,qBAAqB,OAAA;AACrB,8IAAA,OAAO,OAA4B;AAGrC,YAAY;AACZ,6CAK0B;AAJxB,wGAAA,YAAY,OAAA;AACZ,2GAAA,eAAe,OAAA;AACf,yGAAA,aAAa,OAAA;AACb,6GAAA,iBAAiB,OAAA"}
@@ -0,0 +1,44 @@
1
+ import { Request, Response, NextFunction } from 'express';
2
+ import { AOPContext, AdviceType, AdvicePhase, AdviceFunction, ClassType, LogLevel } from '../types';
3
+ /**
4
+ * Type for Express route handler
5
+ */
6
+ type ExpressHandler = (req: Request, res: Response, next: NextFunction) => Promise<void> | void;
7
+ /**
8
+ * Type for generic async method
9
+ */
10
+ type AsyncMethod = (...args: unknown[]) => Promise<unknown>;
11
+ /**
12
+ * AOPLogger - Aspect-Oriented Programming Logger for Express.js
13
+ *
14
+ * Provides method interception and logging capabilities for Express applications.
15
+ * Supports before, after, and around advice types for comprehensive logging.
16
+ */
17
+ export declare class AOPLogger {
18
+ /**
19
+ * Log level mapping for different class types
20
+ */
21
+ static logLevelMapping: Record<ClassType, LogLevel>;
22
+ /**
23
+ * Apply advice to a method of an object
24
+ */
25
+ static applyAdvice<T extends Record<string, ExpressHandler | AsyncMethod>>(object: T, methodName: keyof T & string, className: string, methodType: string, adviceType: AdviceType, adviceFunction: AdviceFunction, classType: ClassType): void;
26
+ /**
27
+ * Determine the class type dynamically based on class name
28
+ */
29
+ static getClassType(object: unknown): ClassType;
30
+ /**
31
+ * Log request details based on context and phase
32
+ */
33
+ static logRequestDetails(context: AOPContext, phase: AdvicePhase): void;
34
+ /**
35
+ * Log a single method call dynamically using the logger
36
+ */
37
+ static logMethodCall<T extends Record<string, ExpressHandler | AsyncMethod>>(object: T, methodName: keyof T & string, className: string, methodType?: string, adviceType?: AdviceType, classType?: ClassType): void;
38
+ /**
39
+ * Log all method calls on an object dynamically using the logger
40
+ */
41
+ static logAllMethods<T extends Record<string, ExpressHandler | AsyncMethod>>(object: T, methodNames: (keyof T & string)[], className?: string, adviceType?: AdviceType, classType?: ClassType): void;
42
+ }
43
+ export default AOPLogger;
44
+ //# sourceMappingURL=aopLogger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aopLogger.d.ts","sourceRoot":"","sources":["../../src/lib/aopLogger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,EACL,UAAU,EACV,UAAU,EACV,WAAW,EACX,cAAc,EACd,SAAS,EACT,QAAQ,EACT,MAAM,UAAU,CAAC;AAIlB;;GAEG;AACH,KAAK,cAAc,GAAG,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AAEhG;;GAEG;AACH,KAAK,WAAW,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAE5D;;;;;GAKG;AACH,qBAAa,SAAS;IACpB;;OAEG;IACH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+ const logger_1 = require("./logger");
5
+ const config_1 = require("../config");
6
+ /**
7
+ * AOPLogger - Aspect-Oriented Programming Logger for Express.js
8
+ *
9
+ * Provides method interception and logging capabilities for Express applications.
10
+ * Supports before, after, and around advice types for comprehensive logging.
11
+ */
12
+ class AOPLogger {
13
+ /**
14
+ * Apply advice to a method of an object
15
+ */
16
+ static applyAdvice(object, methodName, className, methodType, adviceType, adviceFunction, classType) {
17
+ const originalMethod = object[methodName];
18
+ if (!originalMethod) {
19
+ throw new Error(`Method ${methodName} does not exist on the object.`);
20
+ }
21
+ object[methodName] = async function (...args) {
22
+ const req = args[0];
23
+ const res = args[1];
24
+ const context = {
25
+ methodName,
26
+ methodType,
27
+ classType,
28
+ className: className || this?.constructor?.name || 'Unknown',
29
+ startTime: Date.now(),
30
+ };
31
+ // Add request data to context
32
+ if (req?.originalUrl) {
33
+ context.url = req.originalUrl;
34
+ }
35
+ if (req?.method) {
36
+ context.method = req.method;
37
+ }
38
+ // Apply 'before' advice
39
+ if (methodType !== 'getAll' &&
40
+ methodType !== 'getSingle' &&
41
+ (adviceType === 'before' || adviceType === 'around')) {
42
+ if (req?.body) {
43
+ context.body = req.body;
44
+ }
45
+ adviceFunction(context, 'before');
46
+ }
47
+ // Capture response body
48
+ let responseBody = '';
49
+ const originalWrite = res?.write?.bind(res);
50
+ const originalEnd = res?.end?.bind(res);
51
+ if (typeof res === 'object' && typeof res?.write === 'function') {
52
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
53
+ res.write = function (chunk, ...args) {
54
+ if (chunk) {
55
+ responseBody += String(chunk);
56
+ }
57
+ return originalWrite(chunk, ...args);
58
+ };
59
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
60
+ res.end = function (chunk, ...args) {
61
+ if (chunk && typeof chunk !== 'function') {
62
+ responseBody += String(chunk);
63
+ }
64
+ let parsedResponseBody;
65
+ try {
66
+ parsedResponseBody = JSON.parse(responseBody);
67
+ }
68
+ catch {
69
+ parsedResponseBody = responseBody;
70
+ }
71
+ // Extract data property if exists
72
+ if (parsedResponseBody &&
73
+ typeof parsedResponseBody === 'object' &&
74
+ 'data' in parsedResponseBody) {
75
+ context.responseBody = parsedResponseBody.data;
76
+ }
77
+ else {
78
+ context.responseBody = parsedResponseBody;
79
+ }
80
+ context.statusCode = res.statusCode;
81
+ if (parsedResponseBody &&
82
+ typeof parsedResponseBody === 'object' &&
83
+ 'message' in parsedResponseBody) {
84
+ context.message = parsedResponseBody.message;
85
+ }
86
+ // Apply 'after' advice after response is finalized
87
+ if (adviceType === 'after' || adviceType === 'around') {
88
+ context.result = context.responseBody;
89
+ context.endTime = Date.now();
90
+ context.executionTime = context.endTime - context.startTime;
91
+ adviceFunction(context, 'after');
92
+ }
93
+ return originalEnd(chunk, ...args);
94
+ };
95
+ }
96
+ try {
97
+ const result = await originalMethod.apply(this, args);
98
+ context.result = result;
99
+ context.logType = 'info';
100
+ return result;
101
+ }
102
+ catch (error) {
103
+ context.error = error;
104
+ context.statusCode = error.statusCode || 500;
105
+ context.message = error?.message || context.message;
106
+ context.logType = 'error';
107
+ // Log the error
108
+ adviceFunction(context, 'error');
109
+ throw error;
110
+ }
111
+ };
112
+ }
113
+ /**
114
+ * Determine the class type dynamically based on class name
115
+ */
116
+ static getClassType(object) {
117
+ const className = (object?.constructor?.name || '').toLowerCase();
118
+ if (className.includes('controller'))
119
+ return 'controllers';
120
+ if (className.includes('service'))
121
+ return 'services';
122
+ if (className.includes('repository'))
123
+ return 'repositories';
124
+ if (className.includes('util'))
125
+ return 'utils';
126
+ if (className.includes('middleware'))
127
+ return 'middleware';
128
+ if (className.includes('route'))
129
+ return 'routes';
130
+ if (className.includes('config'))
131
+ return 'configuration';
132
+ if (className.includes('validator'))
133
+ return 'validators';
134
+ if (className.includes('listener') || className.includes('event'))
135
+ return 'eventListeners';
136
+ if (className.includes('helper'))
137
+ return 'helpers';
138
+ if (className.includes('job') || className.includes('task'))
139
+ return 'jobs';
140
+ if (className.includes('model'))
141
+ return 'models';
142
+ if (className.includes('transformer'))
143
+ return 'transformers';
144
+ return 'unknown';
145
+ }
146
+ /**
147
+ * Log request details based on context and phase
148
+ */
149
+ static logRequestDetails(context, phase) {
150
+ const logger = (0, logger_1.getLogger)();
151
+ const config = (0, config_1.getConfig)();
152
+ if (!context.statusCode)
153
+ context.statusCode = 200;
154
+ // Set log level based on class type
155
+ if (!context.level) {
156
+ context.level = (0, config_1.getLogLevelForClass)(config, context.classType);
157
+ }
158
+ // Base log data shared across phases
159
+ const baseLogData = {
160
+ className: context.className,
161
+ method: context.method,
162
+ methodName: context.methodName,
163
+ url: context.url || '',
164
+ level: context.level,
165
+ logType: context.logType,
166
+ timestamp: new Date().toISOString(),
167
+ };
168
+ // Handle getAll and getSingle method types
169
+ if (context.methodType === 'getAll' || context.methodType === 'getSingle') {
170
+ if (phase === 'error') {
171
+ logger.error({
172
+ ...baseLogData,
173
+ message: context.message
174
+ ? `Request completed: ${context.methodName} - ${context.message}`
175
+ : `Request completed: ${context.methodName}`,
176
+ error: context.error,
177
+ statusCode: context.statusCode || 500,
178
+ });
179
+ }
180
+ if (phase === 'after' && context.statusCode >= 400) {
181
+ if (context.statusCode === 404) {
182
+ logger.error({
183
+ ...baseLogData,
184
+ message: `Resource not found: ${context.methodName} for URL ${context.url}`,
185
+ statusCode: context.statusCode,
186
+ responseTime: `${context.executionTime}ms`,
187
+ });
188
+ }
189
+ else {
190
+ logger.error({
191
+ ...baseLogData,
192
+ message: `Server error during ${context.methodName}: ${context.message || 'Unexpected error'}`,
193
+ statusCode: context.statusCode,
194
+ responseTime: `${context.executionTime}ms`,
195
+ error: context.error,
196
+ });
197
+ }
198
+ }
199
+ }
200
+ else {
201
+ if (phase === 'after') {
202
+ // Standard logging for successful responses
203
+ logger.log(context.level, {
204
+ ...baseLogData,
205
+ message: context.message
206
+ ? `Request completed: ${context.methodName} - ${context.message}`
207
+ : `Request completed: ${context.methodName}`,
208
+ statusCode: context.statusCode,
209
+ responseTime: `${context.executionTime}ms`,
210
+ body: context.result,
211
+ });
212
+ }
213
+ else if (phase === 'error') {
214
+ logger.error({
215
+ ...baseLogData,
216
+ message: context.message
217
+ ? `Request failed: ${context.methodName} - ${context.message}`
218
+ : `Request failed: ${context.methodName}`,
219
+ error: context.error,
220
+ statusCode: context.statusCode || 500,
221
+ });
222
+ }
223
+ else if (phase === 'before') {
224
+ if (context.methodType !== 'getAll' && context.methodType !== 'getSingle') {
225
+ logger.log(context.level, {
226
+ ...baseLogData,
227
+ message: `Request started: ${context.methodName}`,
228
+ body: context.body,
229
+ });
230
+ }
231
+ }
232
+ }
233
+ }
234
+ /**
235
+ * Log a single method call dynamically using the logger
236
+ */
237
+ static logMethodCall(object, methodName, className, methodType = '', adviceType = 'around', classType) {
238
+ this.applyAdvice(object, methodName, className, methodType, adviceType, this.logRequestDetails.bind(this), classType || this.getClassType(object));
239
+ }
240
+ /**
241
+ * Log all method calls on an object dynamically using the logger
242
+ */
243
+ static logAllMethods(object, methodNames, className = '', adviceType = 'around', classType) {
244
+ methodNames.forEach((methodName) => this.logMethodCall(object, methodName, className, '', adviceType, classType));
245
+ }
246
+ }
247
+ exports.AOPLogger = AOPLogger;
248
+ /**
249
+ * Log level mapping for different class types
250
+ */
251
+ AOPLogger.logLevelMapping = {
252
+ controllers: process.env.LOG_LEVEL_CONTROLLERS || 'info',
253
+ services: process.env.LOG_LEVEL_SERVICES || 'error',
254
+ repositories: process.env.LOG_LEVEL_REPOSITORIES || 'debug',
255
+ utils: process.env.LOG_LEVEL_UTILS || 'warn',
256
+ middleware: process.env.LOG_LEVEL_MIDDLEWARE || 'info',
257
+ routes: process.env.LOG_LEVEL_ROUTES || 'info',
258
+ configuration: process.env.LOG_LEVEL_CONFIGURATION || 'debug',
259
+ validators: process.env.LOG_LEVEL_VALIDATORS || 'info',
260
+ eventListeners: process.env.LOG_LEVEL_EVENT_LISTENERS || 'debug',
261
+ helpers: process.env.LOG_LEVEL_HELPERS || 'debug',
262
+ jobs: process.env.LOG_LEVEL_JOBS || 'debug',
263
+ models: process.env.LOG_LEVEL_MODELS || 'info',
264
+ transformers: process.env.LOG_LEVEL_TRANSFORMERS || 'debug',
265
+ default: process.env.LOG_LEVEL_DEFAULT || 'info',
266
+ unknown: 'info',
267
+ };
268
+ exports.default = AOPLogger;
269
+ //# sourceMappingURL=aopLogger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aopLogger.js","sourceRoot":"","sources":["../../src/lib/aopLogger.ts"],"names":[],"mappings":";;;AASA,qCAAqC;AACrC,sCAA2D;AAY3D;;;;;GAKG;AACH,MAAa,SAAS;IAsBpB;;OAEG;IACH,MAAM,CAAC,WAAW,CAChB,MAAS,EACT,UAA4B,EAC5B,SAAiB,EACjB,UAAkB,EAClB,UAAsB,EACtB,cAA8B,EAC9B,SAAoB;QAEpB,MAAM,cAAc,GAAG,MAAM,CAAC,UAAU,CAAmB,CAAC;QAE5D,IAAI,CAAC,cAAc,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,UAAU,UAAU,gCAAgC,CAAC,CAAC;QACxE,CAAC;QAED,MAAM,CAAC,UAAU,CAAC,GAAG,KAAK,WAExB,GAAG,IAAmD;YAEtD,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAY,CAAC;YAC/B,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAa,CAAC;YAEhC,MAAM,OAAO,GAAe;gBAC1B,UAAU;gBACV,UAAU;gBACV,SAAS;gBACT,SAAS,EAAE,SAAS,IAAK,IAA4C,EAAE,WAAW,EAAE,IAAI,IAAI,SAAS;gBACrG,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;aACtB,CAAC;YAEF,8BAA8B;YAC9B,IAAI,GAAG,EAAE,WAAW,EAAE,CAAC;gBACrB,OAAO,CAAC,GAAG,GAAG,GAAG,CAAC,WAAW,CAAC;YAChC,CAAC;YACD,IAAI,GAAG,EAAE,MAAM,EAAE,CAAC;gBAChB,OAAO,CAAC,MAAM,GAAG,GAAG,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GAAG,CAAC,gBAA6B,IAAI,MAAM;IAC5D,YAAY,EAAG,OAAO,CAAC,GAAG,CAAC,sBAAmC,IAAI,OAAO;IACzE,OAAO,EAAG,OAAO,CAAC,GAAG,CAAC,iBAA8B,IAAI,MAAM;IAC9D,OAAO,EAAE,MAAM;CAChB,CAAC;AA4RJ,kBAAe,SAAS,CAAC"}
@@ -0,0 +1,54 @@
1
+ import { Router, Request, Response, NextFunction } from 'express';
2
+ import { ClassType, AdviceType } from '../types';
3
+ /**
4
+ * Type for Express route handler
5
+ */
6
+ type ExpressHandler = (req: Request, res: Response, next: NextFunction) => Promise<void> | void;
7
+ /**
8
+ * Type for class prototype with methods
9
+ */
10
+ type ClassPrototype = any;
11
+ /**
12
+ * Utility to log all method calls dynamically on a class except excluded methods.
13
+ * Handles error-specific methods (such as getAll) and logs errors accordingly.
14
+ *
15
+ * @param classPrototype - The prototype of the class whose methods are to be logged.
16
+ * @param excludedMethods - Array of method names to be excluded from logging.
17
+ * @param logErrorsOnly - Array of methods to log only errors (e.g., getAll).
18
+ * @param className - The name of the class for logging context.
19
+ * @param classType - The type of the class (optional).
20
+ * @param adviceType - The type of advice (optional, defaults to "around").
21
+ */
22
+ export declare function logMethodsWithAOP(classPrototype: ClassPrototype, excludedMethods: string[] | undefined, logErrorsOnly: string[] | undefined, className: string, classType?: ClassType, adviceType?: AdviceType): void;
23
+ /**
24
+ * Decorator for logging method calls (for use with TypeScript decorators)
25
+ *
26
+ * @param className - The class name for logging context
27
+ * @param methodType - The method type (optional)
28
+ * @param adviceType - The advice type (default: 'around')
29
+ * @param classType - The class type for log level determination
30
+ */
31
+ export declare function LogMethod(className?: string, methodType?: string, adviceType?: AdviceType, classType?: ClassType): MethodDecorator;
32
+ /**
33
+ * Decorator for logging all methods in a class
34
+ *
35
+ * @param excludedMethods - Methods to exclude from logging
36
+ * @param logErrorsOnly - Methods that only log errors
37
+ * @param classType - The class type for log level determination
38
+ */
39
+ export declare function LogClass(excludedMethods?: string[], logErrorsOnly?: string[], classType?: ClassType): <T extends new (...args: unknown[]) => object>(constructor: T) => T;
40
+ /**
41
+ * Wraps all route handlers in a router with AOP logging.
42
+ *
43
+ * @param router - The Express router object.
44
+ * @param className - The class name or context name for logging.
45
+ * @param classType - The type of the class (e.g., "routes", "controller").
46
+ * @param logErrorsOnly - Methods that should only log on errors.
47
+ */
48
+ export declare function wrapRoutesWithLogging(router: Router, className: string, classType?: ClassType, logErrorsOnly?: string[]): void;
49
+ /**
50
+ * Create a wrapped handler with logging
51
+ */
52
+ export declare function withLogging(handler: ExpressHandler, methodName: string, className?: string, classType?: ClassType): ExpressHandler;
53
+ export {};
54
+ //# sourceMappingURL=aopLoggerUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aopLoggerUtils.d.ts","sourceRoot":"","sources":["../../src/lib/aopLoggerUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAElE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAc,MAAM,UAAU,CAAC;AAE7D;;GAEG;AACH,KAAK,cAAc,GAAG,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AAEhG;;GAEG;AAEH,KAAK,cAAc,GAAG,GAAG,CAAC;AAE1B;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAC/B,cAAc,EAAE,cAAc,EAC9B,eAAe,EAAE,MAAM,EAAE,YAAK,EAC9B,aAAa,EAAE,MAAM,EAAE,YAAK,EAC5B,SAAS,EAAE,MAAM,EACjB,SAAS,CAAC,EAAE,SAAS,EACrB,UAAU,GAAE,UAAqB,GAChC,IAAI,CAsBN;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CACvB,SAAS,CAAC,EAAE,MAAM,EAClB,UAAU,GAAE,M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