DEP0059: util.log()


类型:寿命终止

【Type: End-of-Life】

util.log() API 已被移除,因为它是一个未维护的遗留 API,之前意外地暴露给了用户使用。相反,请根据你的具体需求考虑以下替代方案:

【The util.log() API has been removed because it's an unmaintained legacy API that was exposed to user land by accident. Instead, consider the following alternatives based on your specific needs:】

  • 第三方日志库
  • 使用 console.log(new Date().toLocaleString(), message)

通过采用这些替代方案之一,你可以逐步放弃 util.log(),并选择与你的应用的具体需求和复杂性相适应的日志记录策略。

【By adopting one of these alternatives, you can transition away from util.log() and choose a logging strategy that aligns with the specific requirements and complexity of your application.】

提供了自动迁移(来源):

【An automated migration is available (source):】

npx codemod@latest @nodejs/util-log-to-console-log