Registry
Nnodejs avatar

nodejs/util-log-to-console-log

Handle DEP0059 via transforming `log.util()` to `console.log()`.

nodejs4,767 executions

  • transformation
  • migration
  • nodejs
Connect a repo
npx codemod @nodejs/util-log-to-console-log

util.log DEP0059

This recipe transforms the usage of util.log() to use console.log().

See DEP0059.

Example

diff
- const util = require("node:util");

- util.log("Hello world");
+ console.log(new Date().toLocaleString(), "Hello world");

Before:

js
const { log } = require("node:util");

log("Application started");
log("Processing request");

After:

js
console.log(new Date().toLocaleString(), "Application started");
console.log(new Date().toLocaleString(), "Processing request");

Ready to evolve your codebase?

Build tailored, compiler-aware skills to assess, plan, and automate complex codebase changes.