@lark-apaas/nestjs-logger 1.0.1-alpha.3 → 1.0.2

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 CHANGED
@@ -14816,6 +14816,7 @@ var logger_config_default = (0, import_config.registerAs)("logger", () => {
14816
14816
  var import_common3 = require("@nestjs/common");
14817
14817
  var import_config2 = __toESM(require_config2(), 1);
14818
14818
  var import_operators = __toESM(require_operators(), 1);
14819
+ var import_util2 = require("util");
14819
14820
  function _ts_decorate3(decorators, target, key, desc) {
14820
14821
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
14821
14822
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -14946,6 +14947,7 @@ duration_ms=${durationMs}`, "HTTPTraceInterceptor");
14946
14947
  this.traceLogger.logStructured(traceLevel, isError ? "HTTP request failed" : "HTTP request completed", responseMeta, "HTTPTraceInterceptor");
14947
14948
  });
14948
14949
  return next.handle().pipe((0, import_operators.catchError)((error) => {
14950
+ this.appLogger.error((0, import_util2.format)("HTTP request exception\nmethod=%s url=%s\nerror=%o", req.method, req.url, error), "HTTPTraceInterceptor");
14949
14951
  throw error;
14950
14952
  }));
14951
14953
  }
@@ -15061,13 +15063,14 @@ var LoggerContextMiddleware = class {
15061
15063
  constructor(requestContext) {
15062
15064
  this.requestContext = requestContext;
15063
15065
  }
15064
- use(req, _res, next) {
15066
+ use(req, res, next) {
15065
15067
  const requestId = req.headers["x-tt-log-id"] ?? (0, import_crypto.randomUUID)();
15066
15068
  const path = req.originalUrl ?? req.url;
15067
15069
  const userContext = req.userContext ?? {};
15068
15070
  const mutableReq = req;
15069
15071
  mutableReq.requestId = requestId;
15070
15072
  mutableReq.id = requestId;
15073
+ res.setHeader("x-log-trace-id", requestId);
15071
15074
  this.requestContext.run({
15072
15075
  requestId,
15073
15076
  path,