@meadown/logger 1.8.10 → 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 (142) 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/cjs/{core/writeLog → domain/write/helpers}/formatLocation.js +3 -2
  13. package/dist/cjs/domain/write/helpers/index.d.ts +4 -0
  14. package/dist/cjs/domain/write/helpers/index.js +20 -0
  15. package/dist/cjs/{core/writeLog → domain/write/helpers}/renderMessage.js +6 -5
  16. package/dist/cjs/{core/writeLog → domain/write/helpers}/visibleLines.js +3 -3
  17. package/dist/cjs/domain/write/index.d.ts +2 -0
  18. package/dist/cjs/domain/write/index.js +14 -0
  19. package/dist/{core/writeLog/index.d.ts → cjs/domain/write/writeLog.d.ts} +2 -3
  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/features/logger-tap/tapAsync/helpers/buildBlock.d.ts +19 -0
  38. package/dist/cjs/features/logger-tap/tapAsync/helpers/buildBlock.js +56 -0
  39. package/dist/cjs/features/logger-tap/tapAsync/helpers/format.d.ts +4 -0
  40. package/dist/cjs/features/logger-tap/tapAsync/helpers/format.js +30 -0
  41. package/dist/cjs/features/logger-tap/tapAsync/helpers/index.d.ts +4 -0
  42. package/dist/cjs/features/logger-tap/tapAsync/helpers/index.js +20 -0
  43. package/dist/cjs/features/logger-tap/tapAsync/helpers/isThenable.d.ts +2 -0
  44. package/dist/cjs/features/logger-tap/tapAsync/helpers/isThenable.js +15 -0
  45. package/dist/cjs/features/logger-tap/tapAsync/helpers/response.d.ts +21 -0
  46. package/dist/cjs/features/logger-tap/tapAsync/helpers/response.js +62 -0
  47. package/dist/cjs/features/logger-tap/tapAsync/index.d.ts +2 -0
  48. package/dist/cjs/features/logger-tap/tapAsync/index.js +13 -0
  49. package/dist/cjs/{tap → features/logger-tap/tapAsync}/tapAsync.d.ts +1 -3
  50. package/dist/cjs/features/logger-tap/tapAsync/tapAsync.js +95 -0
  51. package/dist/cjs/features/logger-warn/index.d.ts +1 -0
  52. package/dist/cjs/features/logger-warn/index.js +21 -0
  53. package/dist/cjs/index.d.ts +63 -18
  54. package/dist/cjs/index.js +29 -15
  55. package/dist/cjs/types/index.d.ts +2 -0
  56. package/dist/cjs/types/index.js +8 -0
  57. package/dist/{config.js → config/index.js} +1 -1
  58. package/dist/{constants.d.ts → const/index.d.ts} +0 -5
  59. package/dist/{constants.js → const/index.js} +1 -7
  60. package/dist/{caller → domain/caller}/getCaller.js +1 -1
  61. package/dist/{colors → domain/colors}/color.js +1 -1
  62. package/dist/{decorations → domain/decorations}/link.js +1 -1
  63. package/dist/{terminal → domain/terminal}/isTTY.js +1 -1
  64. package/dist/{time → domain/time}/getTimeStamp.js +1 -1
  65. package/dist/domain/write/helpers/buildContext.d.ts +16 -0
  66. package/dist/domain/write/helpers/buildContext.js +33 -0
  67. package/dist/{core/writeLog → domain/write/helpers}/formatLocation.js +3 -2
  68. package/dist/domain/write/helpers/index.d.ts +4 -0
  69. package/dist/domain/write/helpers/index.js +10 -0
  70. package/dist/{core/writeLog → domain/write/helpers}/renderMessage.js +5 -4
  71. package/dist/{core/writeLog → domain/write/helpers}/visibleLines.js +2 -2
  72. package/dist/domain/write/index.d.ts +2 -0
  73. package/dist/domain/write/index.js +8 -0
  74. package/dist/{cjs/core/writeLog/index.d.ts → domain/write/writeLog.d.ts} +2 -3
  75. package/dist/domain/write/writeLog.js +21 -0
  76. package/dist/features/logger/index.d.ts +1 -0
  77. package/dist/features/logger/index.js +15 -0
  78. package/dist/features/logger-error/index.d.ts +1 -0
  79. package/dist/features/logger-error/index.js +15 -0
  80. package/dist/features/logger-group/createGroup.d.ts +11 -0
  81. package/dist/features/logger-group/createGroup.js +15 -0
  82. package/dist/features/logger-group/index.d.ts +1 -0
  83. package/dist/features/logger-group/index.js +7 -0
  84. package/dist/features/logger-group/writeGroup.d.ts +8 -0
  85. package/dist/features/logger-group/writeGroup.js +17 -0
  86. package/dist/features/logger-max-lines/index.d.ts +1 -0
  87. package/dist/features/logger-max-lines/index.js +7 -0
  88. package/dist/features/logger-tap/createTap.d.ts +5 -0
  89. package/dist/features/logger-tap/createTap.js +27 -0
  90. package/dist/features/logger-tap/index.d.ts +1 -0
  91. package/dist/features/logger-tap/index.js +7 -0
  92. package/dist/features/logger-tap/tapAsync/helpers/buildBlock.d.ts +19 -0
  93. package/dist/features/logger-tap/tapAsync/helpers/buildBlock.js +53 -0
  94. package/dist/features/logger-tap/tapAsync/helpers/format.d.ts +4 -0
  95. package/dist/features/logger-tap/tapAsync/helpers/format.js +26 -0
  96. package/dist/features/logger-tap/tapAsync/helpers/index.d.ts +4 -0
  97. package/dist/features/logger-tap/tapAsync/helpers/index.js +10 -0
  98. package/dist/features/logger-tap/tapAsync/helpers/isThenable.d.ts +2 -0
  99. package/dist/features/logger-tap/tapAsync/helpers/isThenable.js +12 -0
  100. package/dist/features/logger-tap/tapAsync/helpers/response.d.ts +21 -0
  101. package/dist/features/logger-tap/tapAsync/helpers/response.js +57 -0
  102. package/dist/features/logger-tap/tapAsync/index.d.ts +2 -0
  103. package/dist/features/logger-tap/tapAsync/index.js +8 -0
  104. package/dist/{tap → features/logger-tap/tapAsync}/tapAsync.d.ts +1 -3
  105. package/dist/features/logger-tap/tapAsync/tapAsync.js +92 -0
  106. package/dist/features/logger-warn/index.d.ts +1 -0
  107. package/dist/features/logger-warn/index.js +15 -0
  108. package/dist/index.d.ts +63 -18
  109. package/dist/index.js +29 -15
  110. package/dist/types/index.d.ts +2 -0
  111. package/dist/types/index.js +7 -0
  112. package/package.json +7 -4
  113. package/dist/cjs/core/createLog.d.ts +0 -8
  114. package/dist/cjs/core/createLog.js +0 -29
  115. package/dist/cjs/core/writeLog/index.js +0 -48
  116. package/dist/cjs/tap/createTap.d.ts +0 -18
  117. package/dist/cjs/tap/createTap.js +0 -51
  118. package/dist/cjs/tap/tapAsync.js +0 -192
  119. package/dist/core/createLog.d.ts +0 -8
  120. package/dist/core/createLog.js +0 -23
  121. package/dist/core/writeLog/index.js +0 -39
  122. package/dist/tap/createTap.d.ts +0 -18
  123. package/dist/tap/createTap.js +0 -45
  124. package/dist/tap/tapAsync.js +0 -188
  125. /package/dist/cjs/{config.d.ts → config/index.d.ts} +0 -0
  126. /package/dist/{caller → cjs/domain/caller}/getCaller.d.ts +0 -0
  127. /package/dist/cjs/{colors → domain/colors}/color.d.ts +0 -0
  128. /package/dist/cjs/{decorations → domain/decorations}/link.d.ts +0 -0
  129. /package/dist/cjs/{terminal → domain/terminal}/isTTY.d.ts +0 -0
  130. /package/dist/cjs/{time → domain/time}/getTimeStamp.d.ts +0 -0
  131. /package/dist/cjs/{core/writeLog → domain/write/helpers}/formatLocation.d.ts +0 -0
  132. /package/dist/cjs/{core/writeLog → domain/write/helpers}/renderMessage.d.ts +0 -0
  133. /package/dist/cjs/{core/writeLog → domain/write/helpers}/visibleLines.d.ts +0 -0
  134. /package/dist/{config.d.ts → config/index.d.ts} +0 -0
  135. /package/dist/{cjs → domain}/caller/getCaller.d.ts +0 -0
  136. /package/dist/{colors → domain/colors}/color.d.ts +0 -0
  137. /package/dist/{decorations → domain/decorations}/link.d.ts +0 -0
  138. /package/dist/{terminal → domain/terminal}/isTTY.d.ts +0 -0
  139. /package/dist/{time → domain/time}/getTimeStamp.d.ts +0 -0
  140. /package/dist/{core/writeLog → domain/write/helpers}/formatLocation.d.ts +0 -0
  141. /package/dist/{core/writeLog → domain/write/helpers}/renderMessage.d.ts +0 -0
  142. /package/dist/{core/writeLog → domain/write/helpers}/visibleLines.d.ts +0 -0
