@fomantic/better-console

中文文档
1.0.2发布于 2022/10/27BSDCommonJS近 30 天下载 2.2万

A better console for Node.js

原始使用文档
文档目录13 节
  1. Forked Version using updated dependencies
  2. Installation
  3. A better console for Node.js
  4. How to use it
  5. Methods
  6. console.log , console.warn , console.error , console.info ,…
  7. console.clear
  8. console.table
  9. console.time
  10. console.timeEnd
  11. console.trace
  12. console.count
  13. TODOs

Better Console

Forked Version using updated dependencies

Original repo at https://github.com/mohsen1/better-console

Screenshot

Installation

Use NPM

$ npm install better-console

A better console for Node.js

better-console is a drop-in replacement for node's default console which gives you colors and more methods in console.

How to use it

You can override console object itself or assign better console to another variable. It's completely safe to override the native console object because better console calls native console methods for methods that are already available in it.

var console = require('better-console');

console.log("This is a log information");
console.warn("Warning!");
console.info("Information");
console.table([ [1,2], [3,4] ]);
console.time("Timer");
console.timeEnd("Timer");
console.dir(myObject);

Methods

console.log, console.warn, console.error, console.info, console.debug, console.dir, console.trace

These methods work exactly same as native console methods but with colors for warn, info or error

console.clear

Clears the screen

console.table

Draws a table of data if a 2d array or object passed to it

console.time

Creates a new timer under the given name. Call console.timeEnd(name) with the same name to stop the timer and print the time elapsed.

console.timeEnd

Stops a timer created by a call to console.time(name) and write the time

console.trace

Prints a stack trace of JavaScript execution at the point where it is called. The stack trace details the functions on the stack, as well as the values that were passed as arguments to each function.

console.count

Writes number of times each argument is called with blue color

TODOs

  • Use Unicode icons to mimic browser console icons in OSX
  • Make console.trace more detailed with V8 flags

版本与发布记录

@fomantic/better-console 共发布 1 个版本,首次发布于 2022/10/27;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.0.2latest2022/10/274 年前

关于 @fomantic/better-console 的常见问题

@fomantic/better-console 是什么?

A better console for Node.js

如何安装 @fomantic/better-console?

在项目目录运行 npm install @fomantic/better-console,或使用 pnpm add / yarn add / bun add。

@fomantic/better-console 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/fomantic__better-console 是否存在。

@fomantic/better-console 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@fomantic/better-console 可以商用吗?

@fomantic/better-console 使用 BSD 许可。声明的许可为 BSD,请阅读许可原文确认使用条件。以上为概括,不构成法律意见,请以许可原文为准。

@fomantic/better-console 的下载量有多少?

根据 npm 官方下载统计,@fomantic/better-console 在 2026/10/15 – 2026/11/13 这 30 天内被下载 22,408 次,日均约 747 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@fomantic/better-console 还在维护吗?

最新版本 1.0.2 发布于 2022/10/27(4 年前);至今共发布 1 个版本,其中过去 12 个月发布了 0 个;首次发布于 2022/10/27。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。