nextrans-logger 0.1.6 → 0.1.7

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
@@ -54,17 +54,21 @@ class Logging {
54
54
  return formatMessage(log, this.env).replace(/`/g, '').replace(/\[\*/g, '[').replace(/\*\]/g, ']');
55
55
  }
56
56
  formatPrint() {
57
- return winston_1.format.combine(winston_1.format.errors({ stack: true }), winston_1.format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss' }), winston_1.format.printf((log) => this.lineFormat(log)));
57
+ return winston_1.format.combine(winston_1.format.colorize({ all: true, colors: { info: 'blue', error: 'red', warn: 'yellow' } }), winston_1.format.errors({ stack: true }), winston_1.format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss' }), winston_1.format.printf((log) => this.lineFormat(log)));
58
58
  }
59
59
  log() {
60
60
  var _a, _b, _c, _d;
61
61
  const transportsData = [
62
- new winston_1.transports.Console({ format: this.formatPrint(), handleExceptions: true, level: 'debug' }),
62
+ new winston_1.transports.Console({
63
+ format: winston_1.format.combine(winston_1.format.colorize(), this.formatPrint()),
64
+ handleExceptions: true,
65
+ level: 'debug',
66
+ }),
63
67
  ];
64
68
  if (this.enable && (this === null || this === void 0 ? void 0 : this.slackWebhook)) {
65
69
  const slack = (level) => new winston_slack_webhook_transport_1.default({
66
70
  level,
67
- webhookUrl: this === null || this === void 0 ? void 0 : this.slackWebhook,
71
+ webhookUrl: this.slackWebhook,
68
72
  formatter: (log) => ({ text: `:sos: ${formatMessage(log, this.env)}` }),
69
73
  });
70
74
  transportsData.push(slack('error'));
@@ -76,8 +80,8 @@ class Logging {
76
80
  });
77
81
  if (this.enable &&
78
82
  this.cloudwatchOption &&
79
- this.cloudwatchOption.logGroupName &&
80
- this.cloudwatchOption.logStreamName &&
83
+ this.cloudwatchOption.logGroupName != undefined &&
84
+ this.cloudwatchOption.logStreamName != undefined &&
81
85
  ((_b = (_a = this === null || this === void 0 ? void 0 : this.cloudwatchOption) === null || _a === void 0 ? void 0 : _a.credentials) === null || _b === void 0 ? void 0 : _b.secretAccessKey) != undefined &&
82
86
  ((_d = (_c = this === null || this === void 0 ? void 0 : this.cloudwatchOption) === null || _c === void 0 ? void 0 : _c.credentials) === null || _d === void 0 ? void 0 : _d.accessKeyId) != undefined &&
83
87
  this.cloudwatchOption.region) {
package/lib/index.js CHANGED
@@ -50,16 +50,20 @@ export default class Logging {
50
50
  return formatMessage(log, this.env).replace(/`/g, '').replace(/\[\*/g, '[').replace(/\*\]/g, ']');
51
51
  }
52
52
  formatPrint() {
53
- return format.combine(format.errors({ stack: true }), format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss' }), format.printf((log) => this.lineFormat(log)));
53
+ return format.combine(format.colorize({ all: true, colors: { info: 'blue', error: 'red', warn: 'yellow' } }), format.errors({ stack: true }), format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss' }), format.printf((log) => this.lineFormat(log)));
54
54
  }
55
55
  log() {
56
56
  const transportsData = [
57
- new transports.Console({ format: this.formatPrint(), handleExceptions: true, level: 'debug' }),
57
+ new transports.Console({
58
+ format: format.combine(format.colorize(), this.formatPrint()),
59
+ handleExceptions: true,
60
+ level: 'debug',
61
+ }),
58
62
  ];
59
63
  if (this.enable && this?.slackWebhook) {
60
64
  const slack = (level) => new SlackHook({
61
65
  level,
62
- webhookUrl: this?.slackWebhook,
66
+ webhookUrl: this.slackWebhook,
63
67
  formatter: (log) => ({ text: `:sos: ${formatMessage(log, this.env)}` }),
64
68
  });
65
69
  transportsData.push(slack('error'));
@@ -71,8 +75,8 @@ export default class Logging {
71
75
  });
72
76
  if (this.enable &&
73
77
  this.cloudwatchOption &&
74
- this.cloudwatchOption.logGroupName &&
75
- this.cloudwatchOption.logStreamName &&
78
+ this.cloudwatchOption.logGroupName != undefined &&
79
+ this.cloudwatchOption.logStreamName != undefined &&
76
80
  this?.cloudwatchOption?.credentials?.secretAccessKey != undefined &&
77
81
  this?.cloudwatchOption?.credentials?.accessKeyId != undefined &&
78
82
  this.cloudwatchOption.region) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nextrans-logger",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "Logging for nextrans app service",
5
5
  "main": "lib/index.cjs",
6
6
  "module": "lib/index.js",