package/README.md CHANGED
@@ -30,11 +30,11 @@ tells you where things came from and disappears when you ship.
30
30
 
31
31
  - **Zero dependencies**
32
32
  - **Development-focused** — built for the dev experience, not production ops
33
- - **Clickable source link** — every log is a clickable link that jumps to the exact file and line it came from
34
- - **Tap logging** — log any value or promise inline; fetch calls also get timing, status, size, and body
33
+ - **Clickable source link** — every log jumps straight to the file and line it came from
34
+ - **Tap logging** — log any value or promise inline without breaking the expression
35
35
  - **Color-coded levels** — `[INFO]` cyan, `[WARN]` yellow, `[ERROR]` red
36
- - **Tree layout output** — clean, scannable structure in your terminal
37
- - **Collapsible messages** — cap long output with `logger.maxLines`
36
+ - **Tree layout** — clean, scannable structure in your terminal
37
+ - **Collapsible output** — cap long dumps with `logger.maxLines`
38
38
 
39
39
  ## Install
40
40
 
@@ -46,33 +46,27 @@ npm install @meadown/logger
46
46
  yarn add @meadown/logger
47
47
  ```
48
48
 
49
- ## Using it
50
-
51
- Set `NODE_ENV=production` and all output is suppressed. Anything else and
52
- logging is on. No config files, no init call, no options object.
49
+ ## Quick start
53
50
 
54
51
  ```ts
