@autofleet/logger 1.2.0 → 1.2.1-beta-1
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/index.js +17 -0
- package/package.json +2 -1
package/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const winston = require('winston');
|
|
2
|
+
const sizeof = require('object-sizeof');
|
|
2
3
|
const Events = require('@autofleet/events');
|
|
3
4
|
|
|
4
5
|
const { createLogger } = winston;
|
|
@@ -27,6 +28,19 @@ const getLevel = (logLevel) => {
|
|
|
27
28
|
return 'debug';
|
|
28
29
|
};
|
|
29
30
|
|
|
31
|
+
const addLogsSize = winston.format((info) => {
|
|
32
|
+
const logSize = sizeof(info);
|
|
33
|
+
return {
|
|
34
|
+
logSize,
|
|
35
|
+
...info,
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const addStackTrace = winston.format(info => ({
|
|
40
|
+
stackTrace: console.trace(),
|
|
41
|
+
...info,
|
|
42
|
+
}));
|
|
43
|
+
|
|
30
44
|
const enumerateErrorFormat = winston.format((info) => {
|
|
31
45
|
// fix for this crap: https://github.com/googleapis/nodejs-logging-winston/issues/285
|
|
32
46
|
// eslint-disable-next-line no-param-reassign
|
|
@@ -59,12 +73,15 @@ const enumerateErrorFormat = winston.format((info) => {
|
|
|
59
73
|
const getFormat = () => {
|
|
60
74
|
if (isProd) {
|
|
61
75
|
return winston.format.combine(
|
|
76
|
+
addStackTrace(),
|
|
77
|
+
addLogsSize(),
|
|
62
78
|
enumerateErrorFormat(),
|
|
63
79
|
winston.format.json(),
|
|
64
80
|
);
|
|
65
81
|
}
|
|
66
82
|
|
|
67
83
|
return winston.format.combine(
|
|
84
|
+
addLogsSize(),
|
|
68
85
|
enumerateErrorFormat(),
|
|
69
86
|
winston.format.splat(),
|
|
70
87
|
winston.format.colorize(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autofleet/logger",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.1-beta-1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"coverage": "jest --coverage --forceExit --runInBand",
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"@google-cloud/pubsub": "^0.20.1",
|
|
29
29
|
"dotenv": "^5.0.1",
|
|
30
30
|
"jest": "^22.4.4",
|
|
31
|
+
"object-sizeof": "^1.6.1",
|
|
31
32
|
"winston": "^3.0.0"
|
|
32
33
|
},
|
|
33
34
|
"devDependencies": {
|