@rf-logger/logger 0.1.0 → 0.1.1

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.
@@ -19,6 +19,7 @@ const chalk_1 = require("chalk");
19
19
  const json_colorizer_1 = __importDefault(require("json-colorizer"));
20
20
  const safe_stable_stringify_1 = __importDefault(require("safe-stable-stringify"));
21
21
  const winston_1 = __importDefault(require("winston"));
22
+ const safe_1 = __importDefault(require("@colors/colors/safe"));
22
23
  const shift = (string, spaces = 2) => string
23
24
  .split("\n")
24
25
  .map((line) => " ".repeat(spaces) + line)
@@ -28,10 +29,18 @@ const shift = (string, spaces = 2) => string
28
29
  * see https://github.com/winstonjs/logform/blob/master/simple.js
29
30
  */
30
31
  exports.simpleFormatWithTimestamp = winston_1.default.format.printf((info) => {
31
- const { level, message, timestamp, stack, channel } = info, rest = __rest(info, ["level", "message", "timestamp", "stack", "channel"]);
32
+ const { level, message, timestamp, stack, channel, nestContext } = info, rest = __rest(info, ["level", "message", "timestamp", "stack", "channel", "nestContext"]);
32
33
  const context = (0, safe_stable_stringify_1.default)(rest, null, 2);
33
- const padding = (info.padding && info.padding[info.level]) || "";
34
- let log = `[${timestamp}] ${level}:${padding}${(channel && ` [${channel}]`) || ""} ${message}`;
34
+ let log = `[${timestamp}] ${level}:`;
35
+ if (info.padding)
36
+ log += info.padding[info.level];
37
+ if (channel) {
38
+ let loggedChannel = channel;
39
+ if (nestContext)
40
+ loggedChannel += `::${nestContext}`;
41
+ log += ` ${safe_1.default.grey(`[${loggedChannel}]`)}`;
42
+ }
43
+ log += ` ${message}`;
35
44
  if (context !== "{}") {
36
45
  log += shift(`\n> ${(0, chalk_1.underline)("Context")}: ${shift((0, json_colorizer_1.default)(context)).trim()}`, 15);
37
46
  }
package/package.json CHANGED
@@ -5,6 +5,7 @@
5
5
  ],
6
6
  "main": "dist/index.js",
7
7
  "dependencies": {
8
+ "@colors/colors": "^1.5.0",
8
9
  "chalk": "^4.1.2",
9
10
  "json-colorizer": "^2.2.2",
10
11
  "safe-stable-stringify": "^2.3.1",
@@ -20,7 +21,7 @@
20
21
  "engines": {
21
22
  "node": ">=16.0.0"
22
23
  },
23
- "version": "0.1.0",
24
+ "version": "0.1.1",
24
25
  "scripts": {
25
26
  "test": "jest",
26
27
  "version": "pnpm version --no-git-tag-version"