nestjs-log-decorator 1.1.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +10 -1
- package/dist/index.d.cts +86 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -438,5 +438,14 @@ const NoLog = () => {
|
|
|
438
438
|
|
|
439
439
|
//#endregion
|
|
440
440
|
exports.Log = Log;
|
|
441
|
+
exports.LogWrapper = LogWrapper;
|
|
442
|
+
exports.NO_LOG_METADATA_KEY = NO_LOG_METADATA_KEY;
|
|
441
443
|
exports.NoLog = NoLog;
|
|
442
|
-
exports.
|
|
444
|
+
exports.applyToClass = applyToClass;
|
|
445
|
+
exports.applyToMethod = applyToMethod;
|
|
446
|
+
exports.buildArgsObject = buildArgsObject;
|
|
447
|
+
exports.createLogWrapper = createLogWrapper;
|
|
448
|
+
exports.getParameterNames = getParameterNames;
|
|
449
|
+
exports.handleAsyncExecution = handleAsyncExecution;
|
|
450
|
+
exports.isLoggable = isLoggable;
|
|
451
|
+
exports.prettifyAxiosError = prettifyAxiosError;
|
package/dist/index.d.cts
CHANGED
|
@@ -29,14 +29,53 @@ interface LogOptions<TArgs extends unknown[] = unknown[]> {
|
|
|
29
29
|
*/
|
|
30
30
|
args?: LogArgsFormatter<TArgs>;
|
|
31
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Symbol used to mark methods that should not be logged
|
|
34
|
+
* @internal
|
|
35
|
+
*/
|
|
36
|
+
declare const NO_LOG_METADATA_KEY: unique symbol;
|
|
32
37
|
//#endregion
|
|
33
38
|
//#region src/LogWrapper.d.ts
|
|
34
|
-
|
|
39
|
+
/**
|
|
40
|
+
* Wrapper class for logging operations with consistent format.
|
|
41
|
+
* @internal
|
|
42
|
+
*/
|
|
43
|
+
declare class LogWrapper {
|
|
44
|
+
private readonly logger;
|
|
45
|
+
private readonly method;
|
|
46
|
+
private readonly args;
|
|
47
|
+
constructor(logger: Logger, method: string, args: string | number | Record<string, unknown> | undefined);
|
|
48
|
+
invoked(): void;
|
|
49
|
+
success(): void;
|
|
50
|
+
error(error: unknown): void;
|
|
51
|
+
}
|
|
35
52
|
/** If you see it, then you probably forgot to add `readonly logger = new Logger(YourClass.name)` to your class */
|
|
36
53
|
interface Loggable {
|
|
37
54
|
logger: Logger;
|
|
38
55
|
}
|
|
39
56
|
declare const isLoggable: (instance: unknown) => instance is Loggable;
|
|
57
|
+
/**
|
|
58
|
+
* Creates a LogWrapper instance with validated logger and built args object.
|
|
59
|
+
* @internal
|
|
60
|
+
*/
|
|
61
|
+
declare const createLogWrapper: (instance: unknown, className: string, methodName: string, argsObject: string | number | Record<string, unknown> | undefined) => LogWrapper;
|
|
62
|
+
/**
|
|
63
|
+
* Builds an object mapping parameter names to their values.
|
|
64
|
+
*
|
|
65
|
+
* Creates a record where keys are parameter names and values are the
|
|
66
|
+
* corresponding argument values passed to the function.
|
|
67
|
+
*
|
|
68
|
+
* @param parameterNames - Array of parameter names
|
|
69
|
+
* @param args - Array of argument values
|
|
70
|
+
* @returns Object mapping parameter names to values
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* buildArgsObject(['id', 'name'], [1, 'John'])
|
|
74
|
+
* // Returns: { id: 1, name: 'John' }
|
|
75
|
+
*
|
|
76
|
+
* @internal
|
|
77
|
+
*/
|
|
78
|
+
declare const buildArgsObject: (parameterNames: string[], args: unknown[]) => Record<string, unknown> | undefined;
|
|
40
79
|
//#endregion
|
|
41
80
|
//#region src/log.decorator.d.ts
|
|
42
81
|
type LoggableConstructor = new (...args: any[]) => Loggable;
|
|
@@ -250,4 +289,49 @@ declare const Log: <TArgs extends unknown[]>(options?: LogOptions<TArgs>) => Log
|
|
|
250
289
|
*/
|
|
251
290
|
declare const NoLog: () => (_target: unknown, _propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
252
291
|
//#endregion
|
|
253
|
-
|
|
292
|
+
//#region src/axios/axios.logger.d.ts
|
|
293
|
+
declare function prettifyAxiosError(error: unknown): unknown;
|
|
294
|
+
//#endregion
|
|
295
|
+
//#region src/decorate/applyToMethod.d.ts
|
|
296
|
+
type MethodFunction = (...args: unknown[]) => unknown;
|
|
297
|
+
/**
|
|
298
|
+
* Applies logging to a single method.
|
|
299
|
+
* @internal
|
|
300
|
+
*/
|
|
301
|
+
declare const applyToMethod: (target: object, propertyKey: string, descriptor: PropertyDescriptor, {
|
|
302
|
+
onInvoke: shouldLogInvoke,
|
|
303
|
+
args: formatArgs
|
|
304
|
+
}?: LogOptions) => PropertyDescriptor;
|
|
305
|
+
/**
|
|
306
|
+
* Extracts parameter names from a function signature.
|
|
307
|
+
*
|
|
308
|
+
* This function parses the function's string representation to extract
|
|
309
|
+
* parameter names, handling TypeScript type annotations and default values.
|
|
310
|
+
*
|
|
311
|
+
* @param func - The function to extract parameter names from
|
|
312
|
+
* @returns Array of parameter names
|
|
313
|
+
*
|
|
314
|
+
* @example
|
|
315
|
+
* function example(id: number, name: string = 'default') {}
|
|
316
|
+
* getParameterNames(example) // Returns: ['id', 'name']
|
|
317
|
+
*
|
|
318
|
+
* @internal
|
|
319
|
+
*/
|
|
320
|
+
declare const getParameterNames: (func: MethodFunction) => string[];
|
|
321
|
+
/**
|
|
322
|
+
* Handles execution of async methods with proper logging.
|
|
323
|
+
* @internal
|
|
324
|
+
*/
|
|
325
|
+
declare const handleAsyncExecution: (result: Promise<unknown>, logWrapper: LogWrapper) => Promise<unknown>;
|
|
326
|
+
//#endregion
|
|
327
|
+
//#region src/decorate/applyToClass.d.ts
|
|
328
|
+
interface Constructor {
|
|
329
|
+
prototype: Record<string, unknown>;
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Applies logging to all methods in a class.
|
|
333
|
+
* @internal
|
|
334
|
+
*/
|
|
335
|
+
declare const applyToClass: (target: Constructor, options: LogOptions) => void;
|
|
336
|
+
//#endregion
|
|
337
|
+
export { Log, LogArgsFormatter, LogOptions, LogWrapper, Loggable, NO_LOG_METADATA_KEY, NoLog, applyToClass, applyToMethod, buildArgsObject, createLogWrapper, getParameterNames, handleAsyncExecution, isLoggable, prettifyAxiosError };
|
package/package.json
CHANGED