Dev Helpers

Node.js / Utility functions

Format a diagnostic message

Dev Helpers · September 4, 2025

Formatted diagnostic messages combine fixed text and inspected values. Check how the formatter treats objects and unused arguments.

Worked example

import * as util from "node:util";
console.log(util.format("%s: %d", "jobs", 3));

Result

jobs: 3

Implementation notes

Formatting happens before the message reaches its destination. Avoid including credentials or full request bodies in a diagnostic argument.

Try it yourself

Log a nested object alongside a literal percent sign.

Open the Node.js example →

Editorial date September 4, 2025 · Published December 6, 2026

Related articles

Safely parse malformed input

Parsing user-provided JSON needs a failure path. Successful parsing alone does not establish that the result has the expected shape.

Checksum bytes with CRC32

CRC32 is useful for detecting accidental changes to a byte sequence. Record the input encoding so different producers compute the same checksum.

Attach details to a mark

Performance marks can carry details about the operation they describe. Small stable identifiers are easier to aggregate than large payloads.