@architect/logs

中文文档
7.0.1发布于 2025/11/29Apache-2.0CommonJS近 30 天下载 1.1万

Manage logging from Architect-provisioned cloud functions

原始使用文档
文档目录4 节
  1. Installation
  2. logs({pathToCode, verbose, destroy, production}, callback)
  3. logs.read({name, pathToCode, ts}, callback)
  4. logs.destroy({name, pathToCode, ts}, callback)

@architect/logs GitHub CI status

@architect/logs is a module that retrieves and clears logs associated to your @architect functions across environments.

Installation

npm i @architect/logs
let logs = require('@architect/logs')

API

logs({pathToCode, verbose, destroy, production}, callback)

Takes a parameter object as first argument which accepts the following properties:

  • pathToCode: required the local path to architect Function code relative to the current working directory, i.e. src/http/get-index
  • verbose: verbose super chatty mode
  • destroy: if truthy will delete logs via logs.destroy, otherwise will read logs via logs.read
  • production: if truthy will target your arc project's production environment, otherwise will default to staging

By default will read logs from the staging environment. If the destroy property is truthy, logs instead will be destroyed.

logs.read({name, pathToCode, ts}, callback)

Will read logs from aws.CloudWatchLogs, invoking getLogEvents for log retrieval.

Takes a parameter object as first argument which accepts the following properties:

  • name: the CloudFormation StackName passed to listStackResources within which to search Function logs. Note that this is inferred from your application name, environment and specific function you are querying - tread carefully!
  • pathToCode: required the local path to architect Function code relative to the current working directory, i.e. src/http/get-index
  • ts: timestamp to use as a start time for displaying length of time details (i.e. Date.now())

callback will be invoked with an error if an error arises during execution. Otherwise, callback will be invoked without arguments.

logs.destroy({name, pathToCode, ts}, callback)

Will delete logs from aws.CloudWatchLogs, invoking deleteLogGroup.

Takes a parameter object as first argument which accepts the following properties:

  • name: the CloudFormation StackName passed to listStackResources within which to search Function logs. Note that this is inferred from your application name, environment and specific function you are querying - tread carefully!
  • pathToCode: required the local path to architect Function code relative to the current working directory, i.e. src/http/get-index
  • ts: timestamp to use as a start time for displaying length of time details (i.e. Date.now())

callback will be invoked with an error if an error arises during execution. Otherwise, callback will be invoked without arguments.

版本与发布记录

@architect/logs 共发布 69 个版本,首次发布于 2019/07/09;过去 12 个月发布了 3 个版本。

版本发布日期距今
7.0.1latest2025/11/2911 个月前
7.0.02025/11/2811 个月前
7.0.0-RC.0RC2025/11/2611 个月前
6.0.12025/09/261.1 年前
6.0.02025/09/251.1 年前
5.0.6-RC.02025/09/241.1 年前

关于 @architect/logs 的常见问题

@architect/logs 是什么?

Manage logging from Architect-provisioned cloud functions

如何安装 @architect/logs?

在项目目录运行 npm install @architect/logs,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 arc-logs,可以用 npx arc-logs 直接运行。

@architect/logs 支持 TypeScript 吗?

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

@architect/logs 支持 ESM 还是 CommonJS?

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

@architect/logs 需要什么版本的 Node.js?

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

@architect/logs 可以商用吗?

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

@architect/logs 的下载量有多少?

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

@architect/logs 还在维护吗?

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