Debian Codegraph @

intl/icu_capi/src/logging.rs

raw
1 // This file is part of ICU4X. For terms of use, please see the file
2 // called LICENSE at the top level of the ICU4X source tree
3 // (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
4
5 #[diplomat::bridge]
6 pub mod ffi {
7 use alloc::boxed::Box;
8
9 #[diplomat::opaque]
10 /// An object allowing control over the logging used
11 pub struct ICU4XLogger;
12
13 impl ICU4XLogger {
14 /// Initialize the logger using `simple_logger`
15 ///
16 /// Requires the `simple_logger` Cargo feature.
17 ///
18 /// Returns `false` if there was already a logger set.
19 #[cfg(all(not(target_arch = "wasm32"), feature = "simple_logger"))]
20 pub fn init_simple_logger() -> bool {
21 simple_logger::init().is_ok()
22 }
23
24 /// Deprecated: since ICU4X 1.4, this now happens automatically if the `log` feature is enabled.
25 #[cfg(target_arch = "wasm32")]
26 pub fn init_console_logger() -> bool {
27 false
28 }
29 }
30 }
31
32 // semver?
33 #[no_mangle]
34 #[cfg(target_arch = "wasm32")]
35 pub unsafe extern "C" fn icu4x_init() {}