@autofleet/logger 2.0.0-beta-4 → 2.0.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 +6 -14
- package/package.json +3 -3
package/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
const winston = require('winston');
|
|
2
|
-
const { LoggingWinston } = require('@google-cloud/logging-winston');
|
|
3
2
|
const sizeof = require('object-sizeof');
|
|
4
3
|
|
|
5
4
|
const { createLogger } = winston;
|
|
@@ -7,12 +6,6 @@ require('dotenv').config();
|
|
|
7
6
|
|
|
8
7
|
const { env } = process;
|
|
9
8
|
|
|
10
|
-
const loggingWinston = new LoggingWinston();
|
|
11
|
-
// https://github.com/googleapis/nodejs-logging-winston/issues/428
|
|
12
|
-
loggingWinston.on('error', (err) => {
|
|
13
|
-
console.error('Transport error', err);
|
|
14
|
-
});
|
|
15
|
-
|
|
16
9
|
const isProd = env.NODE_ENV === 'production';
|
|
17
10
|
|
|
18
11
|
const infoEnvNmaes = [
|
|
@@ -38,7 +31,7 @@ const addLogsSize = winston.format((info) => {
|
|
|
38
31
|
const logSize = sizeof(info);
|
|
39
32
|
if (logSize > 256000) {
|
|
40
33
|
console.log(`[WARNING] Found Oversized log with message "${info.message}"`);
|
|
41
|
-
return { message:
|
|
34
|
+
return { message: info.message, logSize };
|
|
42
35
|
}
|
|
43
36
|
|
|
44
37
|
return { ...info, logSize };
|
|
@@ -75,9 +68,11 @@ const enumerateErrorFormat = winston.format((info) => {
|
|
|
75
68
|
|
|
76
69
|
const getFormat = () => {
|
|
77
70
|
if (isProd) {
|
|
78
|
-
return
|
|
71
|
+
return winston.format.combine(
|
|
79
72
|
addLogsSize(),
|
|
80
|
-
|
|
73
|
+
enumerateErrorFormat(),
|
|
74
|
+
winston.format.json(),
|
|
75
|
+
);
|
|
81
76
|
}
|
|
82
77
|
|
|
83
78
|
return winston.format.combine(
|
|
@@ -92,10 +87,7 @@ const createLoggerInstance = (level, exceptionHandlers) => {
|
|
|
92
87
|
const logger = createLogger({
|
|
93
88
|
level,
|
|
94
89
|
format: getFormat(),
|
|
95
|
-
transports:
|
|
96
|
-
new winston.transports.Console(),
|
|
97
|
-
loggingWinston,
|
|
98
|
-
] : [
|
|
90
|
+
transports: [
|
|
99
91
|
new winston.transports.Console(),
|
|
100
92
|
],
|
|
101
93
|
exceptionHandlers,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autofleet/logger",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"coverage": "jest --coverage --forceExit --runInBand",
|
|
@@ -23,11 +23,11 @@
|
|
|
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.1",
|
|
27
27
|
"dotenv": "^5.0.1",
|
|
28
28
|
"jest": "^22.4.4",
|
|
29
29
|
"object-sizeof": "^1.6.1",
|
|
30
|
-
"winston": "^3.
|
|
30
|
+
"winston": "^3.3.3"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"eslint": "^4.19.1",
|