# @docusaurus/logger

> An encapsulated logger for semantically formatting console messages.

Latest version **3.10.2** (published 2026-07-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install @docusaurus/logger
pnpm add @docusaurus/logger
yarn add @docusaurus/logger
bun add @docusaurus/logger
```

## Health

**Score 75/100 (B)** — status: active.

Positive: has types; no vulnerabilities; has provenance; recently updated; high maintenance score; popular repo; extremely popular.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 3.10.2 |
| Published | 2026-07-10 |
| First published | 2021-12-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=20.0 |
| Dependencies | 2 |
| Unpacked size | 137.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 66259 |
| Maintainers | fb, slorber, lex111, docusaurus-bot |

## Links

- npm: https://www.npmjs.com/package/@docusaurus/logger
- Repository: https://github.com/facebook/docusaurus
- Homepage: https://github.com/facebook/docusaurus#readme
- Issues: https://github.com/facebook/docusaurus/issues
- npm.io page: https://npm.io/package/@docusaurus/logger

## Dependencies (2)

- [chalk](https://npm.io/package/chalk.md) ^4.1.2
- [tslib](https://npm.io/package/tslib.md) ^2.6.0

## Recent versions

- 3.10.2 (latest) — 2026-07-10
- 4.0.0-canary-6821 (canary) — 2026-09-18
- 3.9.2-alpha.4 (alpha) — 2026-03-20
- 3.0.0-rc.1 (next) — 2023-10-26
- 4.0.0-canary-6820 — 2026-09-18
- 4.0.0-canary-6818 — 2026-09-18
- 4.0.0-canary-6817 — 2026-09-18
- 4.0.0-canary-6816 — 2026-09-18
- 4.0.0-canary-6815 — 2026-09-18
- 4.0.0-canary-6814 — 2026-09-17
- 4.0.0-canary-6813 — 2026-09-17
- 4.0.0-canary-6811 — 2026-09-17
- 4.0.0-canary-6810 — 2026-09-17
- 4.0.0-canary-6809 — 2026-09-17
- 4.0.0-canary-6808 — 2026-09-14
- … 1387 more at https://npm.io/package/@docusaurus/logger/versions

## README

# `@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:

```js
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](./demo.png)

---
_Source: https://npm.io/package/@docusaurus/logger · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
