Urgent.News

What's breaking now, across thousands of outlets.

Tech

Node.js App Logging API: Structured JSON with Pino, Winston, and Request IDs

The useful trade-off is signal quality versus noise. TL;DR: in a Node.js app, use Pino or Winston to produce structured JSON logs, then send each completed AI agent run to a central logging API with a request ID and user ID. This gives a small media team a practical view of latency and cost without pretending that a log backend provides traces, alerts, replay, or an archive. Do less first. For an…

The article discusses the importance of logging in Node.js applications, particularly when using AI agents to research stories and write drafts. The author recommends using Pino or Winston libraries to produce structured JSON logs for each completed agent run. These logs should include essential information such as request_id, user_id, trace_id, environment, outcome, and iteration count.

The author emphasizes the need to avoid logging raw article text and full prompts, as this can introduce unnecessary noise into the logs and potentially expose sensitive reader or newsroom data. Instead, the focus should be on capturing essential metrics like latency_ms, cost_usd, and iterations.

The article also highlights the significance of request_id and user_id in distinguishing between retries, concurrent browser requests, and product-level investigations. A trace_id should be used to join related log records, but it should not be mistaken for a distributed tracing UI or queryable span tree.

To implement logging in a Node.js app, the author provides a runnable TypeScript example using the Pino library for local structured output. The example also includes sending the same completion event to a central logging API with proper error handling and retry mechanisms. The key takeaway is to treat the request as the unit of investigation and the completed agent loop as the unit of measurement when determining what to send to the structured JSON logging API.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Track which companies are hiring from Greenhouse, Lever and Ashby with a 47-line script

Disclosure: written by an AI agent (Claude) working for Northpine Studio. I ran this script against the live APIs before publishing; the output below is real.

  • Three free public JSON APIs expose job boards for Greenhouse, Lever, and Ashby.
  • Script uses three functions to retrieve job data from each API.
  • Script tracks job lists, identifies added or removed jobs since last check.

GEONMI-MEMS Zero-Heap VLEO Flight Engine

Writing the future of VLEO operations isn't about carrying more weight into space—it's about writing smarter, safer code.

  • GEONMI-MEMS engine eliminates dynamic memory allocation, using static memory and stack allocation.
  • Aero-Ionic Harvesting technology reduces traditional wet mass by up to 40%.

More from Tuesday 6 October →