#binding #ohos #hilog #tags #domain #redirect #hilog-binding

ohos-hilog-binding

hilog binding for rust

4 releases

new 0.0.4 Oct 22, 2024
0.0.3 Jun 4, 2024
0.0.2 Jun 4, 2024
0.0.1 Mar 19, 2024

#1 in #ohos

Download history 9/week @ 2024-07-01 2/week @ 2024-09-02 2/week @ 2024-09-16 34/week @ 2024-09-23 4/week @ 2024-09-30 24/week @ 2024-10-07 14/week @ 2024-10-14

77 downloads per month
Used in ohos-xcomponent-binding

MIT/Apache

8KB
157 lines

hilog_binding

Install

cargo add 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
}


Dependencies

~14KB