@meadown/logger 1.8.6 → 1.8.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.
@@ -23,10 +23,10 @@ export default function getCaller() {
23
23
  // Split off the trailing `:line:column`, keeping the (possibly colon-bearing)
24
24
  // path intact (e.g. Windows `C:\…` or `file://…`).
25
25
  const match = inner.match(/^(.*):(\d+):\d+$/);
26
- const file = match?.[1];
27
- if (file === undefined)
26
+ if (match === null)
28
27
  return UNKNOWN;
29
- const line = Number(match?.[2]);
28
+ const file = match[1] ?? "";
29
+ const line = Number(match[2]);
30
30
  const base = file.split(/[/\\]/).pop() ?? "";
31
31
  if (!SOURCE_FILE.test(base))
32
32
  return UNKNOWN;
@@ -26,10 +26,10 @@ function getCaller() {
26
26
  // Split off the trailing `:line:column`, keeping the (possibly colon-bearing)
27
27
  // path intact (e.g. Windows `C:\…` or `file://…`).
28
28
  const match = inner.match(/^(.*):(\d+):\d+$/);
29
- const file = match?.[1];
30
- if (file === undefined)
29
+ if (match === null)
31
30
  return UNKNOWN;
32
- const line = Number(match?.[2]);
31
+ const file = match[1] ?? "";
32
+ const line = Number(match[2]);
33
33
  const base = file.split(/[/\\]/).pop() ?? "";
34
34
  if (!SOURCE_FILE.test(base))
35
35
  return UNKNOWN;
@@ -9,6 +9,6 @@ export declare const BRANCH_END = "\u2514\u2500\u2500";
9
9
  export declare const SEPARATOR = "-";
10
10
  /** Hang-indent for message continuation lines, so they align under the message
11
11
  * text (the `├── ` branch is 4 columns wide). */
12
- export declare const MESSAGE_INDENT = "|\t";
12
+ export declare const MESSAGE_INDENT = "\u2502 ";
13
13
  /** Default for the collapse setting: 0 = show every line. */
14
14
  export declare const DEFAULT_MAX_LINES = 0;
@@ -22,6 +22,6 @@ exports.BRANCH_END = "└──"; // the last (metadata) branch
22
22
  exports.SEPARATOR = "-"; // between the timestamp and the location
23
23
  /** Hang-indent for message continuation lines, so they align under the message
24
24
  * text (the `├── ` branch is 4 columns wide). */
25
- exports.MESSAGE_INDENT = "|\t";
25
+ exports.MESSAGE_INDENT = "";
26
26
  /** Default for the collapse setting: 0 = show every line. */
27
27
  exports.DEFAULT_MAX_LINES = 0;
@@ -76,17 +76,14 @@ function writeLog(opts) {
76
76
  // One terminal check drives both color and clickable links — `isTTY` is the
77
77
  // single source of truth (DRY). Off when output is piped/redirected.
78
78
  const useColor = (0, isTTY_js_1.isTTY)(streamName);
79
+ const paint = (s, c) => useColor ? (0, color_js_1.colorize)(s, c) : s;
79
80
  const location = formatLocation(caller, useColor);
80
- // Colors (terminal only): tag by level, timestamp teal, location dim teal,
81
- // branch and separator gray.
82
- const tagOut = useColor ? (0, color_js_1.colorize)(tag, constants_js_1.TAG_COLOR[channel]) : tag;
83
- const timeStamp = useColor ? (0, color_js_1.colorize)((0, getTimeStamp_js_1.default)(), "teal") : (0, getTimeStamp_js_1.default)();
84
- const locOut = useColor
85
- ? (0, color_js_1.colorize)(`(${location})`, "dimTeal")
86
- : `(${location})`;
87
- const connector = useColor ? (0, color_js_1.colorize)(constants_js_1.BRANCH, "gray") : constants_js_1.BRANCH;
88
- const connectorBottom = useColor ? (0, color_js_1.colorize)(constants_js_1.BRANCH_END, "gray") : constants_js_1.BRANCH_END;
89
- const separator = useColor ? (0, color_js_1.colorize)(constants_js_1.SEPARATOR, "gray") : constants_js_1.SEPARATOR;
81
+ const tagOut = paint(tag, constants_js_1.TAG_COLOR[channel]);
82
+ const timeStamp = paint((0, getTimeStamp_js_1.default)(), "teal");
83
+ const locOut = paint(`(${location})`, "dimTeal");
84
+ const connector = paint(constants_js_1.BRANCH, "gray");
85
+ const connectorBottom = paint(constants_js_1.BRANCH_END, "gray");
86
+ const separator = paint(constants_js_1.SEPARATOR, "gray");
90
87
  // Layout: the tag, the message hanging off a `├──` branch, then the timestamp
91
88
  // and location on a `└──` branch below. Leading `\n` spaces entries apart.
92
89
  const message = renderMessage(args, useColor);
@@ -106,23 +106,18 @@ async function readBody(res) {
106
106
  * │ └── name: Leanne Graham
107
107
  */
108
108
  function buildBlock(label, ms, res, body, useColor) {
109
- const pipe = useColor ? (0, color_js_1.colorize)("│", "gray") : "│";
110
- const branch = useColor ? (0, color_js_1.colorize)("├──", "gray") : "├──";
111
- const last = useColor ? (0, color_js_1.colorize)("└──", "gray") : "└──";
109
+ const paint = (s, c) => useColor ? (0, color_js_1.colorize)(s, c) : s;
110
+ const pipe = paint("", "gray");
111
+ const branch = paint("├──", "gray");
112
+ const last = paint("└──", "gray");
112
113
  const indent = `${pipe} `;
113
- const statusLine = `${indent}${branch} status: ${formatStatus(res, useColor)}`;
114
114
  const timeLine = `${indent}${branch} time: ${formatDuration(ms, useColor)}`;
115
+ const statusLine = `${indent}${branch} status: ${formatStatus(res, useColor)}`;
115
116
  const sizeLine = `${indent}${last} size: ${body.size}`;
116
- const responseBlock = [
117
- `${pipe}`,
118
- `${indent}response:`,
119
- timeLine,
120
- statusLine,
121
- sizeLine,
122
- ].join("\n");
117
+ const responseLines = [`${pipe}`, `${indent}response:`, timeLine, statusLine, sizeLine];
118
+ const head = label === undefined ? "" : `${label}\n`;
123
119
  if (body.data === undefined) {
124
- const head = label === undefined ? "" : `${label}\n`;
125
- return [`${head}${responseBlock}`];
120
+ return [`${head}${responseLines.join("\n")}`];
126
121
  }
127
122
  // Render the body using util.formatWithOptions so objects/arrays look like
128
123
  // console.log output — colors, proper nesting, no JSON.stringify quirkiness.
@@ -132,17 +127,7 @@ function buildBlock(label, ms, res, body, useColor) {
132
127
  const bodyBlock = bodyLines
133
128
  .map((line, i) => `${indent}${i === lastIdx ? last : branch} ${line}`)
134
129
  .join("\n");
135
- const full = [
136
- `${pipe}`,
137
- `${indent}response:`,
138
- timeLine,
139
- statusLine,
140
- sizeLine,
141
- `${pipe}`,
142
- `${indent}body:`,
143
- bodyBlock,
144
- ].join("\n");
145
- const head = label === undefined ? "" : `${label}\n`;
130
+ const full = [...responseLines, `${pipe}`, `${indent}body:`, bodyBlock].join("\n");
146
131
  return [`${head}${full}`];
147
132
  }
148
133
  /**
@@ -9,6 +9,6 @@ export declare const BRANCH_END = "\u2514\u2500\u2500";
9
9
  export declare const SEPARATOR = "-";
10
10
  /** Hang-indent for message continuation lines, so they align under the message
11
11
  * text (the `├── ` branch is 4 columns wide). */
12
- export declare const MESSAGE_INDENT = "|\t";
12
+ export declare const MESSAGE_INDENT = "\u2502 ";
13
13
  /** Default for the collapse setting: 0 = show every line. */
14
14
  export declare const DEFAULT_MAX_LINES = 0;
package/dist/constants.js CHANGED
@@ -19,6 +19,6 @@ export const BRANCH_END = "└──"; // the last (metadata) branch
19
19
  export const SEPARATOR = "-"; // between the timestamp and the location
20
20
  /** Hang-indent for message continuation lines, so they align under the message
21
21
  * text (the `├── ` branch is 4 columns wide). */
22
- export const MESSAGE_INDENT = "|\t";
22
+ export const MESSAGE_INDENT = "";
23
23
  /** Default for the collapse setting: 0 = show every line. */
24
24
  export const DEFAULT_MAX_LINES = 0;
@@ -68,17 +68,14 @@ export function writeLog(opts) {
68
68
  // One terminal check drives both color and clickable links — `isTTY` is the
69
69
  // single source of truth (DRY). Off when output is piped/redirected.
70
70
  const useColor = isTTY(streamName);
71
+ const paint = (s, c) => useColor ? colorize(s, c) : s;
71
72
  const location = formatLocation(caller, useColor);
72
- // Colors (terminal only): tag by level, timestamp teal, location dim teal,
73
- // branch and separator gray.
74
- const tagOut = useColor ? colorize(tag, TAG_COLOR[channel]) : tag;
75
- const timeStamp = useColor ? colorize(getTimeStamp(), "teal") : getTimeStamp();
76
- const locOut = useColor
77
- ? colorize(`(${location})`, "dimTeal")
78
- : `(${location})`;
79
- const connector = useColor ? colorize(BRANCH, "gray") : BRANCH;
80
- const connectorBottom = useColor ? colorize(BRANCH_END, "gray") : BRANCH_END;
81
- const separator = useColor ? colorize(SEPARATOR, "gray") : SEPARATOR;
73
+ const tagOut = paint(tag, TAG_COLOR[channel]);
74
+ const timeStamp = paint(getTimeStamp(), "teal");
75
+ const locOut = paint(`(${location})`, "dimTeal");
76
+ const connector = paint(BRANCH, "gray");
77
+ const connectorBottom = paint(BRANCH_END, "gray");
78
+ const separator = paint(SEPARATOR, "gray");
82
79
  // Layout: the tag, the message hanging off a `├──` branch, then the timestamp
83
80
  // and location on a `└──` branch below. Leading `\n` spaces entries apart.
84
81
  const message = renderMessage(args, useColor);
@@ -102,23 +102,18 @@ async function readBody(res) {
102
102
  * │ └── name: Leanne Graham
103
103
  */
104
104
  function buildBlock(label, ms, res, body, useColor) {
105
- const pipe = useColor ? colorize("│", "gray") : "│";
106
- const branch = useColor ? colorize("├──", "gray") : "├──";
107
- const last = useColor ? colorize("└──", "gray") : "└──";
105
+ const paint = (s, c) => useColor ? colorize(s, c) : s;
106
+ const pipe = paint("", "gray");
107
+ const branch = paint("├──", "gray");
108
+ const last = paint("└──", "gray");
108
109
  const indent = `${pipe} `;
109
- const statusLine = `${indent}${branch} status: ${formatStatus(res, useColor)}`;
110
110
  const timeLine = `${indent}${branch} time: ${formatDuration(ms, useColor)}`;
111
+ const statusLine = `${indent}${branch} status: ${formatStatus(res, useColor)}`;
111
112
  const sizeLine = `${indent}${last} size: ${body.size}`;
112
- const responseBlock = [
113
- `${pipe}`,
114
- `${indent}response:`,
115
- timeLine,
116
- statusLine,
117
- sizeLine,
118
- ].join("\n");
113
+ const responseLines = [`${pipe}`, `${indent}response:`, timeLine, statusLine, sizeLine];
114
+ const head = label === undefined ? "" : `${label}\n`;
119
115
  if (body.data === undefined) {
120
- const head = label === undefined ? "" : `${label}\n`;
121
- return [`${head}${responseBlock}`];
116
+ return [`${head}${responseLines.join("\n")}`];
122
117
  }
123
118
  // Render the body using util.formatWithOptions so objects/arrays look like
124
119
  // console.log output — colors, proper nesting, no JSON.stringify quirkiness.
@@ -128,17 +123,7 @@ function buildBlock(label, ms, res, body, useColor) {
128
123
  const bodyBlock = bodyLines
129
124
  .map((line, i) => `${indent}${i === lastIdx ? last : branch} ${line}`)
130
125
  .join("\n");
131
- const full = [
132
- `${pipe}`,
133
- `${indent}response:`,
134
- timeLine,
135
- statusLine,
136
- sizeLine,
137
- `${pipe}`,
138
- `${indent}body:`,
139
- bodyBlock,
140
- ].join("\n");
141
- const head = label === undefined ? "" : `${label}\n`;
126
+ const full = [...responseLines, `${pipe}`, `${indent}body:`, bodyBlock].join("\n");
142
127
  return [`${head}${full}`];
143
128
  }
144
129
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meadown/logger",
3
- "version": "1.8.6",
3
+ "version": "1.8.7",
4
4
  "description": "A development-focused logger for Node.js and TypeScript — zero dependencies, clickable source links, and API response logging built in.",
5
5
  "keywords": [
6
6
  "logger",