7 releases

0.1.2 Aug 19, 2025
0.1.1 Mar 12, 2025
0.1.0 Feb 10, 2025
0.0.4 Oct 22, 2024
0.0.1 Mar 19, 2024

#336 in Debugging

Download history 109/week @ 2025-09-18 135/week @ 2025-09-25 139/week @ 2025-10-02 87/week @ 2025-10-09 142/week @ 2025-10-16 86/week @ 2025-10-23 63/week @ 2025-10-30 56/week @ 2025-11-06 49/week @ 2025-11-13 42/week @ 2025-11-20 52/week @ 2025-11-27 127/week @ 2025-12-04 64/week @ 2025-12-11 74/week @ 2025-12-18 198/week @ 2025-12-25 71/week @ 2026-01-01

419 downloads per month
Used in 3 crates

MIT/Apache

32KB
631 lines

ohos-hilog-binding

Install

cargo add ohos-hilog-binding

Usage

use hilog_binding::hilog_debug;
use napi_derive_ohos::napi;

#[napi]
pub fn add(left: u32, right: u32) -> u32 {
    hilog_debug!("hello world");
    hilog_debug!(
        "test",
        LogOptions {
          tag: Some("testTag"),
          domain: None
      }
    );
    left + right
}

Feature

redirect

Allow us redirect stdout/stderr to hilog.

# Cargo.toml

[dependencies]
ohos-hilog-binding = {version = "*", features = ["redirect"]}
use napi_derive_ohos::napi;

#[napi]
pub fn add(left: u32, right: u32) -> u32 {
  // setup at first
  let _handle = ohos_hilog_binding::forward_stdio_to_hilog();
  // can be redirected to hilog with info level
  println!("hello");

  left + right
}


log

Allow us use log as log library.

For log trace level, we will convert to debug level which is not supported in OHOS.

# Cargo.toml

[dependencies]
ohos-hilog-binding = {version = "*", features = ["log"]}
log                = { version = "*" }
use napi_derive_ohos::napi;

use log::{debug, error, LevelFilter};
use ohos_hilog_binding::log::Config;

#[napi]
pub fn info() {
    ohos_hilog_binding::log::init_once(Config::default().with_max_level(LevelFilter::Info));

    debug!("this is a debug {}", "message");
    error!("this is printed by default");
}

Dependencies

~3–630KB
~11K SLoC