@cumulus/logger

中文文档
22.5.0发布于 2026/11/06Apache-2.0TypeScriptCommonJS近 30 天下载 5366

A log library for use on Cumulus

原始使用文档
文档目录13 节
  1. Install
  2. Usage
  3. API
  4. new Logger({ [asyncOperationId], [executions], [granules], …
  5. log.debug([...messageArgs])
  6. log.error([...messageArgs][, error])
  7. log.fatal([...messageArgs])
  8. log.info([...messageArgs])
  9. log.infoWithAdditionalKeys(additionalKeys, ...messageArgs)
  10. log.trace([...messageArgs])
  11. log.warn([...messageArgs])
  12. About Cumulus
  13. Contributing

@cumulus/logger

A logging library for use on the Cumulus project.

The @cumulus/logger library exports a Logger class, which generates JSON-formated log events.

Log events always have the following keys:

  • level (string) - the priority level of the message
  • message (string) - the message itself
  • sender (string) - the resource that created the message
  • timestamp (string) - an ISO-8601 timestamp

Log events may have the following options keys:

  • executions (string)
  • granules (string [stringified array of objects])
  • parentArn (string)
  • stackName (string)
  • version (string)
  • asyncOperationId (string)

Log events may also contain user-specified keys.

Example log event:

{
  "level": "info",
  "message": "hello world",
  "sender": "greetingFunction",
  "timestamp": "2018-10-19T19:12:47.501Z"
}

Install

npm install @cumulus/logger

Usage

const Logger = require('@cumulus/logger');

const log = new Logger({ sender: 'example' });

log.info('hello, world');

API

new Logger({ [asyncOperationId], [executions], [granules], [parentArn], [sender], [stackName], [version] })

asyncOperationId

Type: string

An optional async operation id associated with a workflow.

executions

Type: string

An optional description of the executions.

granules

type: string

An optional granules string. Generally a stringified array of granule objects.

parentArn

type: string

An optional stepfunction ARN of the parent workflow that triggered the current execution.

sender

Type: string

The sender of the log event. Typically a Lambda Function Name or ECS Task Name. Defaults to "unknown".

stackName

type: string

Cumulus stack name.

version

Type: string

An optional version.

log.debug([...messageArgs])

Writes a log event to stdout with level set to "debug".

args

Type: ...any

See console.log().

log.error([...messageArgs][, error])

Writes a log event to stderr with level set to "error".

args

Type: ...any

See console.log().

error

Type: Error

If the last argument is an Error then the following additional properties will be set on the log event:

  • error (Object)
    • name (string)
    • message (string)
    • stack (Array<string>) - the lines of the stack trace

log.fatal([...messageArgs])

Writes a log event to stdout with level set to "fatal".

args

Type: ...any

See console.log().

log.info([...messageArgs])

Writes a log event to stdout with level set to "info".

args

Type: ...any

See console.log().

log.infoWithAdditionalKeys(additionalKeys, ...messageArgs)

Writes a log event to stdout with level set to "info". In addition to the standard keys, additional keys will be added to the event. If an additional key is specified with the same name as a standard key, the value standard key will be displayed.

additionalKeys

Type: Object

Additional key/value pairs to be added to the event.

args

Type: ...any

See console.log().

log.trace([...messageArgs])

Writes a log event to stdout with level set to "trace".

args

Type: ...any

See console.log().

log.warn([...messageArgs])

Writes a log event to stdout with level set to "debug".

args

Type: ...any

See console.log().

About Cumulus

Cumulus is a cloud-based data ingest, archive, distribution and management prototype for NASA's future Earth science data streams.

Cumulus Documentation

Contributing

To make a contribution, please see our contributing guidelines.

版本与发布记录

@cumulus/logger 共发布 208 个版本,首次发布于 2018/10/31;过去 12 个月发布了 36 个版本。

版本发布日期距今
22.5.0latest2026/11/065 天前
22.4.42026/11/065 天前
22.4.32026/10/031 个月前
22.4.22026/09/251 个月前
22.4.12026/09/151 个月前
22.4.02026/09/022 个月前

其他发布通道:release-v1.13.6 → 1.13.6,release-v2.0.8 → 2.0.8,release-v6.0.1 → 6.0.1,release-v8.1.1 → 8.1.1,release-v9.2.1 → 9.2.1,release-v8.1.2 → 8.1.2。

关于 @cumulus/logger 的常见问题

@cumulus/logger 是什么?

A log library for use on Cumulus

如何安装 @cumulus/logger?

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

@cumulus/logger 支持 TypeScript 吗?

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

@cumulus/logger 支持 ESM 还是 CommonJS?

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

@cumulus/logger 需要什么版本的 Node.js?

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

@cumulus/logger 可以商用吗?

@cumulus/logger 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@cumulus/logger 的下载量有多少?

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

@cumulus/logger 还在维护吗?

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