ohos_runtimebinding

    HarmonyOS runtime capability bindings for MoonBit, built on MoonOHOS.

    Download zip
    Version
    0.2.0
    License
    Apache-2.0
    Last updated
    4 days ago
    Downloads
    63

    #HarmonyOS Runtime Binding

    Structured HiLog output for MoonBit native modules, using BitLogger 0.12.0 records and MoonOHOS 0.9.0. The module is available on Mooncakes and from this checkout.

    #Use

    Add ohos_runtimebinding to the consuming MoonBit workspace and depend on Nanaloveyuki/ohos_runtimebinding@0.2.0. Import these packages in moon.pkg:

    import {
    "Nanaloveyuki/BitLogger/src/core",
    "Nanaloveyuki/ohos_runtimebinding/log",
    }

    let sink = @log.HilogSink::new(0x5254, "MyApp")
    sink.write(@core.Record::new(
    @core.Level::Info,
    "资源索引 ready: 月亮 🌙",
    target="ResourceIndex",
    fields=[@core.field("resource_count", "1")],
    ))

    Construction raises MoonOHOS HilogError for an invalid domain or tag. Domains must be 0..0xFFFF; tags must contain 1–31 UTF-8 bytes without NUL. Writes implement BitLogger's non-raising Sink contract. HiLog delivery status is not available through the current MoonOHOS interface.

    Each message is a complete BitLogger JSON record. Trace uses HiLog Debug while preserving TRACE in JSON; the remaining levels map directly. Target, fields, and supplied timestamp remain in the record. HiLog output is public; callers must avoid logging sensitive data.

    #Requirements and applicability

    Use MoonBit 1.0.0-rc1+3c0520448 with a MoonOHOS native host. The example was verified on the API 26 x86_64 simulator with this toolchain. HarmonyOS example

    Use BitLogger's core, formatting, and sink_graph packages for the HarmonyOS build. The root src package also brings in file I/O C stubs that require a MoonOHOS native dependency descriptor.

    MoonOHOS owns HiLog access, Node-API bridging, native dependency discovery, and HAR packaging. This module adapts BitLogger records to its public logging interface.