@riocrypto/common-server 1.0.2016 → 1.0.2017
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.
|
@@ -35,11 +35,15 @@ function maskHeaders(headers) {
|
|
|
35
35
|
// Request Interceptor
|
|
36
36
|
axiosWithLogging.interceptors.request.use((config) => {
|
|
37
37
|
var _a;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
const customConfig = config;
|
|
39
|
+
// Check if logging is disabled for this request
|
|
40
|
+
if (!customConfig.skipLogging) {
|
|
41
|
+
// Mask sensitive headers in the configuration
|
|
42
|
+
const maskedHeaders = maskHeaders(customConfig.headers);
|
|
43
|
+
// Combine and log the full request configuration with masked headers
|
|
44
|
+
const logMessage = `Request: method=${customConfig.method}, url=${customConfig.url}, headers=${JSON.stringify(maskedHeaders)}, data=${JSON.stringify(customConfig.data)}`;
|
|
45
|
+
((_a = logger_1.default.getLogger()) === null || _a === void 0 ? void 0 : _a.info(logMessage)) || console.log(logMessage);
|
|
46
|
+
}
|
|
43
47
|
return config;
|
|
44
48
|
}, (error) => {
|
|
45
49
|
var _a;
|
|
@@ -51,14 +55,20 @@ axiosWithLogging.interceptors.request.use((config) => {
|
|
|
51
55
|
// Response Interceptor
|
|
52
56
|
axiosWithLogging.interceptors.response.use((response) => {
|
|
53
57
|
var _a;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
58
|
+
const customConfig = response.config;
|
|
59
|
+
// Check if logging is disabled for this request
|
|
60
|
+
if (!customConfig.skipLogging) {
|
|
61
|
+
// Combine and log the full response details
|
|
62
|
+
const logMessage = `Response: url=${customConfig.url}, status=${response.status}, data=${JSON.stringify(response.data)}`;
|
|
63
|
+
((_a = logger_1.default.getLogger()) === null || _a === void 0 ? void 0 : _a.info(logMessage)) || console.log(logMessage);
|
|
64
|
+
}
|
|
57
65
|
return response;
|
|
58
66
|
}, (error) => {
|
|
59
67
|
var _a;
|
|
68
|
+
// Mask sensitive headers in the error config
|
|
69
|
+
const maskedHeaders = error.config ? maskHeaders(error.config.headers) : {};
|
|
60
70
|
// Combine and log the response error details
|
|
61
|
-
let logMessage = `Response Error: url=${error.config ? error.config.url : "unknown"}, message=${error.message}`;
|
|
71
|
+
let logMessage = `Response Error: url=${error.config ? error.config.url : "unknown"}, message=${error.message}, headers=${JSON.stringify(maskedHeaders)}`;
|
|
62
72
|
if (error.response) {
|
|
63
73
|
logMessage += `, status=${error.response.status}, data=${JSON.stringify(error.response.data)}`;
|
|
64
74
|
}
|