nextrans-logger 0.2.4 → 0.2.6
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/index.cjs +4 -1
- package/lib/index.js +4 -1
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -7,6 +7,9 @@ require('dotenv').config();
|
|
|
7
7
|
const winston_1 = require("winston");
|
|
8
8
|
const winston_cloudwatch_1 = __importDefault(require("winston-cloudwatch"));
|
|
9
9
|
const winston_slack_webhook_transport_1 = __importDefault(require("winston-slack-webhook-transport"));
|
|
10
|
+
function sanitizePolicyData(string) {
|
|
11
|
+
return string.replace(/"(amount|name|beneficiary_name)":\s?"([^"]*)"/g, '"$1": "******"');
|
|
12
|
+
}
|
|
10
13
|
function replaceAnsi(data) {
|
|
11
14
|
const ansiiCodePattern = /[\u001b\u009b][[()#;?]*(?:\d{1,4}(?:;\d{0,4})*)?[0-9A-ORZcf-nqry=><]/g;
|
|
12
15
|
return data.replace(ansiiCodePattern, '');
|
|
@@ -51,7 +54,7 @@ function formatMessage(log, env) {
|
|
|
51
54
|
? '\n```' + JSON.stringify(data, null, '\t') + '```'
|
|
52
55
|
: `${data}`)
|
|
53
56
|
.join(' ');
|
|
54
|
-
return output;
|
|
57
|
+
return sanitizePolicyData(output);
|
|
55
58
|
}
|
|
56
59
|
class Logging {
|
|
57
60
|
constructor({ enable = false, slackWebhook, cloudwatchOption, env = 'DEVELOPMENT', }) {
|
package/lib/index.js
CHANGED
|
@@ -2,6 +2,9 @@ require('dotenv').config();
|
|
|
2
2
|
import { createLogger, format, transports } from 'winston';
|
|
3
3
|
import WinstonCloudwatch from 'winston-cloudwatch';
|
|
4
4
|
import SlackHook from 'winston-slack-webhook-transport';
|
|
5
|
+
function sanitizePolicyData(string) {
|
|
6
|
+
return string.replace(/"(amount|name|beneficiary_name)":\s?"([^"]*)"/g, '"$1": "******"');
|
|
7
|
+
}
|
|
5
8
|
function replaceAnsi(data) {
|
|
6
9
|
const ansiiCodePattern = /[\u001b\u009b][[()#;?]*(?:\d{1,4}(?:;\d{0,4})*)?[0-9A-ORZcf-nqry=><]/g;
|
|
7
10
|
return data.replace(ansiiCodePattern, '');
|
|
@@ -45,7 +48,7 @@ function formatMessage(log, env) {
|
|
|
45
48
|
? '\n```' + JSON.stringify(data, null, '\t') + '```'
|
|
46
49
|
: `${data}`)
|
|
47
50
|
.join(' ');
|
|
48
|
-
return output;
|
|
51
|
+
return sanitizePolicyData(output);
|
|
49
52
|
}
|
|
50
53
|
export default class Logging {
|
|
51
54
|
env = 'DEVELOPMENT';
|