55
52
  import logger from "@meadown/logger"
56
53
 
57
- logger("Hello world")
58
- logger("Auth", "user logged in")
59
-
60
- logger.warn("This is deprecated")
61
- logger.error("Something went wrong")
54
+ logger("server started", { port: 3000 })
62
55
  ```
63
56
 
64
57
  ```text
65
58
  [INFO]
66
- ├── Auth user logged in
67
- └── 05-30 04:00:00 PM - (server.ts:42)
59
+ ├── server started { port: 3000 }
60
+ └── 05-30 04:00:00 PM - (server.ts:5)
68
61
  ```
69
62
 
70
- ### Recommended: single shared import
63
+ Works out of the box. Set `NODE_ENV=production` when you ship and the logs
64
+ disappear — no wrappers, no cleanup, nothing to remember.
65
+
66
+ ### Single shared import
71
67
 
72
- Rather than importing directly from `@meadown/logger` in every file, create
73
- one shared module in your project and re-export from there. This gives you a
74
- single place to set options like `maxLines` and keeps any future changes to
75
- one file.
68
+ Create one module in your project and re-export from there. One place to set
69
+ options, one place to change if you ever need to.
76
70
 
77
71
  ```ts
78
72
  // lib/logger.ts
@@ -88,8 +82,8 @@ export default logger
88
82
  import logger from "@/lib/logger"
89
83
  ```
90
84
 
91
- When re-exporting, use a direct re-export, Not a wrapper function. A wrapper
92
- breaks the caller location shown in every log line.
85
+ Use a direct re-export not a wrapper function. A wrapper breaks the
86
+ `(file:line)` link on every log.
93
87
 
94
88
  ```ts
