@meadown/logger 1.8.11 → 1.9.0

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.
Files changed (140) hide show
  1. package/README.md +149 -51
  2. package/dist/cjs/{config.js → config/index.js} +1 -1
  3. package/dist/cjs/{constants.d.ts → const/index.d.ts} +0 -5
  4. package/dist/cjs/{constants.js → const/index.js} +2 -8
  5. package/dist/cjs/{caller → domain/caller}/getCaller.js +1 -1
  6. package/dist/cjs/{colors → domain/colors}/color.js +1 -1
  7. package/dist/cjs/{decorations → domain/decorations}/link.js +1 -1
  8. package/dist/cjs/{terminal → domain/terminal}/isTTY.js +1 -1
  9. package/dist/cjs/{time → domain/time}/getTimeStamp.js +1 -1
  10. package/dist/cjs/domain/write/helpers/buildContext.d.ts +16 -0
  11. package/dist/cjs/domain/write/helpers/buildContext.js +40 -0
  12. package/dist/{core/writeLog → cjs/domain/write}/helpers/formatLocation.d.ts +1 -1
  13. package/dist/cjs/{core/writeLog → domain/write}/helpers/formatLocation.js +2 -2
  14. package/dist/cjs/{core/writeLog → domain/write}/helpers/index.d.ts +1 -0
  15. package/dist/cjs/{core/writeLog → domain/write}/helpers/index.js +5 -2
  16. package/dist/cjs/{core/writeLog → domain/write}/helpers/renderMessage.js +6 -5
  17. package/dist/cjs/{core/writeLog → domain/write}/helpers/visibleLines.js +3 -3
  18. package/dist/cjs/{core/writeLog → domain/write}/index.js +1 -1
  19. package/dist/{core/writeLog → cjs/domain/write}/writeLog.d.ts +2 -2
  20. package/dist/cjs/domain/write/writeLog.js +24 -0
  21. package/dist/cjs/features/logger/index.d.ts +1 -0
  22. package/dist/cjs/features/logger/index.js +21 -0
  23. package/dist/cjs/features/logger-error/index.d.ts +1 -0
  24. package/dist/cjs/features/logger-error/index.js +21 -0
  25. package/dist/cjs/features/logger-group/createGroup.d.ts +11 -0
  26. package/dist/cjs/features/logger-group/createGroup.js +21 -0
  27. package/dist/cjs/features/logger-group/index.d.ts +1 -0
  28. package/dist/cjs/features/logger-group/index.js +14 -0
  29. package/dist/cjs/features/logger-group/writeGroup.d.ts +8 -0
  30. package/dist/cjs/features/logger-group/writeGroup.js +20 -0
  31. package/dist/cjs/features/logger-max-lines/index.d.ts +1 -0
  32. package/dist/cjs/features/logger-max-lines/index.js +12 -0
  33. package/dist/cjs/features/logger-tap/createTap.d.ts +5 -0
  34. package/dist/cjs/features/logger-tap/createTap.js +33 -0
  35. package/dist/cjs/features/logger-tap/index.d.ts +1 -0
  36. package/dist/cjs/features/logger-tap/index.js +14 -0
  37. package/dist/cjs/{tap → features/logger-tap}/tapAsync/helpers/buildBlock.js +2 -2
  38. package/dist/cjs/{tap → features/logger-tap}/tapAsync/helpers/format.js +2 -2
  39. package/dist/cjs/{tap → features/logger-tap}/tapAsync/helpers/index.js +1 -1
  40. package/dist/cjs/{tap → features/logger-tap}/tapAsync/helpers/isThenable.js +1 -1
  41. package/dist/cjs/{tap → features/logger-tap}/tapAsync/helpers/response.js +2 -2
  42. package/dist/cjs/{tap → features/logger-tap}/tapAsync/index.js +1 -1
  43. package/dist/cjs/{tap → features/logger-tap}/tapAsync/tapAsync.d.ts +1 -1
  44. package/dist/cjs/{tap → features/logger-tap}/tapAsync/tapAsync.js +6 -3
  45. package/dist/cjs/features/logger-warn/index.d.ts +1 -0
  46. package/dist/cjs/features/logger-warn/index.js +21 -0
  47. package/dist/cjs/index.d.ts +17 -1
  48. package/dist/cjs/index.js +12 -8
  49. package/dist/cjs/types/index.d.ts +2 -0
  50. package/dist/cjs/types/index.js +8 -0
  51. package/dist/{config.js → config/index.js} +1 -1
  52. package/dist/{constants.d.ts → const/index.d.ts} +0 -5
  53. package/dist/{constants.js → const/index.js} +1 -7
  54. package/dist/{caller → domain/caller}/getCaller.js +1 -1
  55. package/dist/{colors → domain/colors}/color.js +1 -1
  56. package/dist/{decorations → domain/decorations}/link.js +1 -1
  57. package/dist/{terminal → domain/terminal}/isTTY.js +1 -1
  58. package/dist/{time → domain/time}/getTimeStamp.js +1 -1
  59. package/dist/domain/write/helpers/buildContext.d.ts +16 -0
  60. package/dist/domain/write/helpers/buildContext.js +33 -0
  61. package/dist/{cjs/core/writeLog → domain/write}/helpers/formatLocation.d.ts +1 -1
  62. package/dist/{core/writeLog → domain/write}/helpers/formatLocation.js +2 -2
  63. package/dist/{core/writeLog → domain/write}/helpers/index.d.ts +1 -0
  64. package/dist/{core/writeLog → domain/write}/helpers/index.js +2 -1
  65. package/dist/{core/writeLog → domain/write}/helpers/renderMessage.js +5 -4
  66. package/dist/{core/writeLog → domain/write}/helpers/visibleLines.js +2 -2
  67. package/dist/{core/writeLog → domain/write}/index.js +1 -1
  68. package/dist/{cjs/core/writeLog → domain/write}/writeLog.d.ts +2 -2
  69. package/dist/domain/write/writeLog.js +21 -0
  70. package/dist/features/logger/index.d.ts +1 -0
  71. package/dist/features/logger/index.js +15 -0
  72. package/dist/features/logger-error/index.d.ts +1 -0
  73. package/dist/features/logger-error/index.js +15 -0
  74. package/dist/features/logger-group/createGroup.d.ts +11 -0
  75. package/dist/features/logger-group/createGroup.js +15 -0
  76. package/dist/features/logger-group/index.d.ts +1 -0
  77. package/dist/features/logger-group/index.js +7 -0
  78. package/dist/features/logger-group/writeGroup.d.ts +8 -0
  79. package/dist/features/logger-group/writeGroup.js +17 -0
  80. package/dist/features/logger-max-lines/index.d.ts +1 -0
  81. package/dist/features/logger-max-lines/index.js +7 -0
  82. package/dist/features/logger-tap/createTap.d.ts +5 -0
  83. package/dist/features/logger-tap/createTap.js +27 -0
  84. package/dist/features/logger-tap/index.d.ts +1 -0
  85. package/dist/features/logger-tap/index.js +7 -0
  86. package/dist/{tap → features/logger-tap}/tapAsync/helpers/buildBlock.js +2 -2
  87. package/dist/{tap → features/logger-tap}/tapAsync/helpers/format.js +2 -2
  88. package/dist/{tap → features/logger-tap}/tapAsync/helpers/index.js +1 -1
  89. package/dist/{tap → features/logger-tap}/tapAsync/helpers/isThenable.js +1 -1
  90. package/dist/{tap → features/logger-tap}/tapAsync/helpers/response.js +2 -2
  91. package/dist/{tap → features/logger-tap}/tapAsync/index.js +1 -1
  92. package/dist/{tap → features/logger-tap}/tapAsync/tapAsync.d.ts +1 -1
  93. package/dist/{tap → features/logger-tap}/tapAsync/tapAsync.js +6 -3
  94. package/dist/features/logger-warn/index.d.ts +1 -0
  95. package/dist/features/logger-warn/index.js +15 -0
  96. package/dist/index.d.ts +17 -1
  97. package/dist/index.js +12 -8
  98. package/dist/types/index.d.ts +2 -0
  99. package/dist/types/index.js +7 -0
  100. package/package.json +1 -1
  101. package/dist/cjs/core/createLog.d.ts +0 -8
  102. package/dist/cjs/core/createLog.js +0 -29
  103. package/dist/cjs/core/writeLog/writeLog.js +0 -43
  104. package/dist/cjs/tap/createTap.d.ts +0 -18
  105. package/dist/cjs/tap/createTap.js +0 -51
  106. package/dist/core/createLog.d.ts +0 -8
  107. package/dist/core/createLog.js +0 -23
  108. package/dist/core/writeLog/writeLog.js +0 -37
  109. package/dist/tap/createTap.d.ts +0 -18
  110. package/dist/tap/createTap.js +0 -45
  111. /package/dist/cjs/{config.d.ts → config/index.d.ts} +0 -0
  112. /package/dist/{caller → cjs/domain/caller}/getCaller.d.ts +0 -0
  113. /package/dist/cjs/{colors → domain/colors}/color.d.ts +0 -0
  114. /package/dist/cjs/{decorations → domain/decorations}/link.d.ts +0 -0
  115. /package/dist/cjs/{terminal → domain/terminal}/isTTY.d.ts +0 -0
  116. /package/dist/cjs/{time → domain/time}/getTimeStamp.d.ts +0 -0
  117. /package/dist/cjs/{core/writeLog → domain/write}/helpers/renderMessage.d.ts +0 -0
  118. /package/dist/cjs/{core/writeLog → domain/write}/helpers/visibleLines.d.ts +0 -0
  119. /package/dist/cjs/{core/writeLog → domain/write}/index.d.ts +0 -0
  120. /package/dist/cjs/{tap → features/logger-tap}/tapAsync/helpers/buildBlock.d.ts +0 -0
  121. /package/dist/cjs/{tap → features/logger-tap}/tapAsync/helpers/format.d.ts +0 -0
  122. /package/dist/cjs/{tap → features/logger-tap}/tapAsync/helpers/index.d.ts +0 -0
  123. /package/dist/cjs/{tap → features/logger-tap}/tapAsync/helpers/isThenable.d.ts +0 -0
  124. /package/dist/cjs/{tap → features/logger-tap}/tapAsync/helpers/response.d.ts +0 -0
  125. /package/dist/cjs/{tap → features/logger-tap}/tapAsync/index.d.ts +0 -0
  126. /package/dist/{config.d.ts → config/index.d.ts} +0 -0
  127. /package/dist/{cjs → domain}/caller/getCaller.d.ts +0 -0
  128. /package/dist/{colors → domain/colors}/color.d.ts +0 -0
  129. /package/dist/{decorations → domain/decorations}/link.d.ts +0 -0
  130. /package/dist/{terminal → domain/terminal}/isTTY.d.ts +0 -0
  131. /package/dist/{time → domain/time}/getTimeStamp.d.ts +0 -0
  132. /package/dist/{core/writeLog → domain/write}/helpers/renderMessage.d.ts +0 -0
  133. /package/dist/{core/writeLog → domain/write}/helpers/visibleLines.d.ts +0 -0
  134. /package/dist/{core/writeLog → domain/write}/index.d.ts +0 -0
  135. /package/dist/{tap → features/logger-tap}/tapAsync/helpers/buildBlock.d.ts +0 -0
  136. /package/dist/{tap → features/logger-tap}/tapAsync/helpers/format.d.ts +0 -0
  137. /package/dist/{tap → features/logger-tap}/tapAsync/helpers/index.d.ts +0 -0
  138. /package/dist/{tap → features/logger-tap}/tapAsync/helpers/isThenable.d.ts +0 -0
  139. /package/dist/{tap → features/logger-tap}/tapAsync/helpers/response.d.ts +0 -0
  140. /package/dist/{tap → features/logger-tap}/tapAsync/index.d.ts +0 -0
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ /*
3
+ * createGroup.ts
4
+ * Created by Dewan Mobashirul
5
+ * Copyright (c) 2026 meadown
6
+ * All rights reserved
7
+ */
8
+ var __importDefault = (this && this.__importDefault) || function (mod) {
9
+ return (mod && mod.__esModule) ? mod : { "default": mod };
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.default = group;
13
+ const index_js_1 = require("../../config/index.js");
14
+ const getCaller_js_1 = __importDefault(require("../../domain/caller/getCaller.js"));
15
+ const writeGroup_js_1 = require("./writeGroup.js");
16
+ function group({ name, type = "log", logs, }) {
17
+ if (!(0, index_js_1.isLogAllowed)())
18
+ return;
19
+ const caller = (0, getCaller_js_1.default)();
20
+ (0, writeGroup_js_1.writeGroup)({ name, channel: type, logs, caller });
21
+ }
@@ -0,0 +1 @@
1
+ export { default, type Group, type GroupOptions } from "./createGroup.js";
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ /*
3
+ * index.ts
4
+ * Created by Dewan Mobashirul
5
+ * Copyright (c) 2026 meadown
6
+ * All rights reserved
7
+ */
8
+ var __importDefault = (this && this.__importDefault) || function (mod) {
9
+ return (mod && mod.__esModule) ? mod : { "default": mod };
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.default = void 0;
13
+ var createGroup_js_1 = require("./createGroup.js");
14
+ Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(createGroup_js_1).default; } });
@@ -0,0 +1,8 @@
1
+ import { type LogChannel } from "../../types/index.js";
2
+ import { type Caller } from "../../domain/caller/getCaller.js";
3
+ export declare function writeGroup(opts: {
4
+ name: string;
5
+ channel: LogChannel;
6
+ logs: unknown[];
7
+ caller: Caller;
8
+ }): void;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ /*
3
+ * writeGroup.ts
4
+ * Created by Dewan Mobashirul
5
+ * Copyright (c) 2026 meadown
6
+ * All rights reserved
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.writeGroup = writeGroup;
10
+ const index_js_1 = require("../../domain/write/helpers/index.js");
11
+ function writeGroup(opts) {
12
+ const { name, channel, logs, caller } = opts;
13
+ const { useColor, paint, timeStamp, locOut, connector, connectorEnd, separator, } = (0, index_js_1.buildContext)(channel, caller);
14
+ const tagOut = paint(`[${name.toUpperCase()}]`, index_js_1.TAG_COLOR[channel]);
15
+ const itemLines = logs
16
+ .map((item) => `\n${connector} ${(0, index_js_1.renderMessage)([item], useColor)}`)
17
+ .join("");
18
+ const meta = `\n${connectorEnd} ${timeStamp} ${separator} ${locOut}`;
19
+ console[channel](`\n${tagOut} ${itemLines}${meta}`);
20
+ }
@@ -0,0 +1 @@
1
+ export { getVisibleLines, setVisibleLines } from "../../domain/write/index.js";
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ /*
3
+ * index.ts
4
+ * Created by Dewan Mobashirul
5
+ * Copyright (c) 2026 meadown
6
+ * All rights reserved
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.setVisibleLines = exports.getVisibleLines = void 0;
10
+ var index_js_1 = require("../../domain/write/index.js");
11
+ Object.defineProperty(exports, "getVisibleLines", { enumerable: true, get: function () { return index_js_1.getVisibleLines; } });
12
+ Object.defineProperty(exports, "setVisibleLines", { enumerable: true, get: function () { return index_js_1.setVisibleLines; } });
@@ -0,0 +1,5 @@
1
+ /** Type of `logger.tap` — use this to annotate variables or parameters that accept it. */
2
+ export interface Tap {
3
+ <T>(value: T, label?: string): T;
4
+ }
5
+ export default function tap<T>(value: T, label?: string): T;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ /*
3
+ * createTap.ts
4
+ * Created by Dewan Mobashirul
5
+ * Copyright (c) 2026 meadown
6
+ * All rights reserved
7
+ */
8
+ var __importDefault = (this && this.__importDefault) || function (mod) {
9
+ return (mod && mod.__esModule) ? mod : { "default": mod };
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.default = tap;
13
+ const index_js_1 = require("../../config/index.js");
14
+ const getCaller_js_1 = __importDefault(require("../../domain/caller/getCaller.js"));
15
+ const writeLog_js_1 = require("../../domain/write/writeLog.js");
16
+ const index_js_2 = require("./tapAsync/index.js");
17
+ function tap(value, label) {
18
+ if (!(0, index_js_1.isLogAllowed)())
19
+ return value;
20
+ const caller = (0, getCaller_js_1.default)();
21
+ if ((0, index_js_2.isThenable)(value)) {
22
+ (0, index_js_2.tapAsync)(value, label, caller);
23
+ }
24
+ else {
25
+ (0, writeLog_js_1.writeLog)({
26
+ channel: "log",
27
+ tag: "[TAP]",
28
+ args: label === undefined ? [value] : [label, value],
29
+ caller,
30
+ });
31
+ }
32
+ return value;
33
+ }
@@ -0,0 +1 @@
1
+ export { default, type Tap } from "./createTap.js";
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ /*
3
+ * index.ts
4
+ * Created by Dewan Mobashirul
5
+ * Copyright (c) 2026 meadown
6
+ * All rights reserved
7
+ */
8
+ var __importDefault = (this && this.__importDefault) || function (mod) {
9
+ return (mod && mod.__esModule) ? mod : { "default": mod };
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.default = void 0;
13
+ var createTap_js_1 = require("./createTap.js");
14
+ Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(createTap_js_1).default; } });
@@ -2,14 +2,14 @@
2
2
  /*
3
3
  * buildBlock.ts
4
4
  * Created by Dewan Mobashirul
5
- * Copyright (c) 2026 dewan-meadown
5
+ * Copyright (c) 2026 meadown
6
6
  * All rights reserved
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.buildBlock = buildBlock;
10
10
  const node_util_1 = require("node:util");
11
11
  const format_js_1 = require("./format.js");
12
- const color_js_1 = require("../../../colors/color.js");
12
+ const color_js_1 = require("../../../../domain/colors/color.js");
13
13
  const response_js_1 = require("./response.js");
14
14
  /**
15
15
  * Renders the nested tree block:
@@ -2,13 +2,13 @@
2
2
  /*
3
3
  * format.ts
4
4
  * Created by Dewan Mobashirul
5
- * Copyright (c) 2026 dewan-meadown
5
+ * Copyright (c) 2026 meadown
6
6
  * All rights reserved
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.formatDuration = formatDuration;
10
10
  exports.formatBytes = formatBytes;
11
- const color_js_1 = require("../../../colors/color.js");
11
+ const color_js_1 = require("../../../../domain/colors/color.js");
12
12
  /** `65ms` (green) · `1.2s` (yellow) · `5.8s` (red). */
