@bifold/remote-logs

中文文档
3.1.4发布于 2026/11/05Apache-2.0TypeScriptCommonJS构建来源已验证近 30 天下载 2016

Remote logging for credo-ts agents

原始使用文档
文档目录6 节
  1. Usage
  2. Considerations
  3. Configuration
  4. Example Usage
  5. Including the Package
  6. Development

TL;DR

The @hyperledger/aries-remote-logs package provides a simple way to send credo-ts (Credo) logs to a remote Loki server.

Usage

This package allows a copy of the Credo logs to be sent to a remote Loki server. This is useful for debugging issues in environments where the logs are not easily accessible, yet the logs are needed to provide Tier 3 support.

Due to the sensitive nature of Verifiable Credentials and Digital Identity in general, the logs are not sent automatically. Instead, this feature must be enabled. It is highly recommended that this feature be disabled by default in production environments and only enabled, by the end user, when needed, and even then automatically disabled after a short period of time.

Considerations

When remote logging is enabled the RemoteLogger will generate a session ID automatically. This ID is then set as a label on all logs sent to the remote server. This allows the logs to be filtered by session ID. This is useful when debugging issues that are specific to a single user.

When the end user enables remote logging present them with the a session ID. This ID should be recorded and provided to the support team. The support team can then use this ID to identify the correct logs. This session ID is also helpful to minimize corelation of the logs with the end user.

Remote Warning Screenshot

Fetch the session ID with the following code:

// ...
const { agent } = useAgent()
const logger = agent?.config.logger as RemoteLogger

console.log(`Session ID: ${logger.sessionId}`)

Configuration

The RemoteLogger is configured with a set of options. These options are passed to the constructor of the RemoteLogger class. The options are as follows:

OptionTypeDescription
lokiUrlstringThe full URL of the Loki server.
lokiLabelsRecord<string, string>A set of labels to be applied to all logs sent to the Loki server.
autoDisableRemoteLoggingIntervalInMinutesnumberThe number of minutes to wait before automatically disabling remote logging.

The image below shows what a typical Grafana log query looks like. The query is filtered by the application and job labels. The sessionId label is used to filter the logs for a specific debug session.

Grafana Screenshot

Example Usage

Setup the RemoteLogger and pass it to the Credo Agent as shown below:

import { RemoteLogger, RemoteLoggerOptions } from '@hyperledger/aries-remote-logs'

// ...

const autoDisableRemoteLoggingIntervalInMinutes = 90 // important
const lokiUrl = 'https://logs.example.com:3100/loki/api/v1/push'
const logOptions: RemoteLoggerOptions = {
  lokiUrl,
  lokiLabels: {
    application: 'bifold-wallet',
    job: 'react-native-logs',
  },
  autoDisableRemoteLoggingIntervalInMinutes,
}

const logger = new RemoteLogger(logOptions)
logger.startEventListeners()

const credoConfigOpts = {
  config: {
    label: 'Bifold Wallet',
    walletConfig: {
      id: 'some-wallet-id',
      key: 'some-secret-key',
    },
    logger,
    mediatorPickupStrategy: MediatorPickupStrategy.Implicit,
    autoUpdateStorageOnStartup: true,
    autoAcceptConnections: true,
  },
  dependencies: agentDependencies,
  modules: getAgentModules({
    indyNetworks: ledgers,
    mediatorInvitationUrl: Config.MEDIATOR_URL,
  }),
}

const agent = new Agent(credoConfigOpts)

// ...

Enable and disable remote logging by sending events as shown below:

import { DeviceEventEmitter } from 'react-native'
import { RemoteLoggerEventTypes } from '@hyperledger/aries-remote-logs'

// ...

// enable remote logging, this will send the logs to the remote server
// and will automatically disable remote logging after the specified
// interval.
DeviceEventEmitter.emit(RemoteLoggerEventTypes.ENABLE_REMOTE_LOGGING, true)

// ...

Including the Package

Metro

Metro can't handle symlinks. Therefore, you need to specify the @hyperledger/aries-remote-logs location in the metro.config.js file of your application. Check out the example below, or view this complete example for more information.

// ...
fs.realpathSync(path.join(__dirname, 'node_modules', '@hyperledger/aries-remote-logs')),
// ...

Yarn

Yarn struggles to include react-native peer-dependencies from the local file system. To fix this, add any react-native dependencies from this package's peerDependencies in package.json to your own package.json. Use a command like yarn add react-native-logs@^5.0.1 to do this.

Development

This package ships with a docker-compose file that can be used to run a local Grafana Loki stack. To start the containers run the following command:

docker compose up -d

The Loki server will be available at http://localhost:3100. The Grafana server will be available at http://localhost:3000. The default username and password for Grafana is admin and the password is specified, can can be changed, in the docker-compose.yaml file:

environment:
  GF_SECURITY_ADMIN_PASSWORD: secret

Once the stack is running, and you have logged into Grafana, you may need to add a Loki data source from the main landing page. The only value you need set is the URL where Loki is running. The value, as per the docker stack is: http://loki:3100

版本与发布记录

@bifold/remote-logs 共发布 92 个版本,首次发布于 2025/04/15;过去 12 个月发布了 53 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
3.1.4latest2026/11/053 天前
3.1.32026/10/1029 天前
3.1.22026/10/031 个月前
3.1.12026/09/261 个月前
3.1.02026/09/241 个月前
3.0.222026/08/182 个月前

其他发布通道:legacy-v2 → 2.12.13。

关于 @bifold/remote-logs 的常见问题

@bifold/remote-logs 是什么?

Remote logging for credo-ts agents

如何安装 @bifold/remote-logs?

在项目目录运行 npm install @bifold/remote-logs,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:axios(~1.15.0)、react(19.2.3)、buffer(~6.0.3)、react-native(0.86.3)、@credo-ts/core(0.7.0)、react-native-logs(~5.1.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@bifold/remote-logs 支持 TypeScript 吗?

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

@bifold/remote-logs 支持 ESM 还是 CommonJS?

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

@bifold/remote-logs 可以商用吗?

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

@bifold/remote-logs 的下载量有多少?

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

@bifold/remote-logs 还在维护吗?

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