@azerion/bunosaurus-logger

中文文档
4.0.1发布于 2026/10/18MITTypeScriptCommonJS构建来源已验证近 30 天下载 2039

An encapsulated logger for semantically formatting console messages.

原始使用文档
文档目录3 节
  1. APIs
  2. A word on the error formatter
  3. Using the template literal tag

@docusaurus/logger

An encapsulated logger for semantically formatting console messages.

APIs

It exports a single object as default export: logger. logger has the following properties:

  • Some useful colors.
    • red
    • yellow
    • green
    • bold
    • dim
  • Formatters. These functions all have the signature (msg: unknown) => string. Note that their implementations are not guaranteed. You should only care about their semantics.
    • path: formats a file path.
    • url: formats a URL.
    • name: formats an identifier.
    • code: formats a code snippet.
    • subdue: subdues the text.
    • num: formats a number.
  • The interpolate function. It is a template literal tag. The syntax can be found below.
  • Logging functions. All logging functions can both be used as normal functions (similar to the console.log family, but only accepts one parameter) or template literal tags.
    • info: prints information.
    • warn: prints a warning that should be paid attention to.
    • error: prints an error (not necessarily halting the program) that signals significant problems.
    • success: prints a success message.
  • The report function. It takes a ReportingSeverity value (ignore, log, warn, throw) and reports a message according to the severity.

A word on the error formatter

Beware that an error message, even when it doesn't hang the program, is likely going to cause confusion. When users inspect logs and find an [ERROR], even when the build succeeds, they will assume something is going wrong. Use it sparingly.

Docusaurus only uses logger.error when printing messages immediately before throwing an error, or when user has set the reporting severity of onBrokenLink, etc. to "error".

In addition, warn and error will color the entire message for better attention. If you are printing large blocks of help text about an error, better use logger.info.

Using the template literal tag

The template literal tag evaluates the template and expressions embedded. interpolate returns a new string, while other logging functions prints it. Below is a typical usage:

import logger from '@docusaurus/logger';

logger.info`Hello name=${name}! You have number=${money} dollars. Here are the ${
  items.length > 1 ? 'items' : 'item'
} on the shelf: ${items}
To buy anything, enter code=${'buy x'} where code=${'x'} is the item's name; to quit, press code=${'Ctrl + C'}.`;

An embedded expression is optionally preceded by a flag in the form [a-z]+= (a few lowercase letters, followed by an equals sign, directly preceding the embedded expression). If the expression is not preceded by any flag, it's printed out as-is. Otherwise, it's formatted with one of the formatters:

  • path=: path
  • url=: url
  • name=: name
  • code=: code
  • subdue=: subdue
  • number=: num

If the expression is an array, it's formatted by `\n- ${array.join('\n- ')}\n` (note it automatically gets a leading line end). Each member is formatted by itself and the bullet is not formatted. So you would see the above message printed as:

Some text output in the terminal, containing array, code, name, and number formatting

版本与发布记录

@azerion/bunosaurus-logger 共发布 7 个版本,首次发布于 2026/10/11;过去 12 个月发布了 7 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
4.0.1latest2026/10/1821 天前
4.0.0-canary-6978canary2026/10/1821 天前
4.0.0-canary-69422026/10/1821 天前
4.0.0-canary-69292026/10/1127 天前
4.0.0-canary-69272026/10/1127 天前
4.0.02026/10/1127 天前

关于 @azerion/bunosaurus-logger 的常见问题

@azerion/bunosaurus-logger 是什么?

An encapsulated logger for semantically formatting console messages.

如何安装 @azerion/bunosaurus-logger?

在项目目录运行 npm install @azerion/bunosaurus-logger,或使用 pnpm add / yarn add / bun add。

@azerion/bunosaurus-logger 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@azerion/bunosaurus-logger 支持 ESM 还是 CommonJS?

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

@azerion/bunosaurus-logger 可以商用吗?

@azerion/bunosaurus-logger 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@azerion/bunosaurus-logger 的下载量有多少?

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

@azerion/bunosaurus-logger 还在维护吗?

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