@applicaster/x-ray

中文文档
0.9.10发布于 2026/10/30零依赖近 30 天下载 3929

Applicaster X-Ray Logger

原始使用文档
文档目录11 节
  1. Overview
  2. Motivation
  3. Features:
  4. Android Setup
  5. Linking with the Library
  6. Android Initialization and Basic Usage
  7. Advanced Filtering Configuration
  8. npm Publishing
  9. Stable release (commit-based)
  10. Canary release (PR branches)
  11. Issues:

General Purpose Logger

Logo

Overview

Library provides general purpose logging and reporting facilities for Android, iOS, and React Native.

Motivation

While there are a lot of different logging systems for Android and iOS available, they all are mostly developer-oriented, and perform only single task: logging. Some of them are too simplistic (timber), while other are too complex (logs4j), and none provide user/QA facing features: easy external configuration, UI.

X-Ray library is designed with the following goals:

  • Provide a drop-in solution for Android, iOS, and React Native logging.
  • Modularity, so many of the components can be used as a standalone, or combined with other logging solutions.
  • Provide easy to use syntax and infrastructure for developers to report the information.
  • Provide ready to use UI components for logging configuration, display, and reporting.
  • Provide additional features related to application diagnostics and insights: crash reporting, log sharing.
  • Ease of extensibility and customization.
  • Inherit best practices from other logging systems, including Python, C# Serilog, etc.

Features:

  • Custom sinks, as in Serilog: ADB, file, etc.
  • Flexible filtering
  • Extensions: crash reporting, notification controls
  • Deep object dump support with moshi

Android Setup

In minimal configuration, only core is required. It contains all required logging interfaces, filtering rules, and basic sinks.

Linking with the Library

Project can be connected in a number of ways:

  1. Using maven artifacts:

Maven artifacts is a recommended way for native Android applications.

Add the following repository to your project top level gradle

maven { url 'https://dl.bintray.com/applicaster-ltd/maven_plugins' }

Link the core: implementation('com.applicaster:xray-core:0.0.4-alpha')

Optionally link extensions needed: implementation('com.applicaster:xray-crashreporter:0.0.4-alpha')

  1. From npm repository

NPM package includes the project in source code form. Convenient for react-native projects.

  1. As a git submodule

Useful for developers working on new extensions or expanding the library itself.

Android Initialization and Basic Usage

Initialize and attach the sinks.

        val fileLogSink = PackageFileLogSink(this, "default.log");

        Core.get()
            .addSink("adb", ADBSink())
            .addSink("file", fileLogSink)

Optionally, configure crash reporter extension

        Reporting.init("[email protected]", fileLogSink.file)
        Reporting.enableForCurrentThread(this, true)

Start logging:

        val rootLogger = Logger.get()
        rootLogger
            .d("Test")
            .message("Basic message")

Log from some particular component of some subsystem:

        val logger = Logger.get("subsystem/component")
        logger
            .d("Test")
            .message("Basic message")

Advanced Filtering Configuration

Output from any logger to any sink can be filtered. Default filter implementation allows to filter by log level.

Here, we only allow error messages to pass to the second file sink error_log_sink:

        Core.get()
            .addSink("default_log_sink", fileLogSink)
            .addSink("error_log_sink", errorFileLogSink)
            .setFilter("error_log_sink", "", DefaultSinkFilter(LogLevel.error))

This can be used when verbose logging level log file is been recreated for every application launch, or enabled on demand to avoid it taking too much space, while error log file is been preserved or rotated.

Filtering can be overridden for specific subsystems and its descendants. Here, we allow all messages from childLogger and its descendants to pass to the second file sink:

        Core.get()
            .setFilter("error_log_sink", "childLogger", DefaultSinkFilter(LogLevel.debug))

Please refer to the ./docs/adr/003-sink-filters.md for more details on the filtering approach.

Android Building and Deployment

Project can be published to both npm and maven. Maven publishing is done with CI, but can be performed manually. Please refer to .circleci/config.yml for publishing steps.

npm Publishing

Stable release (commit-based)

  1. Merge changes to master.
  2. deploy_npm runs node ./scripts/publish_npm.js and computes the release bump from commit messages since the previous publish.
  3. The script updates package.json version, publishes to npm (latest), then creates and pushes:
    • commit: chore: publish @applicaster/x-ray@<version>
    • tag: <version>

Canary release (PR branches)

For testing changes before merge:

  1. Open a pull request (any branch except master).
  2. Wait for the build job to complete.
  3. Manually approve hold_create_canary in CircleCI.
  4. deploy_npm_canary runs node ./scripts/publish_npm.js --canary — same rules as Zapp-Frameworks scripts/publish_plugins.js --canary:
    • BREAKING CHANGE in commits since the last publish → major
    • feat in commits (e.g. feat: …) → minor
    • any other commit (chore, fix, etc.) → patch
    • Version base is the latest git tag (or package.json if higher).
    • Canary version: if npm next compares equal to the bumped version → increment alpha on next (e.g. 0.7.2-alpha.0 → 0.7.2-alpha.1); otherwise ${bumpedVersion}-alpha.0.
    • Publishes to the next dist-tag (npm view versions avoids duplicate versions; 409 retries while the registry is processing).

Local canary publish (NPM_TOKEN required):

yarn install
yarn publish:canary

Artifact version for maven publishing must match releaseVersion constant in android/gradle/constants.gradle.

Note that xray component dependencies for extensions are imported using special helper functions xrayAPI, for example:

xrayAPI(dependencies, ':xray-core')

This helper dynamically resolves dependency to either project or maven artifact, and also stores dependency information in the project. Stored dependency information later used by maven publishing script to build POM file. This approach allows to avoid dependency resolution failures due to the fact that, during publishing, extensions are dependent on the artifacts that are only about to be published.

To Do:

  • Dynamic Context Providers in loggers (thread, etc)
  • Mapper configuration
  • Use Dummy EventBuilder if log event will not be recorded to save performance
  • Event formatters with time, tag, etc placeholders
  • Named placeholders in templates (WIP)
  • In-memory circular buffer event sink
  • Maybe output file sinks to cache and not data storage, so user can wipe it without losing data
  • Trim/rotate file sinks
  • HTTP server sink

Issues:

  • Using Android-specific nullable annotations
  • Uses Kotlin internally

版本与发布记录

@applicaster/x-ray 共发布 119 个版本,首次发布于 2020/08/21;过去 12 个月发布了 30 个版本。

版本发布日期距今
0.9.10latest2026/10/308 天前
0.9.92026/10/308 天前
0.9.82026/09/261 个月前
0.9.72026/07/283 个月前
0.9.62026/07/283 个月前
0.9.52026/07/283 个月前

其他发布通道:next → 0.8.0-alpha.5。

关于 @applicaster/x-ray 的常见问题

@applicaster/x-ray 是什么?

Applicaster X-Ray Logger

如何安装 @applicaster/x-ray?

在项目目录运行 npm install @applicaster/x-ray,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(*)、react-native(*)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@applicaster/x-ray 支持 TypeScript 吗?

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

@applicaster/x-ray 可以商用吗?

@applicaster/x-ray 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@applicaster/x-ray 的下载量有多少?

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

@applicaster/x-ray 还在维护吗?

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