diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /intl/icu_capi/src/logging.rs | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'intl/icu_capi/src/logging.rs')
-rw-r--r-- | intl/icu_capi/src/logging.rs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/intl/icu_capi/src/logging.rs b/intl/icu_capi/src/logging.rs new file mode 100644 index 0000000000..c84205bec5 --- /dev/null +++ b/intl/icu_capi/src/logging.rs @@ -0,0 +1,36 @@ +// This file is part of ICU4X. For terms of use, please see the file +// called LICENSE at the top level of the ICU4X source tree +// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). + +#[diplomat::bridge] +pub mod ffi { + use alloc::boxed::Box; + + #[diplomat::opaque] + /// An object allowing control over the logging used + #[diplomat::attr(dart, disable)] + pub struct ICU4XLogger; + + impl ICU4XLogger { + /// Initialize the logger using `simple_logger` + /// + /// Requires the `simple_logger` Cargo feature. + /// + /// Returns `false` if there was already a logger set. + #[cfg(all(not(target_arch = "wasm32"), feature = "simple_logger"))] + pub fn init_simple_logger() -> bool { + simple_logger::init().is_ok() + } + + /// Deprecated: since ICU4X 1.4, this now happens automatically if the `log` feature is enabled. + #[cfg(target_arch = "wasm32")] + pub fn init_console_logger() -> bool { + false + } + } +} + +// semver? +#[no_mangle] +#[cfg(target_arch = "wasm32")] +pub unsafe extern "C" fn icu4x_init() {} |