@riocrypto/common-server 1.0.1894 → 1.0.1897
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/build/services/logger.d.ts +1 -0
- package/build/services/logger.js +22 -22
- package/package.json +1 -1
package/build/services/logger.js
CHANGED
|
@@ -9,7 +9,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const common_1 = require("@riocrypto/common");
|
|
13
12
|
const winston_1 = require("winston");
|
|
14
13
|
class LoggerService {
|
|
15
14
|
constructor() {
|
|
@@ -71,6 +70,15 @@ class LoggerService {
|
|
|
71
70
|
}
|
|
72
71
|
return info;
|
|
73
72
|
});
|
|
73
|
+
this.requestMethodFilter = (0, winston_1.format)((info) => {
|
|
74
|
+
const allowedMethods = ["POST", "PATCH", "DELETE"];
|
|
75
|
+
if (info.meta &&
|
|
76
|
+
info.meta.req &&
|
|
77
|
+
allowedMethods.includes(info.meta.req.method)) {
|
|
78
|
+
return info;
|
|
79
|
+
}
|
|
80
|
+
return false; // Filter out logs for other methods
|
|
81
|
+
});
|
|
74
82
|
this.logger = null;
|
|
75
83
|
}
|
|
76
84
|
maskValue(value) {
|
|
@@ -86,27 +94,19 @@ class LoggerService {
|
|
|
86
94
|
}
|
|
87
95
|
initLogger() {
|
|
88
96
|
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
this.logger = (0, winston_1.createLogger)({
|
|
105
|
-
level: "error",
|
|
106
|
-
format: winston_1.format.combine(winston_1.format.timestamp(), this.maskSensitiveData(), winston_1.format.json(), winston_1.format.metadata(), winston_1.format.prettyPrint()),
|
|
107
|
-
transports: [new winston_1.transports.Console()],
|
|
108
|
-
});
|
|
109
|
-
}
|
|
97
|
+
const logLevel = "info";
|
|
98
|
+
const transportsArray = [new winston_1.transports.Console()];
|
|
99
|
+
const { getWinsonTransport } = yield require("@hyperdx/node-opentelemetry");
|
|
100
|
+
transportsArray.push(getWinsonTransport("info", {
|
|
101
|
+
apiKey: process.env.HYPERDX_API_KEY,
|
|
102
|
+
service: process.env.OTEL_SERVICE_NAME,
|
|
103
|
+
}));
|
|
104
|
+
this.logger = (0, winston_1.createLogger)({
|
|
105
|
+
level: logLevel,
|
|
106
|
+
format: winston_1.format.combine(winston_1.format.timestamp(), this.maskSensitiveData(), this.requestMethodFilter(), // Add the request method filter
|
|
107
|
+
winston_1.format.json(), winston_1.format.prettyPrint()),
|
|
108
|
+
transports: transportsArray,
|
|
109
|
+
});
|
|
110
110
|
});
|
|
111
111
|
}
|
|
112
112
|
}
|