@athenna/logger 5.18.0 → 5.19.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
|
@@ -70,7 +70,7 @@ export class Formatter {
|
|
|
70
70
|
const contextBindings = this.configs.contextBindings || [];
|
|
71
71
|
const resolved = {};
|
|
72
72
|
for (const binding of contextBindings) {
|
|
73
|
-
const value = binding.
|
|
73
|
+
const value = binding.resolve(activeContext);
|
|
74
74
|
if (Is.Undefined(value)) {
|
|
75
75
|
continue;
|
|
76
76
|
}
|
|
@@ -12,13 +12,14 @@ export class JsonFormatter extends Formatter {
|
|
|
12
12
|
format(message) {
|
|
13
13
|
const base = {
|
|
14
14
|
...(this.configs.defaults || {}),
|
|
15
|
-
...this.contextBindings(),
|
|
16
15
|
level: this.level(),
|
|
17
|
-
|
|
16
|
+
date: new Date().toISOString(),
|
|
17
|
+
timestamp: Date.now(),
|
|
18
18
|
pid: this.pid(),
|
|
19
19
|
hostname: this.hostname(),
|
|
20
20
|
traceId: this.traceId(),
|
|
21
|
-
spanId: this.spanId()
|
|
21
|
+
spanId: this.spanId(),
|
|
22
|
+
...this.contextBindings(),
|
|
22
23
|
};
|
|
23
24
|
if (Is.String(message)) {
|
|
24
25
|
base.msg = message;
|
|
@@ -21,6 +21,17 @@ export class RequestFormatter extends Formatter {
|
|
|
21
21
|
if (!this.configs.asJson) {
|
|
22
22
|
return this.clean(`${method}${status} ${ctx.request.baseUrl} - ${date} - ${responseTimeMs}`);
|
|
23
23
|
}
|
|
24
|
+
const base = {
|
|
25
|
+
...(this.configs.defaults || {}),
|
|
26
|
+
level: this.level(),
|
|
27
|
+
date,
|
|
28
|
+
timestamp: Date.now(),
|
|
29
|
+
pid: this.pid(),
|
|
30
|
+
hostname: this.hostname(),
|
|
31
|
+
traceId: this.traceId(),
|
|
32
|
+
spanId: this.spanId(),
|
|
33
|
+
...this.contextBindings()
|
|
34
|
+
};
|
|
24
35
|
const metadata = {
|
|
25
36
|
method: ctx.request.method,
|
|
26
37
|
duration: responseTimeMs,
|
|
@@ -28,9 +39,6 @@ export class RequestFormatter extends Formatter {
|
|
|
28
39
|
statusCode,
|
|
29
40
|
url: ctx.request.hostUrl,
|
|
30
41
|
path: ctx.request.baseUrl,
|
|
31
|
-
createdAt: Date.now(),
|
|
32
|
-
traceId: this.traceId(),
|
|
33
|
-
spanId: this.spanId(),
|
|
34
42
|
data: ctx.data
|
|
35
43
|
};
|
|
36
44
|
const request = {
|
|
@@ -45,6 +53,6 @@ export class RequestFormatter extends Formatter {
|
|
|
45
53
|
body: ctx.response.body,
|
|
46
54
|
headers: ctx.response.headers
|
|
47
55
|
};
|
|
48
|
-
return JSON.stringify({ request, response, metadata }, this.getCircularReplacer());
|
|
56
|
+
return JSON.stringify({ ...base, request, response, metadata }, this.getCircularReplacer());
|
|
49
57
|
}
|
|
50
58
|
}
|