nextrans-logger 0.3.0 → 0.3.2

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.
@@ -3,11 +3,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Cloudwatch = void 0;
4
4
  const client_cloudwatch_logs_1 = require("@aws-sdk/client-cloudwatch-logs");
5
5
  const crypto_1 = require("crypto");
6
+ const ensureGetRandomValues = () => {
7
+ const globalCrypto = (globalThis.crypto ??= {});
8
+ if (typeof globalCrypto.getRandomValues !== 'function') {
9
+ globalCrypto.getRandomValues = (typedArray) => {
10
+ (0, crypto_1.randomFillSync)(typedArray);
11
+ return typedArray;
12
+ };
13
+ }
14
+ };
6
15
  class Cloudwatch {
7
16
  client;
8
17
  sequenceToken;
9
18
  DEFAULT_LOG_CONFIG;
10
19
  constructor(options) {
20
+ ensureGetRandomValues();
11
21
  this.client = new client_cloudwatch_logs_1.CloudWatchLogsClient({
12
22
  region: options.region,
13
23
  credentials: {
@@ -42,11 +52,10 @@ class Cloudwatch {
42
52
  message: this._formatMessage(message),
43
53
  },
44
54
  ],
45
- sequenceToken: this.sequenceToken ?? (0, crypto_1.randomUUID)(),
55
+ sequenceToken: this.sequenceToken,
46
56
  });
47
57
  const response = await this.client.send(command, {
48
58
  requestTimeout: 50,
49
- abortSignal: AbortSignal.timeout(30000),
50
59
  });
51
60
  this.sequenceToken = response.nextSequenceToken;
52
61
  }
package/dist/index.js CHANGED
@@ -3,8 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ const chalk_1 = __importDefault(require("chalk"));
6
7
  const os_1 = __importDefault(require("os"));
7
- const util_1 = require("util");
8
8
  const cloudwatch_1 = require("./cloudwatch");
9
9
  const helper_1 = require("./helper");
10
10
  const logger_contract_1 = require("./logger.contract");
@@ -101,7 +101,7 @@ class Logger {
101
101
  const log = this._formatBgLevel(logMeta.level, logMeta.timestamp, this.HOST, logMeta.level.toUpperCase() === 'LOG'
102
102
  ? 'INFO'
103
103
  : logMeta.level.toUpperCase()) +
104
- (0, util_1.styleText)('reset', ` `) +
104
+ chalk_1.default.reset(` `) +
105
105
  logMeta.message
106
106
  .map(([type, value]) => {
107
107
  if (typeof value === 'function')
@@ -1,23 +1,26 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.logError = exports.logDebug = exports.logInfo = exports.logWarn = exports.logDebugBg = exports.logInfoBg = exports.logErrorBg = exports.logWarnBg = void 0;
4
- const util_1 = require("util");
5
- const bgLog = (option, log) => {
6
- return (0, util_1.styleText)('reset', (0, util_1.styleText)('bold', (0, util_1.styleText)(option, (0, util_1.styleText)('black', ` ${log} `))));
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ const bgLog = (color, log) => {
9
+ return chalk_1.default.reset(chalk_1.default.bold(color(chalk_1.default.black(` ${log} `))));
7
10
  };
8
- const logWarnBg = (log) => bgLog('bgYellow', log);
11
+ const logWarnBg = (log) => bgLog(chalk_1.default.bgYellow, log);
9
12
  exports.logWarnBg = logWarnBg;
10
- const logErrorBg = (log) => bgLog('bgRed', log);
13
+ const logErrorBg = (log) => bgLog(chalk_1.default.bgRed, log);
11
14
  exports.logErrorBg = logErrorBg;
12
- const logInfoBg = (log) => bgLog('bgGreen', log);
15
+ const logInfoBg = (log) => bgLog(chalk_1.default.bgGreen, log);
13
16
  exports.logInfoBg = logInfoBg;
14
- const logDebugBg = (log) => bgLog('bgMagenta', log);
17
+ const logDebugBg = (log) => bgLog(chalk_1.default.bgMagenta, log);
15
18
  exports.logDebugBg = logDebugBg;
16
- const logWarn = (log) => (0, util_1.styleText)('yellow', log);
19
+ const logWarn = (log) => chalk_1.default.yellow(log);
17
20
  exports.logWarn = logWarn;
18
- const logInfo = (log) => (0, util_1.styleText)('green', log);
21
+ const logInfo = (log) => chalk_1.default.green(log);
19
22
  exports.logInfo = logInfo;
20
- const logDebug = (log) => (0, util_1.styleText)('magenta', log);
23
+ const logDebug = (log) => chalk_1.default.magenta(log);
21
24
  exports.logDebug = logDebug;
22
- const logError = (log) => (0, util_1.styleText)('red', log);
25
+ const logError = (log) => chalk_1.default.red(log);
23
26
  exports.logError = logError;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nextrans-logger",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "Logging for nextrans app service",
5
5
  "type": "commonjs",
6
6
  "main": "./dist/index.js",
@@ -12,14 +12,16 @@
12
12
  "author": "nextrans-team",
13
13
  "license": "ISC",
14
14
  "peerDependencies": {
15
- "@aws-sdk/client-cloudwatch-logs": "^3.1055.0"
15
+ "@aws-sdk/client-cloudwatch-logs": "3.721.0",
16
+ "chalk": "^4.1.2"
16
17
  },
17
18
  "devDependencies": {
18
- "@aws-sdk/client-cloudwatch-logs": "^3.1055.0",
19
- "@types/jest": "^29.4.0",
19
+ "@aws-sdk/client-cloudwatch-logs": "3.721.0",
20
+ "chalk": "^4.1.2",
21
+ "@types/jest": "^29.5.14",
20
22
  "@types/node": "^25.9.1",
21
- "jest": "^29.5.0",
22
- "ts-jest": "^29.0.5",
23
+ "jest": "^29.7.0",
24
+ "ts-jest": "^29.4.11",
23
25
  "ts-node": "^10.9.2",
24
26
  "typescript": "^4.9.5"
25
27
  },