pino-nice 0.0.1 โ 0.0.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.
- package/README.md +15 -4
- package/dist/pino-nice.d.ts +1 -0
- package/dist/pino-nice.js +13 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -16,9 +16,10 @@ Structured JSON logs are great for machines and terrible for human eyes. `pino-p
|
|
|
16
16
|
|
|
17
17
|
- ๐งพ **Sectioned details + headline.** Each record renders its structured fields as an indented, YAML-like block, connected with box-drawing lines (`โ` / `โโ`) down to a single headline `LEVEL timestamp message`.
|
|
18
18
|
- ๐จ **Color-coded levels.** `trace`/`debug`/`info`/`warn`/`error`/`fatal` each get a distinct color, applied to the connectors too, so severity pops at a glance.
|
|
19
|
-
- ๐งจ **First-class errors.**
|
|
19
|
+
- ๐งจ **First-class errors.** Serialized errors are detected by shape under _any_ key (`err`, `error`, or nested), stack traces are cleaned up, internal `node_modules`/`node:` frames are dimmed, and nested `cause` chains and `AggregateError`s are rendered with their structure intact.
|
|
20
20
|
- ๐ **Works with more than pino.** Recognizes pino defaults plus common aliases like `severity` / `message` / `timestamp`, so logs from other services format nicely too.
|
|
21
|
-
- ๐ **
|
|
21
|
+
- ๐ **Theme-friendly timestamps.** The clock (`HH:MM:SS`) is bold while the date and milliseconds are dimmed, so it stays readable on both dark and light terminals. Local time by default (or `--utc`, which appends a `Z`), with a missing timestamp filled in from the current time.
|
|
22
|
+
- ๐ชข **Verbatim passthrough.** Lines that aren't recognized as logs (plain text, malformed JSON, or JSON without a level) are printed through untouched, so interleaved non-log output isn't swallowed.
|
|
22
23
|
- ๐ **URL-safe wrapping.** Lines flow to your terminal's width with no manual mid-token breaks, so long URLs stay clickable.
|
|
23
24
|
- ๐ **Bun & Node, zero runtime deps.** Ships as a tiny dependency-free CLI.
|
|
24
25
|
|
|
@@ -88,12 +89,22 @@ If you pass several level flags, the **last one wins** (e.g. `--error --info` sh
|
|
|
88
89
|
|
|
89
90
|
pino-nice resolves fields from common conventions:
|
|
90
91
|
|
|
91
|
-
- **Level:** `level` (numeric `10`โ`60`) or `severity` (`"INFO"`, `"DEBUG"`, ...)
|
|
92
|
-
- **Message:** `msg` or `message`
|
|
92
|
+
- **Level:** `level` (numeric `10`โ`60`) or `severity` (`"INFO"`, `"DEBUG"`, ...) โ the only required field
|
|
93
|
+
- **Message:** `msg` or `message` โ optional (e.g. `log.info({ obj })` renders fine without one)
|
|
93
94
|
- **Timestamp:** `time` or `timestamp` (epoch ms or ISO string); if absent, the current time is used
|
|
94
95
|
|
|
95
96
|
All six pino levels are supported: `trace` (10), `debug` (20), `info` (30), `warn` (40), `error` (50), `fatal` (60).
|
|
96
97
|
|
|
98
|
+
### Non-log lines
|
|
99
|
+
|
|
100
|
+
Any line that can't be recognized as a log is passed through **verbatim**:
|
|
101
|
+
|
|
102
|
+
- not valid JSON (plain text, banners, malformed JSON)
|
|
103
|
+
- valid JSON that isn't an object (e.g. a bare array or string)
|
|
104
|
+
- a JSON object with no `level` field
|
|
105
|
+
|
|
106
|
+
This keeps `pino-nice` transparent for mixed streams. Recognized logs that fall below the active level filter (e.g. `--warn`) are still dropped โ filtering is intentional, passthrough is for genuinely unrecognized lines. Blank lines are ignored.
|
|
107
|
+
|
|
97
108
|
## ๐ License
|
|
98
109
|
|
|
99
110
|
[MIT](LICENSE) ยฉ Tim Zadorozhny
|
package/dist/pino-nice.d.ts
CHANGED
package/dist/pino-nice.js
CHANGED
|
@@ -276,11 +276,18 @@ var PinoNice = class {
|
|
|
276
276
|
try {
|
|
277
277
|
entry = JSON.parse(line);
|
|
278
278
|
} catch {
|
|
279
|
+
this.write(rawLine + "\n");
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
if (!isPlainObject(entry)) {
|
|
283
|
+
this.write(rawLine + "\n");
|
|
279
284
|
return;
|
|
280
285
|
}
|
|
281
|
-
if (!isPlainObject(entry)) return;
|
|
282
286
|
const level = firstDefined(entry, LEVEL_KEYS);
|
|
283
|
-
if (level === void 0)
|
|
287
|
+
if (level === void 0) {
|
|
288
|
+
this.write(rawLine + "\n");
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
284
291
|
const message = firstDefined(entry, MESSAGE_KEYS) ?? "";
|
|
285
292
|
const time = firstDefined(entry, TIME_KEYS) ?? Date.now();
|
|
286
293
|
if (levelToNumber(level) < this.minLevel) return;
|
|
@@ -295,8 +302,11 @@ var PinoNice = class {
|
|
|
295
302
|
out.push(info.color(BOX.vertical) + " " + dataLine);
|
|
296
303
|
}
|
|
297
304
|
out.push(summaryLine(time, level, message, this.utc));
|
|
305
|
+
this.write(out.join("\n") + "\n");
|
|
306
|
+
}
|
|
307
|
+
write(text) {
|
|
298
308
|
try {
|
|
299
|
-
process.stdout.write(
|
|
309
|
+
process.stdout.write(text);
|
|
300
310
|
} catch (error) {
|
|
301
311
|
if (error?.code === "EPIPE") process.exit(0);
|
|
302
312
|
throw error;
|
package/package.json
CHANGED