feat: 3.2.0 beta.3 release
This commit is contained in:
parent
e609982bef
commit
06c373f858
44
dist/lib/logged.js
vendored
44
dist/lib/logged.js
vendored
@ -95,20 +95,20 @@ class LoggedMetadata {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const callLogIdentifyMessageDictionary = {
|
const callLogIdentifyMessageDictionary = {
|
||||||
route: 'HIT HTTP',
|
route: 'ENDPOINT',
|
||||||
function: 'CALL',
|
function: 'FUNCTION',
|
||||||
guard: 'HIT GUARD',
|
guard: 'GUARD',
|
||||||
interceptor: 'HIT INTERCEPTOR',
|
interceptor: 'INTERCEPTOR',
|
||||||
middleware: 'HIT MIDDLEWARE',
|
middleware: 'MIDDLEWARE',
|
||||||
};
|
};
|
||||||
function createCallLogIdentifyMessage(type, key, route) {
|
function createCallLogIdentifyMessage(message, type, key, route) {
|
||||||
if (type === 'route')
|
if (message === 'ERROR')
|
||||||
return `${callLogIdentifyMessageDictionary[type]} ${route} (${key})`;
|
return `ERROR WHILE ${callLogIdentifyMessageDictionary[type]} ${key} (${route}): `;
|
||||||
if (type === 'guard' || type === 'interceptor' || type === 'middleware')
|
if (type === 'guard' || type === 'interceptor' || type === 'middleware' || type === 'route')
|
||||||
return `${callLogIdentifyMessageDictionary[type]} ${route}`;
|
return `${message} ${callLogIdentifyMessageDictionary[type]} ${key} (${route})`;
|
||||||
if (type === 'function')
|
if (type === 'function')
|
||||||
return `${callLogIdentifyMessageDictionary[type]} ${key}`;
|
return `${message} ${callLogIdentifyMessageDictionary[type]} ${key}`;
|
||||||
return callLogIdentifyMessageDictionary[type];
|
return `${message} ${callLogIdentifyMessageDictionary[type]}`;
|
||||||
}
|
}
|
||||||
const REQUEST_LOG_ID = '__nestlogged_request_log_id__';
|
const REQUEST_LOG_ID = '__nestlogged_request_log_id__';
|
||||||
function overrideBuild(type, originalFunction, baseLogger, metadatas, key, returnsData, logged, route) {
|
function overrideBuild(type, originalFunction, baseLogger, metadatas, key, returnsData, logged, route) {
|
||||||
@ -164,16 +164,14 @@ function overrideBuild(type, originalFunction, baseLogger, metadatas, key, retur
|
|||||||
const context = args[0];
|
const context = args[0];
|
||||||
if (context.getType() === 'http') {
|
if (context.getType() === 'http') {
|
||||||
const req = context.switchToHttp().getRequest();
|
const req = context.switchToHttp().getRequest();
|
||||||
route = new URL(( /* supporting FastifyRequest */req.raw ? req.raw.url : req.url)).pathname;
|
route = /* supporting FastifyRequest */ req.raw ? req.raw.url : req.url;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Start Log
|
// Start Log
|
||||||
if (logged.options.callLogLevel !== 'skip') {
|
if (logged.options.callLogLevel !== 'skip') {
|
||||||
const callLogIdentifyMessage = type === 'middleware' || type === 'guard' || type === 'interceptor'
|
const callLogIdentifyMessage = type === 'middleware' || type === 'guard' || type === 'interceptor' || type === 'route'
|
||||||
? createCallLogIdentifyMessage(type, route)
|
? createCallLogIdentifyMessage('HIT', type, key, route)
|
||||||
: type === 'route'
|
: createCallLogIdentifyMessage('HIT', type, key);
|
||||||
? createCallLogIdentifyMessage(type, key, route)
|
|
||||||
: createCallLogIdentifyMessage(type, key);
|
|
||||||
injectedLogger[logged.options.callLogLevel](`${callLogIdentifyMessage} ${metadatas.loggedParams && metadatas.loggedParams.length > 0
|
injectedLogger[logged.options.callLogLevel](`${callLogIdentifyMessage} ${metadatas.loggedParams && metadatas.loggedParams.length > 0
|
||||||
? "WITH " +
|
? "WITH " +
|
||||||
metadatas.loggedParams.map(({ name, index, include, exclude }) => name +
|
metadatas.loggedParams.map(({ name, index, include, exclude }) => name +
|
||||||
@ -208,9 +206,7 @@ function overrideBuild(type, originalFunction, baseLogger, metadatas, key, retur
|
|||||||
? "WITH " + JSON.stringify(r)
|
? "WITH " + JSON.stringify(r)
|
||||||
: "WITH " + r
|
: "WITH " + r
|
||||||
: "";
|
: "";
|
||||||
injectedLogger[logged.options.returnLogLevel](route
|
injectedLogger[logged.options.returnLogLevel](`${createCallLogIdentifyMessage('RETURNED', type, key, route)} ${resultLogged}`);
|
||||||
? `RETURNED HTTP ${route} (${key}) ${resultLogged}`
|
|
||||||
: `RETURNED ${key} ${resultLogged}`);
|
|
||||||
return r;
|
return r;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -232,9 +228,7 @@ function overrideBuild(type, originalFunction, baseLogger, metadatas, key, retur
|
|||||||
? "WITH " + JSON.stringify(r)
|
? "WITH " + JSON.stringify(r)
|
||||||
: "WITH " + r
|
: "WITH " + r
|
||||||
: "";
|
: "";
|
||||||
injectedLogger[logged.options.returnLogLevel](route
|
injectedLogger[logged.options.returnLogLevel](`${createCallLogIdentifyMessage('RETURNED', type, key, route)} ${resultLogged}`);
|
||||||
? `RETURNED HTTP ${route} (${key}) ${resultLogged}`
|
|
||||||
: `RETURNED ${key} ${resultLogged}`);
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -245,7 +239,7 @@ function overrideBuild(type, originalFunction, baseLogger, metadatas, key, retur
|
|||||||
catch (e) {
|
catch (e) {
|
||||||
// Error Log
|
// Error Log
|
||||||
if (logged.options.errorLogLevel !== 'skip') {
|
if (logged.options.errorLogLevel !== 'skip') {
|
||||||
injectedLogger[logged.options.errorLogLevel](`WHILE ${route ? `HTTP ${route} (${key})` : key} ERROR ${e}`);
|
injectedLogger[logged.options.errorLogLevel](`${createCallLogIdentifyMessage('ERROR', type, key, route)} ${e}`);
|
||||||
}
|
}
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
2
dist/package.json
vendored
2
dist/package.json
vendored
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "nestlogged",
|
"name": "nestlogged",
|
||||||
"version": "3.2.0-beta.2",
|
"version": "3.2.0-beta.3",
|
||||||
"description": "A NestJS Logger Decorator Library",
|
"description": "A NestJS Logger Decorator Library",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"repository": "https://git.psw.kr/p-sw/nestlogged",
|
"repository": "https://git.psw.kr/p-sw/nestlogged",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "nestlogged",
|
"name": "nestlogged",
|
||||||
"version": "3.2.0-beta.2",
|
"version": "3.2.0-beta.3",
|
||||||
"description": "A NestJS Logger Decorator Library",
|
"description": "A NestJS Logger Decorator Library",
|
||||||
"main": "./dist/lib/index.js",
|
"main": "./dist/lib/index.js",
|
||||||
"repository": "https://git.psw.kr/p-sw/nestlogged",
|
"repository": "https://git.psw.kr/p-sw/nestlogged",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user