@nocobase/logger 2.0.0-alpha.6 → 2.0.0-alpha.60
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/lib/request-logger.js +4 -3
- package/package.json +2 -2
package/lib/request-logger.js
CHANGED
|
@@ -50,7 +50,7 @@ const defaultActionBlackList = [
|
|
|
50
50
|
];
|
|
51
51
|
const requestLogger = /* @__PURE__ */ __name((appName, requestLogger2, options) => {
|
|
52
52
|
return /* @__PURE__ */ __name(async function requestLoggerMiddleware(ctx, next) {
|
|
53
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
53
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
54
54
|
const reqId = ctx.reqId;
|
|
55
55
|
const path = /^\/api\/(.+):(.+)/.exec(ctx.path);
|
|
56
56
|
const contextLogger = ctx.app.log.child({ reqId, module: path == null ? void 0 : path[1], submodule: path == null ? void 0 : path[2] });
|
|
@@ -83,6 +83,7 @@ const requestLogger = /* @__PURE__ */ __name((appName, requestLogger2, options)
|
|
|
83
83
|
res: (0, import_lodash.pick)(ctx.response.toJSON(), (options == null ? void 0 : options.responseWhitelist) || defaultResponseWhitelist),
|
|
84
84
|
action: (0, import_lodash.omit)((_d = (_c = ctx.action) == null ? void 0 : _c.toJSON) == null ? void 0 : _d.call(_c), defaultActionBlackList),
|
|
85
85
|
userId: (_f = (_e = ctx.auth) == null ? void 0 : _e.user) == null ? void 0 : _f.id,
|
|
86
|
+
username: (_h = (_g = ctx.auth) == null ? void 0 : _g.user) == null ? void 0 : _h.username,
|
|
86
87
|
status: ctx.status,
|
|
87
88
|
cost,
|
|
88
89
|
app: appName,
|
|
@@ -90,9 +91,9 @@ const requestLogger = /* @__PURE__ */ __name((appName, requestLogger2, options)
|
|
|
90
91
|
bodySize: ctx.response.length
|
|
91
92
|
};
|
|
92
93
|
if (Math.floor(status / 100) == 5) {
|
|
93
|
-
requestLogger2.error({ ...info, res: ((
|
|
94
|
+
requestLogger2.error({ ...info, res: ((_i = ctx.body) == null ? void 0 : _i["errors"]) || ctx.body });
|
|
94
95
|
} else if (Math.floor(status / 100) == 4) {
|
|
95
|
-
requestLogger2.warn({ ...info, res: ((
|
|
96
|
+
requestLogger2.warn({ ...info, res: ((_j = ctx.body) == null ? void 0 : _j["errors"]) || ctx.body });
|
|
96
97
|
} else {
|
|
97
98
|
requestLogger2.info(info);
|
|
98
99
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/logger",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.60",
|
|
4
4
|
"description": "nocobase logging library",
|
|
5
5
|
"license": "AGPL-3.0",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -18,5 +18,5 @@
|
|
|
18
18
|
"winston-daily-rotate-file": "^5.0.0",
|
|
19
19
|
"winston-transport": "^4.7.0"
|
|
20
20
|
},
|
|
21
|
-
"gitHead": "
|
|
21
|
+
"gitHead": "9113d61ce85b60b7ba3d0e5ca64182d92a15ece4"
|
|
22
22
|
}
|