@go-mailer/jarvis 3.1.2 → 3.1.4
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/lib/middlewares/logger.js +11 -6
- package/lib/query.js +1 -1
- package/package.json +1 -1
|
@@ -8,6 +8,11 @@ const { Logtail } = require("@logtail/node");
|
|
|
8
8
|
const LOGTAIL_SECRET = Env.fetch("LOGTAIL_SECRET", true);
|
|
9
9
|
const logtail = new Logtail(LOGTAIL_SECRET);
|
|
10
10
|
|
|
11
|
+
function hashLogData (log = {}) {
|
|
12
|
+
const hashed = JSON.stringify(log).replace(/\w+@/gi, '************')
|
|
13
|
+
return JSON.parse(hashed)
|
|
14
|
+
}
|
|
15
|
+
|
|
11
16
|
function RequestLogger() {
|
|
12
17
|
const app_name = Env.fetch("APP_NAME", true);
|
|
13
18
|
return (request, response, next) => {
|
|
@@ -54,9 +59,9 @@ function RequestLogger() {
|
|
|
54
59
|
let error = payload ? payload.error : statusMessage;
|
|
55
60
|
if (error) {
|
|
56
61
|
log.error = error;
|
|
57
|
-
logtail.error(pathname, log);
|
|
62
|
+
logtail.error(pathname, hashLogData(log));
|
|
58
63
|
} else {
|
|
59
|
-
logtail.info(pathname, log);
|
|
64
|
+
logtail.info(pathname, hashLogData(log));
|
|
60
65
|
}
|
|
61
66
|
|
|
62
67
|
logtail.flush();
|
|
@@ -72,25 +77,25 @@ class ProcessLogger {
|
|
|
72
77
|
}
|
|
73
78
|
|
|
74
79
|
error(error, method = "unspecified_method", params = {}) {
|
|
75
|
-
logtail.error(`${this.service}:${method}:${error.message}`, {
|
|
80
|
+
logtail.error(`${this.service}:${method}:${error.message}`, hashLogData({
|
|
76
81
|
app_name: Env.fetch("APP_NAME", true),
|
|
77
82
|
type: "process",
|
|
78
83
|
message: error.message,
|
|
79
84
|
trace: error.stack,
|
|
80
85
|
params,
|
|
81
|
-
});
|
|
86
|
+
}));
|
|
82
87
|
logtail.flush();
|
|
83
88
|
}
|
|
84
89
|
|
|
85
90
|
info(info, method = "unspecified_method", params = {}) {
|
|
86
91
|
const message_str = `${this.service}:${method}:${info}`;
|
|
87
92
|
console.log(message_str);
|
|
88
|
-
logtail.info(message_str, {
|
|
93
|
+
logtail.info(message_str, hashLogData({
|
|
89
94
|
app_name: Env.fetch("APP_NAME", true),
|
|
90
95
|
type: "process",
|
|
91
96
|
message: info,
|
|
92
97
|
params,
|
|
93
|
-
});
|
|
98
|
+
}));
|
|
94
99
|
logtail.flush();
|
|
95
100
|
}
|
|
96
101
|
}
|
package/lib/query.js
CHANGED
|
@@ -2,7 +2,7 @@ const buildQuery = (options) => {
|
|
|
2
2
|
const sort_condition = options.sort_by ? buildSortOrderString(options.sort_by) : ''
|
|
3
3
|
const fields_to_return = options.return_only ? buildReturnFieldsString(options.return_only) : ''
|
|
4
4
|
const count = options.count || false
|
|
5
|
-
const seek_conditions = { ...buildBooleanQuery(options.bool || '')}
|
|
5
|
+
const seek_conditions = options.bool ? { ...buildBooleanQuery(options.bool || '')} : {}
|
|
6
6
|
|
|
7
7
|
const { skip, limit } = determinePagination(options.page, options.population)
|
|
8
8
|
|