13
13
  function formatDuration(ms, useColor) {
14
14
  const text = ms >= 1000 ? `${(ms / 1000).toFixed(2)}s` : `${ms}ms`;
@@ -2,7 +2,7 @@
2
2
  /*
3
3
  * index.ts
4
4
  * Created by Dewan Mobashirul
5
- * Copyright (c) 2026 dewan-meadown
5
+ * Copyright (c) 2026 meadown
6
6
  * All rights reserved
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -2,7 +2,7 @@
2
2
  /*
3
3
  * isThenable.ts
4
4
  * Created by Dewan Mobashirul
5
- * Copyright (c) 2026 dewan-meadown
5
+ * Copyright (c) 2026 meadown
6
6
  * All rights reserved
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -2,7 +2,7 @@
2
2
  /*
3
3
  * response.ts
4
4
  * Created by Dewan Mobashirul
5
- * Copyright (c) 2026 dewan-meadown
5
+ * Copyright (c) 2026 meadown
6
6
  * All rights reserved
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -10,7 +10,7 @@ exports.isResponse = isResponse;
10
10
  exports.formatStatus = formatStatus;
11
11
  exports.readBody = readBody;
12
12
  const format_js_1 = require("./format.js");
13
- const color_js_1 = require("../../../colors/color.js");
13
+ const color_js_1 = require("../../../../domain/colors/color.js");
14
14
  /** Whether the resolved value is a fetch `Response` we can read. */
15
15
  function isResponse(value) {
16
16
  const v = value;
@@ -2,7 +2,7 @@
2
2
  /*
3
3
  * index.ts
4
4
  * Created by Dewan Mobashirul
5
- * Copyright (c) 2026 dewan-meadown
5
+ * Copyright (c) 2026 meadown
6
6
  * All rights reserved
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,4 +1,4 @@
1
- import { type Caller } from "../../caller/getCaller.js";
1
+ import { type Caller } from "../../../domain/caller/getCaller.js";
2
2
  /**
3
3
  * The async tap. Fire-and-forget: returns `promise` immediately (unchanged),
4
4
  * and logs a rich block once it resolves. For a `Response`, reads the body from
@@ -2,15 +2,16 @@
2
2
  /*
3
3
  * tapAsync.ts
4
4
  * Created by Dewan Mobashirul
5
- * Copyright (c) 2026 dewan-meadown
5
+ * Copyright (c) 2026 meadown
6
6
  * All rights reserved
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.tapAsync = tapAsync;
10
10
  const node_perf_hooks_1 = require("node:perf_hooks");
11
11
  const index_js_1 = require("./helpers/index.js");
12
- const isTTY_js_1 = require("../../terminal/isTTY.js");
13
- const index_js_2 = require("../../core/writeLog/index.js");
12
+ const isTTY_js_1 = require("../../../domain/terminal/isTTY.js");
13
+ const index_js_2 = require("../../../domain/write/index.js");
14
+ const index_js_3 = require("../../../config/index.js");
14
15
  /**
15
16
  * The async tap. Fire-and-forget: returns `promise` immediately (unchanged),
16
17
  * and logs a rich block once it resolves. For a `Response`, reads the body from
@@ -19,6 +20,8 @@ const index_js_2 = require("../../core/writeLog/index.js");
19
20
  * the logged location points at the user's file.
20
21
  */
21
22
  function tapAsync(promise, label, caller) {
23
+ if (!(0, index_js_3.isLogAllowed)())
24
+ return;
22
25
  const useColor = (0, isTTY_js_1.isTTY)("stdout");
23
26
  const start = node_perf_hooks_1.performance.now();
24
27
  void promise.then((resolved) => {
@@ -0,0 +1 @@
1
+ export default function logWarn(...args: unknown[]): void;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ /*
3
+ * index.ts
4
+ * Created by Dewan Mobashirul
5
+ * Copyright (c) 2026 meadown
6
+ * All rights reserved
7
+ */
8
+ var __importDefault = (this && this.__importDefault) || function (mod) {
9
+ return (mod && mod.__esModule) ? mod : { "default": mod };
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.default = logWarn;
13
+ const index_js_1 = require("../../config/index.js");
14
+ const getCaller_js_1 = __importDefault(require("../../domain/caller/getCaller.js"));
15
+ const writeLog_js_1 = require("../../domain/write/writeLog.js");
16
+ function logWarn(...args) {
17
+ if (!(0, index_js_1.isLogAllowed)())
18
+ return;
19
+ const caller = (0, getCaller_js_1.default)();
20
+ (0, writeLog_js_1.writeLog)({ channel: "warn", tag: "[WARN]", args, caller });
21
+ }
@@ -1,3 +1,5 @@
1
+ import { type Tap } from "./features/logger-tap/index.js";
2
+ import { type Group } from "./features/logger-group/index.js";
1
3
  /** Type of the logger — use this to annotate variables or parameters that accept it. */
2
4
  export interface Logger {
3
5
  /** Log at info level — `stdout`, cyan `[INFO]` tag. */
@@ -26,7 +28,21 @@ export interface Logger {
26
28
  * @param value Any value or promise — always returned as-is.
27
29
  * @param label Optional label shown next to the value in the log line.
28
30
  */
29
- tap<T>(value: T, label?: string): T;
31
+ tap: Tap;
32
+ /**
33
+ * Log multiple related items as one block under a shared name and single
34
+ * timestamp. Each item in `logs` renders on its own `├──` branch — any value
35
+ * is accepted (string, object, function, Promise, …).
36
+ *
37
+ * `type` sets the channel and tag color: `"info"` (default), `"warn"`, `"error"`.
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * logger.group({ name: "Server setup", logs: [`port: ${port}`, `env: ${env}`] })
42
+ * logger.group({ name: "Validation failed", type: "error", logs: ["email invalid"] })
43
+ * ```
44
+ */
45
+ group: Group;
30
46
  /**
31
47
  * How many lines to show before the rest collapses into a
32
48
  * `… N more lines` summary. `0` (default) shows everything.
package/dist/cjs/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  /*
3
3
  * index.ts
4
4
  * Created by Dewan Mobashirul
5
- * Copyright (c) 2026 dewan-meadown
5
+ * Copyright (c) 2026 meadown
6
6
  * All rights reserved
7
7
  */
8
8
  var __importDefault = (this && this.__importDefault) || function (mod) {
@@ -10,9 +10,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.logger = void 0;
13
- const createLog_js_1 = __importDefault(require("./core/createLog.js"));
14
- const createTap_js_1 = __importDefault(require("./tap/createTap.js"));
15
- const index_js_1 = require("./core/writeLog/index.js");
13
+ const index_js_1 = require("./features/logger-max-lines/index.js");
14
+ const index_js_2 = __importDefault(require("./features/logger/index.js"));
15
+ const index_js_3 = __importDefault(require("./features/logger-warn/index.js"));
16
+ const index_js_4 = __importDefault(require("./features/logger-error/index.js"));
17
+ const index_js_5 = __importDefault(require("./features/logger-tap/index.js"));
18
+ const index_js_6 = __importDefault(require("./features/logger-group/index.js"));
16
19
  /**
17
20
  * A logger built for development — colored tags, a local timestamp, and a
18
21
  * clickable `(file:line)` link on every line so you always know where a
@@ -33,10 +36,11 @@ const index_js_1 = require("./core/writeLog/index.js");
33
36
  * const res = await logger.tap(fetch(url), "GET /users")
34
37
  * ```
35
38
  */
36
- const logger = Object.assign((0, createLog_js_1.default)("log", "[INFO]"), {
37
- error: (0, createLog_js_1.default)("error", "[ERROR]"),
38
- warn: (0, createLog_js_1.default)("warn", "[WARN]"),
39
- tap: (0, createTap_js_1.default)(),
39
+ const logger = Object.assign(index_js_2.default, {
40
+ error: index_js_4.default,
41
+ warn: index_js_3.default,
42
+ tap: index_js_5.default,
43
+ group: index_js_6.default,
40
44
  });
41
45
  exports.logger = logger;
42
46
  // `maxLines` is a live getter/setter backed by the shared collapse setting, so
@@ -0,0 +1,2 @@
1
+ /** The console channels the logger writes to. */
2
+ export type LogChannel = "log" | "error" | "warn";
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ /*
3
+ * index.ts
4
+ * Created by Dewan Mobashirul
5
+ * Copyright (c) 2026 meadown
6
+ * All rights reserved
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * config.ts
3
3
  * Created by Dewan Mobashirul
4
- * Copyright (c) 2026 dewan-meadown
4
+ * Copyright (c) 2026 meadown
5
5
  * All rights reserved
6
6
  */
7
7
  /**
@@ -1,8 +1,3 @@
1
- import { type Color } from "./colors/color.js";
2
- /** The console channels the logger writes to. */
3
- export type LogChannel = "log" | "error" | "warn";
4
- /** The tag color per channel: info/tap → cyan, warn → yellow, error → red. */
5
- export declare const TAG_COLOR: Record<LogChannel, Color>;
6
1
  /** Glyphs that draw each entry's little tree. */
7
2
  export declare const BRANCH = "\u251C\u2500\u2500";
8
3
  export declare const BRANCH_END = "\u2514\u2500\u2500";
@@ -1,18 +1,12 @@
1
1
  /*
2
2
  * constants.ts
3
3
  * Created by Dewan Mobashirul
4
- * Copyright (c) 2026 dewan-meadown
4
+ * Copyright (c) 2026 meadown
5
5
  * All rights reserved
6
6
  *
7
7
  * Single home for the logger's layout/behavior constants, so the values that
8
8
  * shape an entry live in one place instead of as magic literals across modules.
9
9
  */
10
- /** The tag color per channel: info/tap → cyan, warn → yellow, error → red. */
11
- export const TAG_COLOR = {
12
- log: "cyan",
13
- warn: "yellow",
14
- error: "red",
15
- };
16
10
  /** Glyphs that draw each entry's little tree. */
17
11
  export const BRANCH = "├──"; // the message branch
18
12
  export const BRANCH_END = "└──"; // the last (metadata) branch
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * getCaller.ts
3
3
  * Created by Dewan Mobashirul
4
- * Copyright (c) 2026 dewan-meadown
4
+ * Copyright (c) 2026 meadown
5
5
  * All rights reserved
6
6
  */
7
7
  const UNKNOWN = { label: "unknown", file: null, line: null };
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * color.ts
3
3
  * Created by Dewan Mobashirul
4
- * Copyright (c) 2026 dewan-meadown
4
+ * Copyright (c) 2026 meadown
5
5
  * All rights reserved
6
6
  */
7
7
  /** ANSI SGR codes for the colors/styles the logger uses. */
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * link.ts
3
3
  * Created by Dewan Mobashirul
4
- * Copyright (c) 2026 dewan-meadown
4
+ * Copyright (c) 2026 meadown
5
5
  * All rights reserved
6
6
  */
7
7
  import { pathToFileURL } from "node:url";
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * isTTY.ts
3
3
  * Created by Dewan Mobashirul
4
- * Copyright (c) 2026 dewan-meadown
4
+ * Copyright (c) 2026 meadown
5
5
  * All rights reserved
6
6
  */
7
7
  /**
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * getTimeStamp.ts
3
3
  * Created by Dewan Mobashirul
4
- * Copyright (c) 2026 dewan-meadown
4
+ * Copyright (c) 2026 meadown
5
5
  * All rights reserved
6
6
  */
7
7
  // Time-only 12-hour formatter (date is built separately, timezone is dropped).
@@ -0,0 +1,16 @@
1
+ import { type LogChannel } from "../../../types/index.js";
2
+ import { type Caller } from "../../caller/getCaller.js";
3
+ import { type Color } from "../../colors/color.js";
4
+ /** Tag color per channel — cyan for log/tap, yellow for warn, red for error. */
5
+ export declare const TAG_COLOR: Record<LogChannel, Color>;
6
+ export interface RenderContext {
7
+ useColor: boolean;
8
+ paint: (s: string, c: Color) => string;
9
+ timeStamp: string;
10
+ locOut: string;
11
+ connector: string;
12
+ connectorEnd: string;
13
+ separator: string;
14
+ }
15
+ /** Builds the shared paint/layout values used by both writeLog and writeGroup. */
16
+ export declare function buildContext(channel: LogChannel, caller: Caller): RenderContext;
@@ -0,0 +1,33 @@
1
+ /*
2
+ * buildContext.ts
3
+ * Created by Dewan Mobashirul
4
+ * Copyright (c) 2026 meadown
5
+ * All rights reserved
6
+ */
7
+ import { BRANCH, BRANCH_END, SEPARATOR } from "../../../const/index.js";
8
+ import { colorize } from "../../colors/color.js";
9
+ /** Tag color per channel — cyan for log/tap, yellow for warn, red for error. */
10
+ export const TAG_COLOR = {
11
+ log: "cyan",
12
+ warn: "yellow",
13
+ error: "red",
14
+ };
15
+ import { isTTY } from "../../terminal/isTTY.js";
16
+ import getTimeStamp from "../../time/getTimeStamp.js";
17
+ import { formatLocation } from "./formatLocation.js";
18
+ /** Builds the shared paint/layout values used by both writeLog and writeGroup. */
19
+ export function buildContext(channel, caller) {
20
+ const streamName = channel === "log" ? "stdout" : "stderr";
21
+ const useColor = isTTY(streamName);
22
+ const paint = (s, c) => (useColor ? colorize(s, c) : s);
23
+ const location = formatLocation(caller, useColor);
24
+ return {
25
+ useColor,
26
+ paint,
27
+ timeStamp: paint(getTimeStamp(), "teal"),
28
+ locOut: paint(`(${location})`, "dimTeal"),
29
+ connector: paint(BRANCH, "gray"),
30
+ connectorEnd: paint(BRANCH_END, "gray"),
31
+ separator: paint(SEPARATOR, "gray"),
32
+ };
33
+ }
@@ -1,4 +1,4 @@
1
- import { type Caller } from "../../../caller/getCaller.js";
1
+ import { type Caller } from "../../caller/getCaller.js";
2
2
  /**
3
3
  * Renders a caller as a `(file:line)` location — a clickable OSC-8 link on a
4
4
  * supporting terminal, plain text otherwise. Pure (no stack access).
@@ -1,10 +1,10 @@
1
1
  /*
2
2
  * formatLocation.ts
3
3
  * Created by Dewan Mobashirul
4
- * Copyright (c) 2026 dewan-meadown
4
+ * Copyright (c) 2026 meadown
5
5
  * All rights reserved
6
6
  */
7
- import { fileUrl, hyperlink } from "../../../decorations/link.js";
7
+ import { fileUrl, hyperlink } from "../../decorations/link.js";
8
8
  /**
9
9
  * Renders a caller as a `(file:line)` location — a clickable OSC-8 link on a
10
10
  * supporting terminal, plain text otherwise. Pure (no stack access).
@@ -1,3 +1,4 @@
1
1
  export { visibleLines, getVisibleLines, setVisibleLines, } from "./visibleLines.js";
2
2
  export { renderMessage } from "./renderMessage.js";
3
3
  export { formatLocation } from "./formatLocation.js";
4
+ export { buildContext, TAG_COLOR } from "./buildContext.js";
@@ -1,9 +1,10 @@
1
1
  /*
2
2
  * index.ts
3
3
  * Created by Dewan Mobashirul
4
- * Copyright (c) 2026 dewan-meadown
4
+ * Copyright (c) 2026 meadown
5
5
  * All rights reserved
6
6
  */
7
7
  export { visibleLines, getVisibleLines, setVisibleLines, } from "./visibleLines.js";
8
8
  export { renderMessage } from "./renderMessage.js";
9
9
  export { formatLocation } from "./formatLocation.js";
10
+ export { buildContext, TAG_COLOR } from "./buildContext.js";
@@ -1,13 +1,13 @@
1
1
  /*
2
2
  * renderMessage.ts
3
3
  * Created by Dewan Mobashirul
4
- * Copyright (c) 2026 dewan-meadown
4
+ * Copyright (c) 2026 meadown
5
5
  * All rights reserved
6
6
  */
7
7
  import { formatWithOptions } from "node:util";
8
8
  import { visibleLines } from "./visibleLines.js";
9
- import { colorize } from "../../../colors/color.js";
10
- import { MESSAGE_INDENT } from "../../../constants.js";
9
+ import { colorize } from "../../colors/color.js";
10
+ import { MESSAGE_INDENT } from "../../../const/index.js";
11
11
  /**
12
12
  * Collapses a long multi-line message to {@link visibleLines} lines, replacing
13
13
  * the rest with a dimmed `… N more lines` summary. When `visibleLines` is 0
@@ -33,5 +33,6 @@ function collapse(text, useColor) {
33
33
  */
34
34
  export function renderMessage(args, useColor) {
35
35
  const text = formatWithOptions({ colors: useColor }, ...args);
36
- return collapse(text.replace(/\n/g, `\n${colorize(MESSAGE_INDENT, "gray")}`), useColor);
36
+ const indent = useColor ? colorize(MESSAGE_INDENT, "gray") : MESSAGE_INDENT;
37
+ return collapse(text.replace(/\n/g, `\n${indent}`), useColor);
37
38
  }
@@ -1,10 +1,10 @@
1
1
  /*
2
2
  * visibleLines.ts
3
3
  * Created by Dewan Mobashirul
4
- * Copyright (c) 2026 dewan-meadown
4
+ * Copyright (c) 2026 meadown
5
5
  * All rights reserved
6
6
  */
7
- import { DEFAULT_MAX_LINES } from "../../../constants.js";
7
+ import { DEFAULT_MAX_LINES } from "../../../const/index.js";
8
8
  /** Max message lines to show before collapsing the rest; 0 (default) shows all. */
9
9
  export let visibleLines = DEFAULT_MAX_LINES;
10
10
  /** How many lines a long message shows before collapsing (0 = all). */
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * index.ts
3
3
  * Created by Dewan Mobashirul
4
- * Copyright (c) 2026 dewan-meadown
4
+ * Copyright (c) 2026 meadown
5
5
  * All rights reserved
6
6
  */
7
7
  export { writeLog } from "./writeLog.js";
@@ -1,5 +1,5 @@
1
- import { type LogChannel } from "../../constants.js";
2
- import { type Caller } from "../../caller/getCaller.js";
1
+ import { type LogChannel } from "../../types/index.js";
2
+ import { type Caller } from "../caller/getCaller.js";
3
3
  /**
4
4
  * Renders and writes one log entry. The `caller` is resolved by the *caller* of
5
5
  * this function (the log closure or `tap`) and passed in, so this helper never