@rdyl/node-koa-controller 0.1.2 → 0.1.3
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/CHANGELOG.md +1 -1
- package/dist/controller/index.js +10 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/controller/index.js
CHANGED
|
@@ -190,7 +190,7 @@ function useController(app, opts) {
|
|
|
190
190
|
}
|
|
191
191
|
if (logs) {
|
|
192
192
|
app.use(function (ctx, next) { return __awaiter(_this, void 0, void 0, function () {
|
|
193
|
-
var start, duration, status_1, method, statusColor, dateTime;
|
|
193
|
+
var start, duration, status_1, method, statusColor, dateTime, dText;
|
|
194
194
|
return __generator(this, function (_a) {
|
|
195
195
|
switch (_a.label) {
|
|
196
196
|
case 0:
|
|
@@ -205,7 +205,7 @@ function useController(app, opts) {
|
|
|
205
205
|
case 3:
|
|
206
206
|
duration = Date.now() - start;
|
|
207
207
|
status_1 = ctx.status;
|
|
208
|
-
method = ctx.method
|
|
208
|
+
method = ctx.method;
|
|
209
209
|
statusColor = void 0;
|
|
210
210
|
if (status_1 >= 500)
|
|
211
211
|
statusColor = chalk_1.default.red;
|
|
@@ -218,7 +218,14 @@ function useController(app, opts) {
|
|
|
218
218
|
else
|
|
219
219
|
statusColor = chalk_1.default.gray;
|
|
220
220
|
dateTime = (0, utils_1.formatDateTime)();
|
|
221
|
-
|
|
221
|
+
dText = chalk_1.default.gray("".concat(duration, "ms"));
|
|
222
|
+
if (duration > 5000) {
|
|
223
|
+
dText = chalk_1.default.red("".concat(duration, "ms"));
|
|
224
|
+
}
|
|
225
|
+
else if (duration > 1000) {
|
|
226
|
+
dText = chalk_1.default.yellow("".concat(duration, "ms"));
|
|
227
|
+
}
|
|
228
|
+
console.log("- [".concat(dateTime, " | ").concat(dText, "] ").concat(chalk_1.default.magenta(method), " ").concat(ctx.url, " ").concat(statusColor(status_1)));
|
|
222
229
|
return [7 /*endfinally*/];
|
|
223
230
|
case 4: return [2 /*return*/];
|
|
224
231
|
}
|