feat: 3.2.0 beta.4 release

This commit is contained in:
Shinwoo PARK 2025-03-20 18:17:51 +09:00
parent 4c0a28251b
commit 86912c08f1
6 changed files with 27 additions and 13 deletions

View File

@ -18,6 +18,7 @@ interface OverrideBuildOptions {
/** @deprecated use `errorLogLevel: 'skip'` instead */
skipErrorLog: boolean;
}
export declare const REQUEST_LOG_ID = "__nestlogged_request_log_id__";
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;

22
dist/lib/logged.js vendored
View File

@ -1,6 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LoggedMiddleware = exports.LoggedInterceptor = exports.LoggedGuard = exports.LoggedRoute = exports.LoggedFunction = exports.LoggedController = exports.LoggedInjectable = void 0;
exports.LoggedMiddleware = exports.LoggedInterceptor = exports.LoggedGuard = exports.LoggedRoute = exports.LoggedFunction = exports.REQUEST_LOG_ID = exports.LoggedController = exports.LoggedInjectable = void 0;
const common_1 = require("@nestjs/common");
const logger_1 = require("./logger");
const reflected_1 = require("./reflected");
@ -110,7 +110,7 @@ function createCallLogIdentifyMessage(message, type, key, route) {
return `${message} ${callLogIdentifyMessageDictionary[type]} ${key}`;
return `${message} ${callLogIdentifyMessageDictionary[type]}`;
}
const REQUEST_LOG_ID = '__nestlogged_request_log_id__';
exports.REQUEST_LOG_ID = '__nestlogged_request_log_id__';
function overrideBuild(type, originalFunction, baseLogger, metadatas, key, returnsData, logged, route) {
return function (...args) {
// Creating ScopedLogger
@ -135,26 +135,26 @@ function overrideBuild(type, originalFunction, baseLogger, metadatas, key, retur
}
else {
let req = ctx.switchToHttp().getRequest();
if (req[REQUEST_LOG_ID] === undefined) {
req[REQUEST_LOG_ID] = logger_1.ScopedLogger.createScopeId();
if (req[exports.REQUEST_LOG_ID] === undefined) {
req[exports.REQUEST_LOG_ID] = logger_1.ScopedLogger.createScopeId();
}
args[metadatas.scopedLoggerInjectableParam] = logger_1.ScopedLogger.fromRoot(baseLogger, key, req[REQUEST_LOG_ID]);
args[metadatas.scopedLoggerInjectableParam] = logger_1.ScopedLogger.fromRoot(baseLogger, key, req[exports.REQUEST_LOG_ID]);
}
}
else if (type === 'middleware') {
let req = args[0];
if (req[REQUEST_LOG_ID] === undefined) {
req[REQUEST_LOG_ID] = logger_1.ScopedLogger.createScopeId();
if (req[exports.REQUEST_LOG_ID] === undefined) {
req[exports.REQUEST_LOG_ID] = logger_1.ScopedLogger.createScopeId();
}
args[metadatas.scopedLoggerInjectableParam] = logger_1.ScopedLogger.fromRoot(baseLogger, key, req[REQUEST_LOG_ID]);
args[metadatas.scopedLoggerInjectableParam] = logger_1.ScopedLogger.fromRoot(baseLogger, key, req[exports.REQUEST_LOG_ID]);
}
else if (type === 'route') {
// args[metadatas.scopedLoggerInjectableParam] is now Request object, thanks to code in @LoggedRoute!!!!
let req = args[metadatas.scopedLoggerInjectableParam];
if (req[REQUEST_LOG_ID] === undefined) {
req[REQUEST_LOG_ID] = logger_1.ScopedLogger.createScopeId();
if (req[exports.REQUEST_LOG_ID] === undefined) {
req[exports.REQUEST_LOG_ID] = logger_1.ScopedLogger.createScopeId();
}
args[metadatas.scopedLoggerInjectableParam] = logger_1.ScopedLogger.fromRoot(baseLogger, key, req[REQUEST_LOG_ID]);
args[metadatas.scopedLoggerInjectableParam] = logger_1.ScopedLogger.fromRoot(baseLogger, key, req[exports.REQUEST_LOG_ID]);
}
}
injectedLogger = args[metadatas.scopedLoggerInjectableParam];

2
dist/lib/utils.d.ts vendored Normal file
View File

@ -0,0 +1,2 @@
import { ScopedLogger } from "./logger";
export declare function getRequestLogger(functionName: string, req: any): ScopedLogger;

11
dist/lib/utils.js vendored Normal file
View File

@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getRequestLogger = void 0;
const common_1 = require("@nestjs/common");
const logger_1 = require("./logger");
const logged_1 = require("./logged");
const logger = new common_1.Logger();
function getRequestLogger(functionName, req) {
return new logger_1.ScopedLogger(logger, [functionName], req[logged_1.REQUEST_LOG_ID]);
}
exports.getRequestLogger = getRequestLogger;

2
dist/package.json vendored
View File

@ -1,6 +1,6 @@
{
"name": "nestlogged",
"version": "3.2.0-beta.3",
"version": "3.2.0-beta.4",
"description": "A NestJS Logger Decorator Library",
"main": "lib/index.js",
"repository": "https://git.psw.kr/p-sw/nestlogged",

View File

@ -1,6 +1,6 @@
{
"name": "nestlogged",
"version": "3.2.0-beta.3",
"version": "3.2.0-beta.4",
"description": "A NestJS Logger Decorator Library",
"main": "./dist/lib/index.js",
"repository": "https://git.psw.kr/p-sw/nestlogged",