Crates.io | ohos-hilog-binding |
lib.rs | ohos-hilog-binding |
version | 0.0.4 |
source | src |
created_at | 2024-03-19 09:54:41.13347 |
updated_at | 2024-10-22 03:04:27.825773 |
description | hilog binding for rust |
homepage | |
repository | |
max_upload_size | |
id | 1179079 |
size | 7,472 |
cargo add hilog_binding
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
}
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
}