@athenna/logger 5.5.0 → 5.7.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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@athenna/logger",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.7.0",
|
|
4
4
|
"description": "The Athenna logging solution. Log in stdout, files and buckets.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "João Lenon <lenon@athenna.io>",
|
|
@@ -66,21 +66,21 @@
|
|
|
66
66
|
"telegraf": "^4.16.3"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
|
-
"@athenna/common": "^5.
|
|
70
|
-
"@athenna/config": "^5.
|
|
71
|
-
"@athenna/ioc": "^5.
|
|
72
|
-
"@athenna/test": "^5.
|
|
69
|
+
"@athenna/common": "^5.14.0",
|
|
70
|
+
"@athenna/config": "^5.4.0",
|
|
71
|
+
"@athenna/ioc": "^5.2.0",
|
|
72
|
+
"@athenna/test": "^5.5.0",
|
|
73
73
|
"@athenna/tsconfig": "^5.0.0",
|
|
74
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
75
|
-
"@typescript-eslint/parser": "^8.
|
|
74
|
+
"@typescript-eslint/eslint-plugin": "^8.38.0",
|
|
75
|
+
"@typescript-eslint/parser": "^8.38.0",
|
|
76
76
|
"commitizen": "^4.3.1",
|
|
77
77
|
"cz-conventional-changelog": "^3.3.0",
|
|
78
78
|
"eslint": "^8.57.1",
|
|
79
|
-
"eslint-config-prettier": "^8.10.
|
|
79
|
+
"eslint-config-prettier": "^8.10.2",
|
|
80
80
|
"eslint-config-standard": "^17.1.0",
|
|
81
|
-
"eslint-plugin-import": "^2.
|
|
81
|
+
"eslint-plugin-import": "^2.32.0",
|
|
82
82
|
"eslint-plugin-n": "^15.7.0",
|
|
83
|
-
"eslint-plugin-prettier": "^4.2.
|
|
83
|
+
"eslint-plugin-prettier": "^4.2.5",
|
|
84
84
|
"eslint-plugin-promise": "^6.6.0",
|
|
85
85
|
"husky": "^3.1.0",
|
|
86
86
|
"lint-staged": "^12.5.0",
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
* For the full copyright and license information, please view the LICENSE
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
|
+
import { debug } from '#src/debug';
|
|
9
10
|
import { File } from '@athenna/common';
|
|
10
11
|
import { Driver } from '#src/drivers/Driver';
|
|
11
|
-
import { debug } from '#src/debug';
|
|
12
12
|
export class FileDriver extends Driver {
|
|
13
13
|
async transport(level, message) {
|
|
14
14
|
if (!this.couldBeTransported(level)) {
|
|
@@ -39,6 +39,11 @@ export declare abstract class Formatter {
|
|
|
39
39
|
* Create the timestamp for formatter.
|
|
40
40
|
*/
|
|
41
41
|
timestamp(): string;
|
|
42
|
+
/**
|
|
43
|
+
* Get the circular replacer function to be used in
|
|
44
|
+
* JSON.stringify().
|
|
45
|
+
*/
|
|
46
|
+
getCircularReplacer(): (key: any, value: any) => any;
|
|
42
47
|
/**
|
|
43
48
|
* Transform the message to string.
|
|
44
49
|
*/
|
|
@@ -61,6 +61,26 @@ export class Formatter {
|
|
|
61
61
|
};
|
|
62
62
|
return new Date(Date.now()).toLocaleString(undefined, localeStringOptions);
|
|
63
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Get the circular replacer function to be used in
|
|
66
|
+
* JSON.stringify().
|
|
67
|
+
*/
|
|
68
|
+
getCircularReplacer() {
|
|
69
|
+
const ancestors = [];
|
|
70
|
+
return function (key, value) {
|
|
71
|
+
if (!Is.Object(value) || value === null) {
|
|
72
|
+
return value;
|
|
73
|
+
}
|
|
74
|
+
while (ancestors.length > 0 && ancestors.at(-1) !== this) {
|
|
75
|
+
ancestors.pop();
|
|
76
|
+
}
|
|
77
|
+
if (ancestors.includes(value)) {
|
|
78
|
+
return '[Circular]';
|
|
79
|
+
}
|
|
80
|
+
ancestors.push(value);
|
|
81
|
+
return value;
|
|
82
|
+
};
|
|
83
|
+
}
|
|
64
84
|
/**
|
|
65
85
|
* Transform the message to string.
|
|
66
86
|
*/
|
|
@@ -69,7 +89,7 @@ export class Formatter {
|
|
|
69
89
|
return message;
|
|
70
90
|
}
|
|
71
91
|
if (Is.Object(message)) {
|
|
72
|
-
message = JSON.stringify(message);
|
|
92
|
+
message = JSON.stringify(message, this.getCircularReplacer());
|
|
73
93
|
}
|
|
74
94
|
return `${message}`;
|
|
75
95
|
}
|
|
@@ -19,8 +19,8 @@ export class JsonFormatter extends Formatter {
|
|
|
19
19
|
};
|
|
20
20
|
if (Is.String(message)) {
|
|
21
21
|
base.msg = message;
|
|
22
|
-
return JSON.stringify(base);
|
|
22
|
+
return JSON.stringify(base, this.getCircularReplacer());
|
|
23
23
|
}
|
|
24
|
-
return JSON.stringify({ ...base, ...message });
|
|
24
|
+
return JSON.stringify({ ...base, ...message }, this.getCircularReplacer());
|
|
25
25
|
}
|
|
26
26
|
}
|
|
@@ -44,6 +44,6 @@ export class RequestFormatter extends Formatter {
|
|
|
44
44
|
body: ctx.response.body,
|
|
45
45
|
headers: ctx.response.headers
|
|
46
46
|
};
|
|
47
|
-
return JSON.stringify({ request, response, metadata });
|
|
47
|
+
return JSON.stringify({ request, response, metadata }, this.getCircularReplacer());
|
|
48
48
|
}
|
|
49
49
|
}
|