@dot/log

中文文档
0.2.1发布于 2025/09/19MPL-2.0TypeScriptCommonJS近 30 天下载 80.4万

A beautiful and minimal logger for all applications

原始使用文档
文档目录5 节
  1. Requirements
  2. Install
  3. Usage
  4. Setting the Log Level
  5. Meta

@dot/log

A beautiful and minimal logger for all applications

Requirements

This package requires an Active LTS Node version (v18+).

Install

Using npm:

npm install @dot/log --save

Usage

Create a new logger and use it to log something wild:

import { log } from '@dot/log';

log.info('Jingle Bells, Batman Smells');
log.warn('Robin laid an egg');
log.error('The Batmobile lost a wheel');
log.debug('And the Joker got away');

And there will appear magic in your console

To name the log pass the name in the getLog options:

const log = getLog({ name: 'batman' });

When logging an object the nesting can be only one level deep. If the nesting level of the object exceeds one level then a RangeError exception will be thrown.

Setting the Log Level

By default, each log instance is set to the 'info' level. The log level can be set one of two ways:

  1. By direct manipulation of the log itself, which can be useful for one-off log instances:
import { log } from '@dot/log';

log.level = 'debug'; // change from the default 'info' level
  1. Using an the DOT_LOG_LEVEL environment variable:
DOT_LOG_LEVEL=debug

Meta

CONTRIBUTING

LICENSE (Mozilla Public License)

版本与发布记录

@dot/log 共发布 8 个版本,首次发布于 2023/01/25;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.2.1latest2025/09/191.1 年前
0.2.02025/03/261.6 年前
0.1.52024/05/292 年前
0.1.42024/05/152 年前
0.1.32023/05/313 年前
0.1.22023/02/263 年前

关于 @dot/log 的常见问题

@dot/log 是什么?

A beautiful and minimal logger for all applications

如何安装 @dot/log?

在项目目录运行 npm install @dot/log,或使用 pnpm add / yarn add / bun add。

@dot/log 支持 TypeScript 吗?

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

@dot/log 支持 ESM 还是 CommonJS?

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

@dot/log 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@dot/log 可以商用吗?

@dot/log 使用 MPL-2.0 许可。弱 Copyleft:可以商用,也可以和闭源代码一起使用;但如果分发时修改了 MPL 授权的文件,这些文件的修改需以 MPL 开源。以上为概括,不构成法律意见,请以许可原文为准。

@dot/log 的下载量有多少?

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

@dot/log 还在维护吗?

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