@lark-apaas/nestjs-logger 1.0.2-alpha.14 → 1.0.2-alpha.15
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 +14 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +14 -2
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
package/dist/index.d.cts
CHANGED
|
@@ -3,6 +3,7 @@ import { Logger } from 'pino';
|
|
|
3
3
|
import { RequestContextService } from '@lark-apaas/nestjs-common';
|
|
4
4
|
export { RequestContextService } from '@lark-apaas/nestjs-common';
|
|
5
5
|
import { Request, Response, NextFunction } from 'express';
|
|
6
|
+
import { ObservableService } from '@lark-apaas/nestjs-observable';
|
|
6
7
|
|
|
7
8
|
declare abstract class BasePinoLogger implements LoggerService {
|
|
8
9
|
protected readonly logger: Logger;
|
|
@@ -48,7 +49,8 @@ type RequestWithUserContext = Request & {
|
|
|
48
49
|
};
|
|
49
50
|
declare class LoggerContextMiddleware implements NestMiddleware {
|
|
50
51
|
private readonly requestContext;
|
|
51
|
-
|
|
52
|
+
private readonly observableService;
|
|
53
|
+
constructor(requestContext: RequestContextService, observableService: ObservableService);
|
|
52
54
|
use(req: RequestWithUserContext, res: Response, next: NextFunction): void;
|
|
53
55
|
}
|
|
54
56
|
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { Logger } from 'pino';
|
|
|
3
3
|
import { RequestContextService } from '@lark-apaas/nestjs-common';
|
|
4
4
|
export { RequestContextService } from '@lark-apaas/nestjs-common';
|
|
5
5
|
import { Request, Response, NextFunction } from 'express';
|
|
6
|
+
import { ObservableService } from '@lark-apaas/nestjs-observable';
|
|
6
7
|
|
|
7
8
|
declare abstract class BasePinoLogger implements LoggerService {
|
|
8
9
|
protected readonly logger: Logger;
|
|
@@ -48,7 +49,8 @@ type RequestWithUserContext = Request & {
|
|
|
48
49
|
};
|
|
49
50
|
declare class LoggerContextMiddleware implements NestMiddleware {
|
|
50
51
|
private readonly requestContext;
|
|
51
|
-
|
|
52
|
+
private readonly observableService;
|
|
53
|
+
constructor(requestContext: RequestContextService, observableService: ObservableService);
|
|
52
54
|
use(req: RequestWithUserContext, res: Response, next: NextFunction): void;
|
|
53
55
|
}
|
|
54
56
|
|
package/dist/index.js
CHANGED
|
@@ -15003,6 +15003,7 @@ __name(createFileDestination, "createFileDestination");
|
|
|
15003
15003
|
// src/middleware/logger-context.middleware.ts
|
|
15004
15004
|
import { Injectable as Injectable3 } from "@nestjs/common";
|
|
15005
15005
|
import { randomUUID } from "crypto";
|
|
15006
|
+
import { ObservableService as ObservableService2 } from "@lark-apaas/nestjs-observable";
|
|
15006
15007
|
import { RequestContextService as RequestContextService3 } from "@lark-apaas/nestjs-common";
|
|
15007
15008
|
function _ts_decorate3(decorators, target, key, desc) {
|
|
15008
15009
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -15020,8 +15021,10 @@ var LoggerContextMiddleware = class {
|
|
|
15020
15021
|
__name(this, "LoggerContextMiddleware");
|
|
15021
15022
|
}
|
|
15022
15023
|
requestContext;
|
|
15023
|
-
|
|
15024
|
+
observableService;
|
|
15025
|
+
constructor(requestContext, observableService) {
|
|
15024
15026
|
this.requestContext = requestContext;
|
|
15027
|
+
this.observableService = observableService;
|
|
15025
15028
|
}
|
|
15026
15029
|
use(req, res, next) {
|
|
15027
15030
|
const requestId = req.headers["x-tt-log-id"] ?? randomUUID();
|
|
@@ -15039,13 +15042,22 @@ var LoggerContextMiddleware = class {
|
|
|
15039
15042
|
tenantId: userContext.tenantId,
|
|
15040
15043
|
appId: userContext.appId
|
|
15041
15044
|
}, () => next());
|
|
15045
|
+
this.observableService.log("info", "request start", {
|
|
15046
|
+
requestId,
|
|
15047
|
+
path,
|
|
15048
|
+
method: req.method,
|
|
15049
|
+
userId: userContext.userId,
|
|
15050
|
+
tenantId: userContext.tenantId,
|
|
15051
|
+
appId: userContext.appId
|
|
15052
|
+
});
|
|
15042
15053
|
}
|
|
15043
15054
|
};
|
|
15044
15055
|
LoggerContextMiddleware = _ts_decorate3([
|
|
15045
15056
|
Injectable3(),
|
|
15046
15057
|
_ts_metadata3("design:type", Function),
|
|
15047
15058
|
_ts_metadata3("design:paramtypes", [
|
|
15048
|
-
typeof RequestContextService3 === "undefined" ? Object : RequestContextService3
|
|
15059
|
+
typeof RequestContextService3 === "undefined" ? Object : RequestContextService3,
|
|
15060
|
+
typeof ObservableService2 === "undefined" ? Object : ObservableService2
|
|
15049
15061
|
])
|
|
15050
15062
|
], LoggerContextMiddleware);
|
|
15051
15063
|
|