95
89
  // GOOD — location stays honest
@@ -99,10 +93,62 @@ export { default as logger } from "@meadown/logger"
99
93
  export const logger = (...args) => log(...args)
100
94
  ```
101
95
 
102
- ## API response logging
96
+ ## API
97
+
98
+ ```text
99
+ ┌─────────────────┬─────────────┬──────────────────────────┬───────────────────────────┐
100
+ │ Method │ Tag │ Params │ Purpose │
101
+ ├─────────────────┼─────────────┼──────────────────────────┼───────────────────────────┤
102
+ │ logger() │ [INFO] │ ...args: unknown[] │ general info │
103
+ ├─────────────────┼─────────────┼──────────────────────────┼───────────────────────────┤
104
+ │ logger.warn() │ [WARN] │ ...args: unknown[] │ something needs attention │
105
+ ├─────────────────┼─────────────┼──────────────────────────┼───────────────────────────┤
106
+ │ logger.error() │ [ERROR] │ ...args: unknown[] │ something broke │
107
+ ├─────────────────┼─────────────┼──────────────────────────┼───────────────────────────┤
108
+ │ logger.tap() │ [TAP] │ value: T, label?: string │ log value, returns as-is │
109
+ ├─────────────────┼─────────────┼──────────────────────────┼───────────────────────────┤
110
+ │ logger.group() │ [name] │ { name: string, │ consolidate related │
111
+ │ │ │ type?: LogChannel, │ items under a label │
112
+ │ │ │ logs: unknown[] } │ │
113
+ ├─────────────────┼─────────────┼──────────────────────────┼───────────────────────────┤
114
+ │ logger.maxLines │ — │ number │ cap output at N lines │
115
+ └─────────────────┴─────────────┴──────────────────────────┴───────────────────────────┘
116
+ ```
117
+
118
+ Every tag is self-describing. You scan the logs and immediately know what each
119
+ entry is without reading the message. That's the design principle holding the
120
+ whole API together.
121
+
122
+ ### `logger()`
123
+
124
+ Your everyday log. Pass it anything — strings, objects, errors, whatever.
125
+ Works exactly like `console.log`, just prettier.
126
+
127
+ ```ts
128
+ logger("server started")
129
+ logger("user logged in", { userId: 42, role: "admin" })
130
+ ```
131
+
132
+ ```text
133
+ [INFO]
134
+ ├── user logged in { userId: 42, role: 'admin' }
135
+ └── 05-30 04:00:00 PM - (server.ts:12)
136
+ ```
137
+
138
+ ### `logger.tap()`
139
+
140
+ The one you reach for when you want to see what's inside something without
141
+ stopping to assign it to a variable first. Logs it and gives it straight back.
142
+
143
+ ```ts
144
+ const port = logger.tap(5000, "port")
145
+ server.listen(logger.tap(port, "port"))
146
+ ```
147
+
148
+ #### API response logging
103
149
 
104
- Drop `tap` into any `await` chain. You get timing, status, size, and the
105
- actual response body. The promise flows through untouched. One line of code.
150
+ Drop it into any `await` and you get timing, status, size, and the response
151
+ body without touching your code at all.
106
152
 
107
153
  ```ts
