@athenna/logger 4.19.0 → 4.20.0
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/package.json
CHANGED
|
@@ -13,8 +13,9 @@ export class RequestFormatter extends Formatter {
|
|
|
13
13
|
if (Is.String(ctx)) {
|
|
14
14
|
return ctx;
|
|
15
15
|
}
|
|
16
|
-
const
|
|
17
|
-
const
|
|
16
|
+
const statusCode = ctx.response.statusCode;
|
|
17
|
+
const responseTimeMs = `${Math.round(ctx.response.responseTime)}ms`;
|
|
18
|
+
const status = Color.statusCode(ctx.response.statusCode);
|
|
18
19
|
const method = Color.httpMethod(ctx.request.method);
|
|
19
20
|
const date = new Date().toISOString();
|
|
20
21
|
if (!this.configs.asJson) {
|
|
@@ -23,8 +24,8 @@ export class RequestFormatter extends Formatter {
|
|
|
23
24
|
const metadata = {
|
|
24
25
|
method: ctx.request.method,
|
|
25
26
|
duration: responseTimeMs,
|
|
26
|
-
status:
|
|
27
|
-
statusCode
|
|
27
|
+
status: statusCode <= 399 ? 'SUCCESS' : 'ERROR',
|
|
28
|
+
statusCode,
|
|
28
29
|
url: ctx.request.hostUrl,
|
|
29
30
|
path: ctx.request.baseUrl,
|
|
30
31
|
createdAt: Date.now(),
|
|
@@ -40,8 +41,8 @@ export class RequestFormatter extends Formatter {
|
|
|
40
41
|
headers: ctx.request.headers
|
|
41
42
|
};
|
|
42
43
|
const response = {
|
|
43
|
-
body: ctx.body,
|
|
44
|
-
headers: ctx.headers
|
|
44
|
+
body: ctx.response.body,
|
|
45
|
+
headers: ctx.response.headers
|
|
45
46
|
};
|
|
46
47
|
return JSON.stringify({ request, response, metadata });
|
|
47
48
|
}
|