@autofleet/logger 1.3.0-beta-2 → 2.0.0-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 +14 -12
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
const winston = require('winston');
|
|
2
|
-
|
|
2
|
+
const { LoggingWinston } = require('@google-cloud/logging-winston');
|
|
3
|
+
const sizeof = require('object-sizeof');
|
|
3
4
|
|
|
4
5
|
const { createLogger } = winston;
|
|
5
6
|
require('dotenv').config();
|
|
6
7
|
|
|
7
8
|
const { env } = process;
|
|
8
9
|
|
|
10
|
+
const loggingWinston = new LoggingWinston();
|
|
9
11
|
const isProd = env.NODE_ENV === 'production';
|
|
10
12
|
|
|
11
13
|
const infoEnvNmaes = [
|
|
@@ -27,14 +29,14 @@ const getLevel = (logLevel) => {
|
|
|
27
29
|
return 'debug';
|
|
28
30
|
};
|
|
29
31
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
const addLogsSize = winston.format((info) => {
|
|
33
|
+
const logSize = sizeof(info);
|
|
34
|
+
if (logSize > 256000) {
|
|
35
|
+
console.log(`[WARNING] Found Oversized log with message "${info.message}"`);
|
|
36
|
+
}
|
|
35
37
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
return { ...info, logSize };
|
|
39
|
+
});
|
|
38
40
|
|
|
39
41
|
const enumerateErrorFormat = winston.format((info) => {
|
|
40
42
|
// fix for this crap: https://github.com/googleapis/nodejs-logging-winston/issues/285
|
|
@@ -68,14 +70,14 @@ const enumerateErrorFormat = winston.format((info) => {
|
|
|
68
70
|
const getFormat = () => {
|
|
69
71
|
if (isProd) {
|
|
70
72
|
return winston.format.combine(
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
73
|
+
new winston.transports.Console(),
|
|
74
|
+
// Add Stackdriver Logging
|
|
75
|
+
loggingWinston,
|
|
74
76
|
);
|
|
75
77
|
}
|
|
76
78
|
|
|
77
79
|
return winston.format.combine(
|
|
78
|
-
|
|
80
|
+
addLogsSize(),
|
|
79
81
|
enumerateErrorFormat(),
|
|
80
82
|
winston.format.splat(),
|
|
81
83
|
winston.format.simple(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autofleet/logger",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-beta-1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"coverage": "jest --coverage --forceExit --runInBand",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"homepage": "https://github.com/Autofleet/logger",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@google-cloud/logging-winston": "^4.1.
|
|
26
|
+
"@google-cloud/logging-winston": "^4.1.3",
|
|
27
27
|
"dotenv": "^5.0.1",
|
|
28
28
|
"jest": "^22.4.4",
|
|
29
29
|
"object-sizeof": "^1.6.1",
|