feat: add getRequestLogger util function for global middleware function
This commit is contained in:
parent
06c373f858
commit
4c0a28251b
@ -184,7 +184,7 @@ function createCallLogIdentifyMessage(message: 'HIT' | 'RETURNED' | 'ERROR', typ
|
||||
return `${message} ${callLogIdentifyMessageDictionary[type]}`;
|
||||
}
|
||||
|
||||
const REQUEST_LOG_ID = '__nestlogged_request_log_id__';
|
||||
export const REQUEST_LOG_ID = '__nestlogged_request_log_id__';
|
||||
|
||||
function overrideBuild<F extends Array<any>, R>(
|
||||
type: 'route',
|
||||
|
9
src/utils.ts
Normal file
9
src/utils.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import { Logger } from "@nestjs/common";
|
||||
import { ScopedLogger } from "./logger";
|
||||
import { REQUEST_LOG_ID } from "./logged";
|
||||
|
||||
const logger = new Logger();
|
||||
|
||||
export function getRequestLogger(functionName: string, req: any) {
|
||||
return new ScopedLogger(logger, [functionName], req[REQUEST_LOG_ID])
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user