108
154
  const user = await logger.tap(
@@ -129,15 +175,14 @@ const user = await logger.tap(
129
175
  └── 05-30 07:54:26 PM - (api.ts:12)
130
176
  ```
131
177
 
132
- You can immediately see: was it successful? How long did it take? What came
133
- back? Without opening DevTools.
178
+ Was it successful? How long did it take? What came back? All there, without
179
+ opening DevTools.
134
180
 
135
181
  ![API response logging: tap a fetch and see timing, status, size, and body](media/tap-api-demo.png)
136
182
 
137
- ### Tap any value
183
+ #### Tap any value
138
184
 
139
- `tap` works on anything, not just fetch. Pass in any value or expression and
140
- get it back exactly as it was. The only thing that happens is a log.
185
+ Not just fetch. Any value, any expression. Logged and returned as-is.
141
186
 
142
187
  ```ts
143
188
  // numbers, strings, objects — logged and returned as-is
@@ -147,7 +192,7 @@ logger.tap(config, "loaded config")
147
192
  ```
148
193
 
149
194
  ```ts
150
- // async functions promise flows through, timing logged when it settles
195
+ // promises — flows through, timing logged when it settles
151
196
  const user = await logger.tap(getUser(), "getUser")
152
197
  const config = await logger.tap(loadConfig(), "loadConfig")
153
198
  ```
@@ -157,43 +202,96 @@ const config = await logger.tap(loadConfig(), "loadConfig")
157
202
  server.listen(logger.tap(port, "port"))
158
203
  ```
159
204
 
160
- If it's a promise, `tap` logs elapsed time once it settles. If it resolves
161
- to a `Response` (any fetch like call), you also get status and size, same
162
- as the fetch example above.
205
+ If it's a promise, timing is logged once it settles. If it resolves to a
206
+ `Response`, you also get status and size.
163
207
 
164
- ## Clickable source link
208
+ ### `logger.group()`
165
209
 
166
- That `(server.ts:42)` is a **clickable link**. Click it and your editor opens the file and jumps straight to that line. Works in VS Code, iTerm2, WezTerm, Kitty, and Windows Terminal. Degrades to plain text everywhere else.
210
+ Got a handful of related things to log at once? Group them. One block, one
211
+ timestamp, one place to look.
167
212
 
168
- ## Color-coded levels
213
+ ```ts
214
+ logger.group({
215
+ name: "Server setup",
216
+ logs: [
217
+ `Running on port ${port}`,
218
+ `Environment: ${env}`,
219
+ `API: http://localhost:${port}/api`,
220
+ ],
221
+ })
222
+ ```
223
+
224
+ ```text
225
+ [SERVER SETUP]
226
+ ├── Running on port 5000
227
+ ├── Environment: development
228
+ ├── API: http://localhost:5000/api
229
+ └── 05-30 04:00:00 PM - (server.ts:23)
230
+ ```
231
+
232
+ Use `type` to set the channel and tag color. Defaults to `"log"` (cyan, stdout).
233
+
234
+ ```ts
235
+ logger.group({
236
+ name: "Validation failed",
237
+ type: "error", // red, stderr
238
+ logs: ["email invalid", "password too short"],
239
+ })
240
+
241
+ logger.group({
242
+ name: "Config warnings",
243
+ type: "warn", // yellow, stderr
244
+ logs: ["deprecated key found", "missing optional field"],
245
+ })
246
+ ```
247
+
248
+ `logs` takes anything — strings, objects, arrays, errors. Each renders exactly
249
+ as `console.log` would.
250
+
251
+ ### `logger.error()`
169
252
 
170
- `[INFO]` , `[TAP]` cyan · `[WARN]` yellow · `[ERROR]` red. Timestamp and location tinted teal.
171
- Auto-disabled when output is piped no escape codes in your log files.
253
+ Red tag, goes to `stderr`. Pass an `Error` and you get the stack too.
172
254
 
173
- ## Tree layout output
255
+ ```ts
256
+ logger.error("database connection failed", new Error("ECONNREFUSED"))
257
+ ```
174
258
 
175
259
  ```text
176
- [INFO]
177
- ├── Auth user logged in
178
- └── 05-30 04:00:00 PM - (server.ts:42)
260
+ [ERROR]
261
+ ├── database connection failed Error: ECONNREFUSED
262
+ │ at Object.<anonymous> (server.ts:14:18)
263
+ └── 05-30 04:00:00 PM - (server.ts:14)
264
+ ```
265
+
266
+ ### `logger.warn()`
267
+
268
+ Yellow tag, `stderr`. For the things that aren't broken yet.
269
+
270
+ ```ts
271
+ logger.warn("disk usage above 80%")
272
+ logger.warn("deprecated config key", { key: "timeout", use: "timeoutMs" })
273
+ ```
274
+
275
+ ```text
276
+ [WARN]
277
+ ├── disk usage above 80%
278
+ └── 05-30 04:00:00 PM - (monitor.ts:8)
179
279
  ```
180
280
 
181
- Level tag, message, timestamp, and location all in a clean tree. Easy to scan,
182
- even in a busy terminal.
281
+ ### `logger.maxLines`
183
282
 
184
- ## Collapsible messages
283
+ Got a massive object dumping 200 lines? Set this and it cuts off after N lines
284
+ with a count of what's hidden. Set back to `0` to show everything again.
185
285
 
186
286
  ```ts
