@autofleet/node-common 1.1.31 → 1.1.35
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/logger/index.js +18 -4
- package/network/index.js +4 -8
- package/package.json +2 -2
package/logger/index.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
const winston = require('winston');
|
|
2
|
-
const { LoggingWinston } = require('@google-cloud/logging-winston');
|
|
3
|
-
|
|
4
|
-
const loggingWinston = new LoggingWinston();
|
|
5
2
|
|
|
6
3
|
const { createLogger } = winston;
|
|
7
4
|
require('dotenv').config();
|
|
@@ -22,12 +19,29 @@ const getLevel = (logLevel) => {
|
|
|
22
19
|
return 'debug';
|
|
23
20
|
};
|
|
24
21
|
|
|
22
|
+
const enumerateErrorFormat = winston.format((info) => {
|
|
23
|
+
if (info.message instanceof Error) {
|
|
24
|
+
info.message = Object.assign({ // eslint-disable-line
|
|
25
|
+
message: info.message.message,
|
|
26
|
+
stack: info.message.stack,
|
|
27
|
+
}, info.message);
|
|
28
|
+
}
|
|
29
|
+
if (info instanceof Error) {
|
|
30
|
+
return Object.assign({
|
|
31
|
+
message: info.message,
|
|
32
|
+
stack: info.stack,
|
|
33
|
+
}, info);
|
|
34
|
+
}
|
|
35
|
+
return info;
|
|
36
|
+
});
|
|
37
|
+
|
|
25
38
|
const getFormat = () => {
|
|
26
39
|
if (env.NODE_ENV === 'producation') {
|
|
27
40
|
return winston.format.json();
|
|
28
41
|
}
|
|
29
42
|
|
|
30
43
|
return winston.format.combine(
|
|
44
|
+
enumerateErrorFormat(),
|
|
31
45
|
winston.format.splat(),
|
|
32
46
|
winston.format.colorize(),
|
|
33
47
|
winston.format.simple(),
|
|
@@ -38,7 +52,7 @@ const createLoggerInstance = (level, transports) => {
|
|
|
38
52
|
const logger = createLogger({
|
|
39
53
|
level,
|
|
40
54
|
format: getFormat(),
|
|
41
|
-
transports: [new winston.transports.Console()
|
|
55
|
+
transports: [new winston.transports.Console()],
|
|
42
56
|
exceptionHandlers: transports,
|
|
43
57
|
exitOnError: false,
|
|
44
58
|
});
|
package/network/index.js
CHANGED
|
@@ -51,9 +51,9 @@ module.exports = class Network {
|
|
|
51
51
|
const logger = Logger();
|
|
52
52
|
this.axios.interceptors.request.use((request) => {
|
|
53
53
|
logger.info(`Start Request: [${request.method.toUpperCase()}] ${request.baseURL} ${request.url}`, {
|
|
54
|
-
query: request.params,
|
|
55
|
-
body: request.data,
|
|
56
54
|
headers: request.headers,
|
|
55
|
+
query: request.query,
|
|
56
|
+
body: request.body,
|
|
57
57
|
});
|
|
58
58
|
return request;
|
|
59
59
|
});
|
|
@@ -62,12 +62,8 @@ module.exports = class Network {
|
|
|
62
62
|
logger.info(`Finish Request: [${response.config.method.toUpperCase()} ${response.config.url}`);
|
|
63
63
|
return response;
|
|
64
64
|
}, (error) => {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
} else {
|
|
68
|
-
logger.error(`Finish Request with error: ${error}`);
|
|
69
|
-
}
|
|
70
|
-
// throw error; // TODO: think about that.. for its break the vehiclems tests
|
|
65
|
+
logger.error(`Finish Request with error: ${error.response.data.message}`);
|
|
66
|
+
throw error;
|
|
71
67
|
});
|
|
72
68
|
}
|
|
73
69
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autofleet/node-common",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.35",
|
|
4
4
|
"description": "",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"coverage": "jest --coverage --forceExit --runInBand",
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
},
|
|
23
23
|
"homepage": "https://gitlab.com/AutoFleet/node-common#README",
|
|
24
24
|
"dependencies": {
|
|
25
|
+
"@google-cloud/logging-winston": "^0.10.1",
|
|
25
26
|
"@google-cloud/monitoring": "^0.6.0",
|
|
26
27
|
"@google-cloud/profiler": "^0.2.0",
|
|
27
|
-
"@google-cloud/logging-winston": "^0.9.1",
|
|
28
28
|
"@google-cloud/pubsub": "^0.19.0",
|
|
29
29
|
"axios": "^0.18.0",
|
|
30
30
|
"axios-retry": "^3.1.0",
|