tracing_ohos/
lib.rs

1//! # tracing-ohos
2//!
3//! Composable tracing layer which logs to logcat using the [OpenHarmony NDK]'s
4//! `OH_LOG_Print` function. The provided tag will be capped at 23 bytes.
5//! Logging events resulting in messages longer than 4000 bytes will result in
6//! multiple log lines in logcat. This avoids running into logcat's truncation
7//! behaviour.
8//!
9//! This crate is mainly based on the [tracing-android] crate.
10//!
11//! License: MIT OR Apache-2.0
12//!
13//! [OpenHarmony NDK]: https://developer.huawei.com/consumer/en/doc/harmonyos-guides-V5/hilog-guidelines-ndk-V5#available-apis
14//! [tracing-android]: https://crates.io/crates/tracing-android
15//! # Example
16//! Constructs a [`layer::Layer`] with the given `tag`.
17//! ```no_run
18//!  use tracing_subscriber::layer::SubscriberExt;
19//!  use tracing_subscriber::util::SubscriberInitExt;
20//!
21//!  let ohrs_writer_layer = tracing_ohos::layer(0x0000, "homogrape")?;
22//!
23//!  tracing_subscriber::registry()
24//!     .with(ohrs_writer_layer)
25//!     .with(filter)
26//!     .init();
27//! ```
28
29
30pub mod ohos;
31pub mod layer;
32
33pub use layer::Layer;
34pub use ohos::OHOSWriter;
35
36/// Constructs a [`layer::Layer`] with the given `tag`.
37/// ```no_run
38///  use tracing_subscriber::layer::SubscriberExt;
39///  use tracing_subscriber::util::SubscriberInitExt;
40///
41///  let ohrs_writer_layer = tracing_ohos::layer(0x0000, "homogrape")?;
42///
43///  tracing_subscriber::registry()
44///     .with(ohrs_writer_layer)
45///     .with(filter)
46///     .init();
47/// ```
48pub fn layer(domain: u16, tag: &str) -> std::io::Result<layer::Layer> {
49    layer::Layer::new(domain, tag)
50}