nextrans-logger 0.1.11 → 0.1.13

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 CHANGED
@@ -36,15 +36,16 @@ function formatMessage(log, env) {
36
36
  }
37
37
  if (typeof (log === null || log === void 0 ? void 0 : log.stack) !== 'undefined') {
38
38
  message.push('\n');
39
- message.push(log === null || log === void 0 ? void 0 : log.stack);
39
+ message.push('```' + (log === null || log === void 0 ? void 0 : log.stack) + '```');
40
40
  }
41
41
  else if (typeof (log === null || log === void 0 ? void 0 : log.options) !== 'undefined') {
42
42
  message.push('\n');
43
43
  message.push(log === null || log === void 0 ? void 0 : log.options);
44
44
  }
45
- return message
46
- .map((data) => (typeof data === 'object' ? '\n```' + JSON.stringify(data, null, '\t') + '```' : `\`${data}\``))
45
+ const output = message
46
+ .map((data) => (typeof data === 'object' ? '\n```' + JSON.stringify(data, null, '\t') + '```' : `${data}`))
47
47
  .join(' ');
48
+ return output;
48
49
  }
49
50
  class Logging {
50
51
  constructor({ enable = false, slackWebhook, cloudwatchOption, env = 'DEVELOPMENT' }) {
@@ -76,7 +77,9 @@ class Logging {
76
77
  const slack = (level) => new winston_slack_webhook_transport_1.default({
77
78
  level,
78
79
  webhookUrl: this.slackWebhook,
79
- formatter: (log) => ({ text: `:sos: ${formatMessage(log, this.env)}` }),
80
+ formatter: (log) => ({
81
+ text: `:sos: ${formatMessage(log, this.env).replace(/\[31m/g, '').replace(/\[39m/g, '')}`,
82
+ }),
80
83
  });
81
84
  transportsData.push(slack('error'));
82
85
  }
@@ -101,7 +104,7 @@ class Logging {
101
104
  region: (_c = this.cloudwatchOption) === null || _c === void 0 ? void 0 : _c.region,
102
105
  credentials: (_d = this === null || this === void 0 ? void 0 : this.cloudwatchOption) === null || _d === void 0 ? void 0 : _d.credentials,
103
106
  },
104
- messageFormatter: (log) => this.lineFormat(log),
107
+ messageFormatter: (log) => this.lineFormat(log).replace(/\[31m/g, '').replace(/\[39m/g, ''),
105
108
  });
106
109
  };
107
110
  log.add(cloudwatch());
package/lib/index.js CHANGED
@@ -30,15 +30,16 @@ function formatMessage(log, env) {
30
30
  }
31
31
  if (typeof log?.stack !== 'undefined') {
32
32
  message.push('\n');
33
- message.push(log?.stack);
33
+ message.push('```' + log?.stack + '```');
34
34
  }
35
35
  else if (typeof log?.options !== 'undefined') {
36
36
  message.push('\n');
37
37
  message.push(log?.options);
38
38
  }
39
- return message
40
- .map((data) => (typeof data === 'object' ? '\n```' + JSON.stringify(data, null, '\t') + '```' : `\`${data}\``))
39
+ const output = message
40
+ .map((data) => (typeof data === 'object' ? '\n```' + JSON.stringify(data, null, '\t') + '```' : `${data}`))
41
41
  .join(' ');
42
+ return output;
42
43
  }
43
44
  export default class Logging {
44
45
  env = 'DEVELOPMENT';
@@ -71,7 +72,9 @@ export default class Logging {
71
72
  const slack = (level) => new SlackHook({
72
73
  level,
73
74
  webhookUrl: this.slackWebhook,
74
- formatter: (log) => ({ text: `:sos: ${formatMessage(log, this.env)}` }),
75
+ formatter: (log) => ({
76
+ text: `:sos: ${formatMessage(log, this.env).replace(/\[31m/g, '').replace(/\[39m/g, '')}`,
77
+ }),
75
78
  });
76
79
  transportsData.push(slack('error'));
77
80
  }
@@ -94,7 +97,7 @@ export default class Logging {
94
97
  region: this.cloudwatchOption?.region,
95
98
  credentials: this?.cloudwatchOption?.credentials,
96
99
  },
97
- messageFormatter: (log) => this.lineFormat(log),
100
+ messageFormatter: (log) => this.lineFormat(log).replace(/\[31m/g, '').replace(/\[39m/g, ''),
98
101
  });
99
102
  log.add(cloudwatch());
100
103
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nextrans-logger",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
4
4
  "description": "Logging for nextrans app service",
5
5
  "main": "lib/index.cjs",
6
6
  "module": "lib/index.js",