Compare commits

..

No commits in common. "d73b64f0f260bed65fdff6549f621a89219b7bc3" and "e81e7b8e09e36976ea01d8374e579c9d1aa868e7" have entirely different histories.

12 changed files with 60 additions and 291 deletions

Binary file not shown.

2
dist/lib/index.d.ts vendored
View File

@ -1,3 +1,3 @@
export { LoggedRoute, LoggedFunction, LoggedController, LoggedInjectable, LoggedGuard, LoggedInterceptor, } from "./logged";
export { LoggedRoute, LoggedFunction, LoggedController, LoggedInjectable, } from "./logged";
export { ScopedLogger } from "./logger";
export { InjectLogger, LoggedParam, LoggedHeaders, LoggedBody, LoggedQuery, Logged, Returns } from "./reflected";

4
dist/lib/index.js vendored
View File

@ -1,13 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Returns = exports.Logged = exports.LoggedQuery = exports.LoggedBody = exports.LoggedHeaders = exports.LoggedParam = exports.InjectLogger = exports.ScopedLogger = exports.LoggedInterceptor = exports.LoggedGuard = exports.LoggedInjectable = exports.LoggedController = exports.LoggedFunction = exports.LoggedRoute = void 0;
exports.Returns = exports.Logged = exports.LoggedQuery = exports.LoggedBody = exports.LoggedHeaders = exports.LoggedParam = exports.InjectLogger = exports.ScopedLogger = exports.LoggedInjectable = exports.LoggedController = exports.LoggedFunction = exports.LoggedRoute = void 0;
var logged_1 = require("./logged");
Object.defineProperty(exports, "LoggedRoute", { enumerable: true, get: function () { return logged_1.LoggedRoute; } });
Object.defineProperty(exports, "LoggedFunction", { enumerable: true, get: function () { return logged_1.LoggedFunction; } });
Object.defineProperty(exports, "LoggedController", { enumerable: true, get: function () { return logged_1.LoggedController; } });
Object.defineProperty(exports, "LoggedInjectable", { enumerable: true, get: function () { return logged_1.LoggedInjectable; } });
Object.defineProperty(exports, "LoggedGuard", { enumerable: true, get: function () { return logged_1.LoggedGuard; } });
Object.defineProperty(exports, "LoggedInterceptor", { enumerable: true, get: function () { return logged_1.LoggedInterceptor; } });
var logger_1 = require("./logger");
Object.defineProperty(exports, "ScopedLogger", { enumerable: true, get: function () { return logger_1.ScopedLogger; } });
var reflected_1 = require("./reflected");

View File

@ -1,4 +1,4 @@
import { LogLevel, ControllerOptions, ScopeOptions, ExecutionContext } from "@nestjs/common";
import { LogLevel, ControllerOptions, ScopeOptions } from "@nestjs/common";
export declare function LoggedInjectable(options?: ScopeOptions & {
verbose?: boolean;
}): (target: any) => void;
@ -20,6 +20,4 @@ interface OverrideBuildOptions {
}
export declare function LoggedFunction<F extends Array<any>, R>(options?: Partial<OverrideBuildOptions>): (_target: any, key: string, descriptor: TypedPropertyDescriptor<(...args: F) => R | Promise<R>>) => void;
export declare function LoggedRoute<F extends Array<any>, R>(route?: string, options?: Partial<OverrideBuildOptions>): (_target: any, key: string, descriptor: TypedPropertyDescriptor<(...args: F) => R>) => void;
export declare function LoggedGuard<F extends Array<any>, R>(options?: Partial<OverrideBuildOptions>): (_target: any, key: string, descriptor: TypedPropertyDescriptor<(context: ExecutionContext, ...args: F) => R>) => void;
export declare function LoggedInterceptor<F extends Array<any>, R>(options?: Partial<OverrideBuildOptions>): (_target: any, key: string, descriptor: TypedPropertyDescriptor<(context: ExecutionContext, ...args: F) => R>) => void;
export {};

122
dist/lib/logged.js vendored
View File

