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 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.** 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.
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
- - ๐Ÿ•’ **Readable timestamps.** Local time by default (or `--utc`), with a missing timestamp filled in from the current time.
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
@@ -10,6 +10,7 @@ declare class PinoNice {
10
10
  private readonly minLevel;
11
11
  constructor(options?: PinoNiceOptions);
12
12
  private handleLine;
13
+ private write;
13
14
  pipe(): Promise<void>;
14
15
  }
15
16
 
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) return;
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(out.join("\n") + "\n");
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pino-nice",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "Pretty-print pino (and pino-like) JSON logs from stdin with a clean, human-friendly streaming view.",
5
5
  "type": "module",
6
6
  "author": "Tim Zadorozhny <tzador@gmail.com>",