187
287
  logger.maxLines = 5 // show 5 lines, then "... N more lines"
188
288
  logger.maxLines = 0 // default — show everything
189
289
  ```
190
290
 
191
- ## NODE_ENV
291
+ ## Production
192
292
 
193
- You shouldn't have to think about whether your logs will leak into production.
194
- This package reads `NODE_ENV` and handles it for you. Set it to `production`
195
- and all output is handled for you. You never have to remember to wrap a log call,
196
- remove a debug line, or grep the codebase before a release.
293
+ Set `NODE_ENV=production` and everything goes silent. No wrapper calls, no
294
+ grep before release, no accidental logs in prod.
197
295
 
198
296
  | `NODE_ENV` | Logs? |
199
297
  | ---------------------------------------- | ---------- |
@@ -2,7 +2,7 @@
2
2
  /*
3
3
  * config.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,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";
@@ -2,20 +2,14 @@
2
2
  /*
3
3
  * constants.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
  * Single home for the logger's layout/behavior constants, so the values that
9
9
  * shape an entry live in one place instead of as magic literals across modules.
10
10
  */
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.DEFAULT_MAX_LINES = exports.MESSAGE_INDENT = exports.SEPARATOR = exports.BRANCH_END = exports.BRANCH = exports.TAG_COLOR = void 0;
13
- /** The tag color per channel: info/tap → cyan, warn → yellow, error → red. */
14
- exports.TAG_COLOR = {
15
- log: "cyan",
16
- warn: "yellow",
17
- error: "red",
18
- };
12
+ exports.DEFAULT_MAX_LINES = exports.MESSAGE_INDENT = exports.SEPARATOR = exports.BRANCH_END = exports.BRANCH = void 0;
19
13
  /** Glyphs that draw each entry's little tree. */
20
14
  exports.BRANCH = "├──"; // the message branch
21
15
  exports.BRANCH_END = "└──"; // the last (metadata) branch
@@ -2,7 +2,7 @@
2
2
  /*
3
3
  * getCaller.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
  * color.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
  * link.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
  * isTTY.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
  * getTimeStamp.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 });
@@ -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,40 @@
1
+ "use strict";
2
+ /*
3
+ * buildContext.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.TAG_COLOR = void 0;
13
+ exports.buildContext = buildContext;
14
+ const index_js_1 = require("../../../const/index.js");
15
+ const color_js_1 = require("../../colors/color.js");
16
+ /** Tag color per channel — cyan for log/tap, yellow for warn, red for error. */
17
+ exports.TAG_COLOR = {
18
+ log: "cyan",
19
+ warn: "yellow",
20
+ error: "red",
21
+ };
22
+ const isTTY_js_1 = require("../../terminal/isTTY.js");
23
+ const getTimeStamp_js_1 = __importDefault(require("../../time/getTimeStamp.js"));
24
+ const formatLocation_js_1 = require("./formatLocation.js");
25
+ /** Builds the shared paint/layout values used by both writeLog and writeGroup. */
26
+ function buildContext(channel, caller) {
27
+ const streamName = channel === "log" ? "stdout" : "stderr";
28
+ const useColor = (0, isTTY_js_1.isTTY)(streamName);
29
+ const paint = (s, c) => (useColor ? (0, color_js_1.colorize)(s, c) : s);
30
+ const location = (0, formatLocation_js_1.formatLocation)(caller, useColor);
31
+ return {
32
+ useColor,
33
+ paint,
34
+ timeStamp: paint((0, getTimeStamp_js_1.default)(), "teal"),
35
+ locOut: paint(`(${location})`, "dimTeal"),
36
+ connector: paint(index_js_1.BRANCH, "gray"),
37
+ connectorEnd: paint(index_js_1.BRANCH_END, "gray"),
38
+ separator: paint(index_js_1.SEPARATOR, "gray"),
39
+ };
40
+ }
@@ -2,7 +2,7 @@
2
2
  /*
3
3
  * formatLocation.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 });
@@ -13,7 +13,8 @@ const link_js_1 = require("../../decorations/link.js");
13
13
  * supporting terminal, plain text otherwise. Pure (no stack access).
14
14
  */
15
15
  function formatLocation(caller, interactive) {
16
- if (caller.file !== null && caller.line !== null && interactive)
16
+ if (caller.file !== null && caller.line !== null && interactive) {
17
17
  return (0, link_js_1.hyperlink)(caller.label, (0, link_js_1.fileUrl)(caller.file));
18
+ }
18
19
  return caller.label;
19
20
  }
@@ -0,0 +1,4 @@
1
+ export { visibleLines, getVisibleLines, setVisibleLines, } from "./visibleLines.js";
2
+ export { renderMessage } from "./renderMessage.js";
3
+ export { formatLocation } from "./formatLocation.js";
4
+ export { buildContext, TAG_COLOR } from "./buildContext.js";
@@ -0,0 +1,20 @@
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.TAG_COLOR = exports.buildContext = exports.formatLocation = exports.renderMessage = exports.setVisibleLines = exports.getVisibleLines = exports.visibleLines = void 0;
10
+ var visibleLines_js_1 = require("./visibleLines.js");
11
+ Object.defineProperty(exports, "visibleLines", { enumerable: true, get: function () { return visibleLines_js_1.visibleLines; } });
12
+ Object.defineProperty(exports, "getVisibleLines", { enumerable: true, get: function () { return visibleLines_js_1.getVisibleLines; } });
13
+ Object.defineProperty(exports, "setVisibleLines", { enumerable: true, get: function () { return visibleLines_js_1.setVisibleLines; } });
14
+ var renderMessage_js_1 = require("./renderMessage.js");
15
+ Object.defineProperty(exports, "renderMessage", { enumerable: true, get: function () { return renderMessage_js_1.renderMessage; } });
16
+ var formatLocation_js_1 = require("./formatLocation.js");
17
+ Object.defineProperty(exports, "formatLocation", { enumerable: true, get: function () { return formatLocation_js_1.formatLocation; } });
18
+ var buildContext_js_1 = require("./buildContext.js");
19
+ Object.defineProperty(exports, "buildContext", { enumerable: true, get: function () { return buildContext_js_1.buildContext; } });
20
+ Object.defineProperty(exports, "TAG_COLOR", { enumerable: true, get: function () { return buildContext_js_1.TAG_COLOR; } });
@@ -2,15 +2,15 @@
2
2
  /*
3
3
  * renderMessage.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.renderMessage = renderMessage;
10
10
  const node_util_1 = require("node:util");
11
- const constants_js_1 = require("../../constants.js");
12
- const color_js_1 = require("../../colors/color.js");
13
11
  const visibleLines_js_1 = require("./visibleLines.js");
12
+ const color_js_1 = require("../../colors/color.js");
13
+ const index_js_1 = require("../../../const/index.js");
14
14
  /**
15
15
  * Collapses a long multi-line message to {@link visibleLines} lines, replacing
16
16
  * the rest with a dimmed `… N more lines` summary. When `visibleLines` is 0
@@ -23,7 +23,7 @@ function collapse(text, useColor) {
23
23
  if (lines.length <= visibleLines_js_1.visibleLines)
24
24
  return text;
25
25
  const hidden = lines.length - visibleLines_js_1.visibleLines;
26
- const summary = `${constants_js_1.MESSAGE_INDENT}... ${hidden} more line${hidden === 1 ? "" : "s"}`;
26
+ const summary = `${index_js_1.MESSAGE_INDENT}... ${hidden} more line${hidden === 1 ? "" : "s"}`;
27
27
  const visible = lines.slice(0, visibleLines_js_1.visibleLines);
28
28
  visible.push(useColor ? (0, color_js_1.colorize)(summary, "gray") : summary);
29
29
  return visible.join("\n");
@@ -36,5 +36,6 @@ function collapse(text, useColor) {
36
36
  */
37
37
  function renderMessage(args, useColor) {
38
38
  const text = (0, node_util_1.formatWithOptions)({ colors: useColor }, ...args);
39
- return collapse(text.replace(/\n/g, `\n${(0, color_js_1.colorize)(constants_js_1.MESSAGE_INDENT, "gray")}`), useColor);
39
+ const indent = useColor ? (0, color_js_1.colorize)(index_js_1.MESSAGE_INDENT, "gray") : index_js_1.MESSAGE_INDENT;
40
+ return collapse(text.replace(/\n/g, `\n${indent}`), useColor);
40
41
  }
@@ -2,16 +2,16 @@
2
2
  /*
3
3
  * visibleLines.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.visibleLines = void 0;
10
10
  exports.getVisibleLines = getVisibleLines;
11
11
  exports.setVisibleLines = setVisibleLines;
12
- const constants_js_1 = require("../../constants.js");
12
+ const index_js_1 = require("../../../const/index.js");
13
13
  /** Max message lines to show before collapsing the rest; 0 (default) shows all. */
14
- exports.visibleLines = constants_js_1.DEFAULT_MAX_LINES;
14
+ exports.visibleLines = index_js_1.DEFAULT_MAX_LINES;
15
15
  /** How many lines a long message shows before collapsing (0 = all). */
16
16
  function getVisibleLines() {
17
17
  return exports.visibleLines;
@@ -0,0 +1,2 @@
1
+ export { writeLog } from "./writeLog.js";
2
+ export { getVisibleLines, setVisibleLines } from "./helpers/index.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
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.setVisibleLines = exports.getVisibleLines = exports.writeLog = void 0;
10
+ var writeLog_js_1 = require("./writeLog.js");
11
+ Object.defineProperty(exports, "writeLog", { enumerable: true, get: function () { return writeLog_js_1.writeLog; } });
12
+ var index_js_1 = require("./helpers/index.js");
13
+ Object.defineProperty(exports, "getVisibleLines", { enumerable: true, get: function () { return index_js_1.getVisibleLines; } });
14
+ Object.defineProperty(exports, "setVisibleLines", { enumerable: true, get: function () { return index_js_1.setVisibleLines; } });
@@ -1,6 +1,5 @@
1
- import { type LogChannel } from "../../constants.js";
2
- import { type Caller } from "../../caller/getCaller.js";
3
- export { getVisibleLines, setVisibleLines } from "./visibleLines.js";
1
+ import { type LogChannel } from "../../types/index.js";
2
+ import { type Caller } from "../caller/getCaller.js";
4
3
  /**
5
4
  * Renders and writes one log entry. The `caller` is resolved by the *caller* of
6
5
  * this function (the log closure or `tap`) and passed in, so this helper never
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ /*
3
+ * writeLog.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.writeLog = writeLog;
10
+ const index_js_1 = require("./helpers/index.js");
11
+ /**
12
+ * Renders and writes one log entry. The `caller` is resolved by the *caller* of
13
+ * this function (the log closure or `tap`) and passed in, so this helper never
14
+ * touches the stack — keeping {@link getCaller}'s frame depth correct no matter
15
+ * which user-facing function delegates here.
16
+ */
17
+ function writeLog(opts) {
18
+ const { channel, tag, args, caller } = opts;
19
+ const { useColor, paint, timeStamp, locOut, connector, connectorEnd, separator, } = (0, index_js_1.buildContext)(channel, caller);
20
+ const tagOut = paint(tag, index_js_1.TAG_COLOR[channel]);
21
+ const message = (0, index_js_1.renderMessage)(args, useColor);
22
+ const meta = `\n${connectorEnd} ${timeStamp} ${separator} ${locOut}`;
23
+ console[channel](`\n${tagOut} \n${connector} ${message}${meta}`);
24
+ }
@@ -0,0 +1 @@
1
+ export default function log(...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 = log;
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 log(...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: "log", tag: "[INFO]", args, caller });
21
+ }
@@ -0,0 +1 @@
1
+ export default function logError(...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 = logError;
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 logError(...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: "error", tag: "[ERROR]", args, caller });
21
+ }