@ -1,6 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LoggedInterceptor = exports.LoggedGuard = exports.LoggedRoute = exports.LoggedFunction = exports.LoggedController = exports.LoggedInjectable = void 0;
exports.LoggedRoute = exports.LoggedFunction = exports.LoggedController = exports.LoggedInjectable = void 0;
const common_1 = require("@nestjs/common");
const logger_1 = require("./logger");
const reflected_1 = require("./reflected");
@ -94,18 +94,8 @@ class LoggedMetadata {
};
}
}
const callLogIdentifyMessageDictionary = {
route: 'HIT HTTP',
function: 'CALL',
guard: 'HIT GUARD',
interceptor: 'HIT INTERCEPTOR'
};
function createCallLogIdentifyMessage(type, key, route) {
return `${callLogIdentifyMessageDictionary[type]} ${type === 'route' ? `${route} (${key})` : type === 'guard' ? `${route}` : key}`;
}
function overrideBuild(type, originalFunction, baseLogger, metadatas, key, returnsData, logged, route) {
function overrideBuild(originalFunction, baseLogger, metadatas, key, returnsData, logged, route) {
return function (...args) {
// Creating ScopedLogger
let injectedLogger = baseLogger;
if (typeof metadatas.scopedLoggerInjectableParam !== "undefined") {
if (args.length <= metadatas.scopedLoggerInjectableParam ||
@ -117,18 +107,8 @@ function overrideBuild(type, originalFunction, baseLogger, metadatas, key, retur
}
injectedLogger = args[metadatas.scopedLoggerInjectableParam];
}
// If this is ExecutionContext based function (e.g. Guard, Interceptor) get Request from Context
if (type === 'guard') {
const context = args[0];
if (context.getType() === 'http') {
const req = context.switchToHttp().getRequest();
route = new URL(( /* supporting FastifyRequest */req.raw ? req.raw.url : req.url)).pathname;
}
}
// Start Log
if (logged.options.callLogLevel !== 'skip') {
const callLogIdentifyMessage = type === 'route' || type === 'guard' || type === 'interceptor' ? createCallLogIdentifyMessage(type, key, route) : createCallLogIdentifyMessage(type, key);
injectedLogger[logged.options.callLogLevel](`${callLogIdentifyMessage} ${metadatas.loggedParams && metadatas.loggedParams.length > 0
injectedLogger[logged.options.callLogLevel](`${route ? "HIT HTTP" : "CALL"} ${route ? `${route.fullRoute} (${key})` : key} ${metadatas.loggedParams && metadatas.loggedParams.length > 0
? "WITH " +
metadatas.loggedParams.map(({ name, index, include, exclude }) => name +
"=" +
@ -139,8 +119,7 @@ function overrideBuild(type, originalFunction, baseLogger, metadatas, key, retur
: ""}`);
}
try {
const r = originalFunction.call(this, ...args); // Try to call original function
// Return Log
const r = originalFunction.call(this, ...args);
if (logged.options.returnLogLevel !== 'skip') {
if (originalFunction.constructor.name === 'AsyncFunction' ||
(r && typeof r === 'object' && typeof r['then'] === 'function')) {
@ -163,7 +142,7 @@ function overrideBuild(type, originalFunction, baseLogger, metadatas, key, retur
: "WITH " + r
: "";
injectedLogger[logged.options.returnLogLevel](route
? `RETURNED HTTP ${route} (${key}) ${resultLogged}`
? `RETURNED HTTP ${route.fullRoute} (${key}) ${resultLogged}`
: `RETURNED ${key} ${resultLogged}`);
return r;
});
@ -187,7 +166,7 @@ function overrideBuild(type, originalFunction, baseLogger, metadatas, key, retur
: "WITH " + r
: "";
injectedLogger[logged.options.returnLogLevel](route
? `RETURNED HTTP ${route} (${key}) ${resultLogged}`
? `RETURNED HTTP ${route.fullRoute} (${key}) ${resultLogged}`
: `RETURNED ${key} ${resultLogged}`);
return r;
}
@ -197,9 +176,8 @@ function overrideBuild(type, originalFunction, baseLogger, metadatas, key, retur
}
}
catch (e) {
// Error Log
if (logged.options.errorLogLevel !== 'skip') {
injectedLogger[logged.options.errorLogLevel](`WHILE ${route ? `HTTP ${route} (${key})` : key} ERROR ${e}`);
injectedLogger[logged.options.errorLogLevel](`WHILE ${route ? `HTTP ${route.fullRoute} (${key})` : key} ERROR ${e}`);
}
throw e;
}
@ -227,11 +205,13 @@ function LoggedFunction(options) {
]);
const scopedLoggerInjectableParam = Reflect.getOwnMetadata(reflected_1.scopedLogger, _target, key);
const loggedParams = Reflect.getOwnMetadata(reflected_1.loggedParam, _target, key);
const scopeKeys = Reflect.getOwnMetadata(reflected_1.scopeKey, _target, key);
const returnsData = Reflect.getOwnMetadata(reflected_1.returns, fn);
const overrideFunction = overrideBuild('function', fn, logger, {
const overrideFunction = overrideBuild(fn, logger, {
scopedLoggerInjectableParam,
loggedParams,
}, key, returnsData, newMetadata);
scopeKeys,
}, key, returnsData, newMetadata, undefined);
_target[key] = overrideFunction;
descriptor.value = overrideFunction;
Reflect.defineMetadata(reflected_1.nestLoggedMetadata, newMetadata, _target, key);
@ -267,11 +247,15 @@ function LoggedRoute(route, options) {
const fullRoute = `${_target.constructor.name}::${route ?? httpPath}[${RevRequestMethod[httpMethod]}]`;
const scopedLoggerInjectableParam = Reflect.getOwnMetadata(reflected_1.scopedLogger, _target, key);
const loggedParams = Reflect.getOwnMetadata(reflected_1.loggedParam, _target, key);
const scopeKeys = Reflect.getOwnMetadata(reflected_1.scopeKey, _target, key);
const returnsData = Reflect.getOwnMetadata(reflected_1.returns, fn);
const overrideFunction = overrideBuild('route', fn, logger, {
const overrideFunction = overrideBuild(fn, logger, {
scopedLoggerInjectableParam,
loggedParams,
}, key, returnsData, newMetadata, fullRoute);
scopeKeys,
}, key, returnsData, newMetadata, {
fullRoute,
});
_target[key] = overrideFunction;
descriptor.value = overrideFunction;
Reflect.defineMetadata(reflected_1.nestLoggedMetadata, newMetadata, _target, key);
@ -282,75 +266,3 @@ function LoggedRoute(route, options) {
};
}
exports.LoggedRoute = LoggedRoute;
function LoggedGuard(options) {
return (_target, key, descriptor) => {
loggerInit(_target);
const logger = _target.logger;
const fn = descriptor.value;
if (!fn || typeof fn !== "function") {
logger.warn(`LoggedGuard decorator applied to non-function property: ${key}`);
return;
}
const logMetadata = Reflect.getOwnMetadata(reflected_1.nestLoggedMetadata, _target, key);
if (logMetadata) {
// already applied, override instead
logMetadata.updateOption(options);
return;
}
const newMetadata = new LoggedMetadata(options);
const all = Reflect.getMetadataKeys(fn).map((k) => [
k,
Reflect.getMetadata(k, fn),
]);
const scopedLoggerInjectableParam = Reflect.getOwnMetadata(reflected_1.scopedLogger, _target, key);
const returnsData = Reflect.getOwnMetadata(reflected_1.returns, fn);
const overrideFunction = overrideBuild('guard', fn, logger, {
scopedLoggerInjectableParam,
loggedParams: [],
}, key, returnsData, newMetadata);
_target[key] = overrideFunction;
descriptor.value = overrideFunction;
Reflect.defineMetadata(reflected_1.nestLoggedMetadata, newMetadata, _target, key);
all.forEach(([k, v]) => {
Reflect.defineMetadata(k, v, _target[key]);
Reflect.defineMetadata(k, v, descriptor.value);
});
};
}
exports.LoggedGuard = LoggedGuard;
function LoggedInterceptor(options) {
return (_target, key, descriptor) => {
loggerInit(_target);
const logger = _target.logger;
const fn = descriptor.value;
if (!fn || typeof fn !== "function") {
logger.warn(`LoggedInterceptor decorator applied to non-function property: ${key}`);
return;
}
const logMetadata = Reflect.getOwnMetadata(reflected_1.nestLoggedMetadata, _target, key);
if (logMetadata) {
// already applied, override instead
logMetadata.updateOption(options);
return;
}
const newMetadata = new LoggedMetadata(options);
const all = Reflect.getMetadataKeys(fn).map((k) => [
k,
Reflect.getMetadata(k, fn),
]);
const scopedLoggerInjectableParam = Reflect.getOwnMetadata(reflected_1.scopedLogger, _target, key);
const returnsData = Reflect.getOwnMetadata(reflected_1.returns, fn);
const overrideFunction = overrideBuild('interceptor', fn, logger, {
scopedLoggerInjectableParam,
loggedParams: [],
}, key, returnsData, newMetadata);
_target[key] = overrideFunction;
descriptor.value = overrideFunction;
Reflect.defineMetadata(reflected_1.nestLoggedMetadata, newMetadata, _target, key);
all.forEach(([k, v]) => {
Reflect.defineMetadata(k, v, _target[key]);
Reflect.defineMetadata(k, v, descriptor.value);
});
};
}
exports.LoggedInterceptor = LoggedInterceptor;

View File

@ -23,6 +23,7 @@ export interface ReturnsReflectData {
}
export declare const scopedLogger: unique symbol;
export declare const loggedParam: unique symbol;
export declare const scopeKey: unique symbol;
export declare const returns: unique symbol;
export declare const nestLoggedMetadata: unique symbol;
export declare function InjectLogger(target: any, propertyKey: string | symbol, parameterIndex: number): void;

View File

@ -1,6 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Returns = exports.LoggedHeaders = exports.LoggedBody = exports.LoggedQuery = exports.LoggedParam = exports.Logged = exports.InjectLogger = exports.nestLoggedMetadata = exports.returns = exports.loggedParam = exports.scopedLogger = void 0;
exports.Returns = exports.LoggedHeaders = exports.LoggedBody = exports.LoggedQuery = exports.LoggedParam = exports.Logged = exports.InjectLogger = exports.nestLoggedMetadata = exports.returns = exports.scopeKey = exports.loggedParam = exports.scopedLogger = void 0;
const route_paramtypes_enum_1 = require("@nestjs/common/enums/route-paramtypes.enum");
const common_1 = require("@nestjs/common");
const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
@ -20,6 +20,7 @@ const createPipesRouteParamDecorator = (paramtype) => (data, ...pipes) => (targe
};
exports.scopedLogger = Symbol("nlogdec-scopedLogger");
exports.loggedParam = Symbol("nlogdec-loggedParam");
exports.scopeKey = Symbol("nlogdec-scopeKey");
exports.returns = Symbol("nlogdec-returns");
exports.nestLoggedMetadata = Symbol("nlogdec-metadata");
function InjectLogger(target, propertyKey, parameterIndex) {

5
dist/package.json vendored
View File

@ -1,11 +1,12 @@
{
"name": "nestlogged",
"version": "3.2.0-beta.1",
"version": "3.1.0",
"description": "A NestJS Logger Decorator Library",
"main": "lib/index.js",
"repository": "https://git.psw.kr/p-sw/nestlogged",
"author": "Shinwoo PARK",
"license": "MIT",
"private": false,
"dependencies": {
"@nestjs/common": "^10.2.8",
"hyperid": "^3.1.1",
@ -22,4 +23,4 @@
"log",
"logging"
]
}
}

173
dist/yarn.lock vendored
View File

@ -1,173 +0,0 @@
# This file is generated by running "yarn install" inside your project.
# Manual changes might be lost - proceed with caution!
__metadata:
version: 8
cacheKey: 10c0
"@lukeed/csprng@npm:^1.0.0":
version: 1.1.0
resolution: "@lukeed/csprng@npm:1.1.0"
checksum: 10c0/5d6dcf478af732972083ab2889c294b57f1028fa13c2c240d7a4aaa079c2c75df7ef0dcbdda5419147fc6704b4adf96b2de92f1a9a72ac21c6350c4014fffe6c
languageName: node
linkType: hard
"@nestjs/common@npm:^10.2.8":
version: 10.4.15
resolution: "@nestjs/common@npm:10.4.15"
dependencies:
iterare: "npm:1.2.1"
tslib: "npm:2.8.1"
uid: "npm:2.0.2"
peerDependencies:
class-transformer: "*"
class-validator: "*"
reflect-metadata: ^0.1.12 || ^0.2.0
rxjs: ^7.1.0
peerDependenciesMeta:
class-transformer:
optional: true
class-validator:
optional: true
checksum: 10c0/9566993fd3f805df2be632f5a16ca90d81b0deeb50e1e7cde4a49d4948c0d8d7db58b42ded70f35061e95e91a40d2adcd9e19cb2771090114eb737f62d2ea4c6
languageName: node
linkType: hard
"@types/node@npm:^20.9.1":
version: 20.17.24
resolution: "@types/node@npm:20.17.24"
dependencies:
undici-types: "npm:~6.19.2"
checksum: 10c0/2a39ce4c4cd4588a05b2a485cc0a1407cbea608dd1ab03e36add59d61712718d95c84b492ca5190753f0be2bce748aeeb0f2a1412e712775462befe3820b3ff9
languageName: node
linkType: hard
"base64-js@npm:^1.3.1":
version: 1.5.1
resolution: "base64-js@npm:1.5.1"
checksum: 10c0/f23823513b63173a001030fae4f2dabe283b99a9d324ade3ad3d148e218134676f1ee8568c877cd79ec1c53158dcf2d2ba527a97c606618928ba99dd930102bf
languageName: node
linkType: hard
"buffer@npm:^5.2.1":
version: 5.7.1
resolution: "buffer@npm:5.7.1"
dependencies:
base64-js: "npm:^1.3.1"
ieee754: "npm:^1.1.13"
checksum: 10c0/27cac81cff434ed2876058d72e7c4789d11ff1120ef32c9de48f59eab58179b66710c488987d295ae89a228f835fc66d088652dffeb8e3ba8659f80eb091d55e
languageName: node
linkType: hard
"hyperid@npm:^3.1.1":
version: 3.3.0
resolution: "hyperid@npm:3.3.0"
dependencies:
buffer: "npm:^5.2.1"
uuid: "npm:^8.3.2"
uuid-parse: "npm:^1.1.0"
checksum: 10c0/709dafd2a25e21086a2d881adb3436a16eafd28692ebd967829ca1d5f10adf001925feb23b6aadfee464ea313d851e7ba7a5452869aaf6cde15e9149793a09e0
languageName: node
linkType: hard
"ieee754@npm:^1.1.13":
version: 1.2.1
resolution: "ieee754@npm:1.2.1"
checksum: 10c0/b0782ef5e0935b9f12883a2e2aa37baa75da6e66ce6515c168697b42160807d9330de9a32ec1ed73149aea02e0d822e572bca6f1e22bdcbd2149e13b050b17bb
languageName: node
linkType: hard
"iterare@npm:1.2.1":
version: 1.2.1
resolution: "iterare@npm:1.2.1"
checksum: 10c0/02667d486e3e83ead028ba8484d927498c2ceab7e8c6a69dd881fd02abc4114f00b13abb36b592252fbb578b6e6f99ca1dfc2835408b9158c9a112a9964f453f
languageName: node
linkType: hard
"nestlogged@workspace:.":
version: 0.0.0-use.local
resolution: "nestlogged@workspace:."
dependencies:
"@nestjs/common": "npm:^10.2.8"
"@types/node": "npm:^20.9.1"
hyperid: "npm:^3.1.1"
reflect-metadata: "npm:^0.1.13"
rxjs: "npm:^7.8.1"
typescript: "npm:^5.2.2"
languageName: unknown
linkType: soft
"reflect-metadata@npm:^0.1.13":
version: 0.1.14
resolution: "reflect-metadata@npm:0.1.14"
checksum: 10c0/3a6190c7f6cb224f26a012d11f9e329360c01c1945e2cbefea23976a8bacf9db6b794aeb5bf18adcb673c448a234fbc06fc41853c00a6c206b30f0777ecf019e
languageName: node
linkType: hard
"rxjs@npm:^7.8.1":
version: 7.8.2
resolution: "rxjs@npm:7.8.2"
dependencies:
tslib: "npm:^2.1.0"
checksum: 10c0/1fcd33d2066ada98ba8f21fcbbcaee9f0b271de1d38dc7f4e256bfbc6ffcdde68c8bfb69093de7eeb46f24b1fb820620bf0223706cff26b4ab99a7ff7b2e2c45
languageName: node
linkType: hard
"tslib@npm:2.8.1, tslib@npm:^2.1.0":
version: 2.8.1
resolution: "tslib@npm:2.8.1"
checksum: 10c0/9c4759110a19c53f992d9aae23aac5ced636e99887b51b9e61def52611732872ff7668757d4e4c61f19691e36f4da981cd9485e869b4a7408d689f6bf1f14e62
languageName: node
linkType: hard
"typescript@npm:^5.2.2":
version: 5.8.2
resolution: "typescript@npm:5.8.2"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: 10c0/5c4f6fbf1c6389b6928fe7b8fcd5dc73bb2d58cd4e3883f1d774ed5bd83b151cbac6b7ecf11723de56d4676daeba8713894b1e9af56174f2f9780ae7848ec3c6
languageName: node
linkType: hard
"typescript@patch:typescript@npm%3A^5.2.2#optional!builtin<compat/typescript>":
version: 5.8.2
resolution: "typescript@patch:typescript@npm%3A5.8.2#optional!builtin<compat/typescript>::version=5.8.2&hash=5786d5"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: 10c0/5448a08e595cc558ab321e49d4cac64fb43d1fa106584f6ff9a8d8e592111b373a995a1d5c7f3046211c8a37201eb6d0f1566f15cdb7a62a5e3be01d087848e2
languageName: node
linkType: hard
"uid@npm:2.0.2":
version: 2.0.2
resolution: "uid@npm:2.0.2"
dependencies:
"@lukeed/csprng": "npm:^1.0.0"
checksum: 10c0/e9d02d0562c74e74b5a2519e586db9d7f8204978e476cddd191ee1a9efb85efafdbab2dbf3fc3dde0f5da01fd9da161f37d604dabf513447fd2c03d008f1324c
languageName: node
linkType: hard
"undici-types@npm:~6.19.2":
version: 6.19.8
resolution: "undici-types@npm:6.19.8"
checksum: 10c0/078afa5990fba110f6824823ace86073b4638f1d5112ee26e790155f481f2a868cc3e0615505b6f4282bdf74a3d8caad715fd809e870c2bb0704e3ea6082f344
languageName: node
linkType: hard
"uuid-parse@npm:^1.1.0":
version: 1.1.0
resolution: "uuid-parse@npm:1.1.0"
checksum: 10c0/513d5b0407b8929c54d452e8e286a1f6f00d40a2ebf6607fc7297b9caa40eee35230dcc4ce3f178f84d89704e8147e24d1a33d680a8afb7e12a5700714db7f51
languageName: node
linkType: hard
"uuid@npm:^8.3.2":
version: 8.3.2
resolution: "uuid@npm:8.3.2"
bin:
uuid: dist/bin/uuid
checksum: 10c0/bcbb807a917d374a49f475fae2e87fdca7da5e5530820ef53f65ba1d12131bd81a92ecf259cc7ce317cbe0f289e7d79fdfebcef9bfa3087c8c8a2fa304c9be54
languageName: node
linkType: hard

View File

@ -1,6 +1,6 @@
{
"name": "nestlogged",
"version": "3.2.0-beta.1",
"version": "3.1.0",
"description": "A NestJS Logger Decorator Library",
"main": "./dist/lib/index.js",
"repository": "https://git.psw.kr/p-sw/nestlogged",
@ -22,8 +22,7 @@
"scripts": {
"docs": "cp ./README.md ./dist/README.md",
"build": "rimraf ./dist/lib && tsc --project tsconfig.build.json",
"up": "yarn docs && yarn build && yarn npm publish dist",
"up:beta": "yarn docs && yarn build && yarn npm publish dist --tag beta",
"up": "yarn docs && yarn build && yarn publish dist",
"test": "ts-node ./src/test/index.ts"
},
"packageManager": "yarn@4.7.0+sha512.5a0afa1d4c1d844b3447ee3319633797bcd6385d9a44be07993ae52ff4facabccafb4af5dcd1c2f9a94ac113e5e9ff56f6130431905884414229e284e37bb7c9"

View File

@ -11,7 +11,9 @@ import { ScopedLogger } from "./logger";
import {
LoggedParamReflectData,
ReturnsReflectData,
ScopeKeyReflectData,
returns,
scopeKey,
nestLoggedMetadata,
loggedParam,
scopedLogger
@ -119,6 +121,7 @@ export function LoggedController(param?: any): (target: any) => void {
interface FunctionMetadata {
scopedLoggerInjectableParam?: number;
scopeKeys?: ScopeKeyReflectData[];
loggedParams?: LoggedParamReflectData[];
}
@ -378,6 +381,12 @@ export function LoggedFunction<F extends Array<any>, R>(
key
);
const scopeKeys: ScopeKeyReflectData[] = Reflect.getOwnMetadata(
scopeKey,
_target,
key
);
const returnsData: ReturnsReflectData[] | true = Reflect.getOwnMetadata(
returns,
fn
@ -390,6 +399,7 @@ export function LoggedFunction<F extends Array<any>, R>(
{
scopedLoggerInjectableParam,
loggedParams,
scopeKeys,
},
key,
returnsData,
@ -466,6 +476,12 @@ export function LoggedRoute<F extends Array<any>, R>(route?: string, options?: P
key
);
const scopeKeys: ScopeKeyReflectData[] = Reflect.getOwnMetadata(
scopeKey,
_target,
key
);
const returnsData: ReturnsReflectData[] | true = Reflect.getOwnMetadata(
returns,
fn
@ -478,6 +494,7 @@ export function LoggedRoute<F extends Array<any>, R>(route?: string, options?: P
{
scopedLoggerInjectableParam,
loggedParams,
scopeKeys,
},
key,
returnsData,
@ -543,6 +560,12 @@ export function LoggedGuard<F extends Array<any>, R>(options?: Partial<OverrideB
key
);
const scopeKeys: ScopeKeyReflectData[] = Reflect.getOwnMetadata(
scopeKey,
_target,
key
);
const returnsData: ReturnsReflectData[] | true = Reflect.getOwnMetadata(
returns,
fn
@ -555,6 +578,7 @@ export function LoggedGuard<F extends Array<any>, R>(options?: Partial<OverrideB
{
scopedLoggerInjectableParam,
loggedParams: [],
scopeKeys,
},
key,
returnsData,
@ -619,6 +643,12 @@ export function LoggedInterceptor<F extends Array<any>, R>(options?: Partial<Ove
key
);
const scopeKeys: ScopeKeyReflectData[] = Reflect.getOwnMetadata(
scopeKey,
_target,
key
);
const returnsData: ReturnsReflectData[] | true = Reflect.getOwnMetadata(
returns,
fn
@ -631,6 +661,7 @@ export function LoggedInterceptor<F extends Array<any>, R>(options?: Partial<Ove
{
scopedLoggerInjectableParam,
loggedParams: [],
scopeKeys,
},
key,
returnsData,

View File

@ -73,6 +73,7 @@ export interface ReturnsReflectData {
export const scopedLogger = Symbol("nlogdec-scopedLogger");
export const loggedParam = Symbol("nlogdec-loggedParam");
export const scopeKey = Symbol("nlogdec-scopeKey");
export const returns = Symbol("nlogdec-returns");
export const nestLoggedMetadata = Symbol("nlogdec-metadata");