diff options
author | Chelsea Holland Komlo <me@chelseakomlo.com> | 2017-11-27 22:59:54 -0500 |
---|---|---|
committer | Chelsea Holland Komlo <me@chelseakomlo.com> | 2017-12-21 15:29:33 -0500 |
commit | 3dfe8e6522460817100582a33a382be3c3efd988 (patch) | |
tree | bfb60d07ac6e4d66fded35794980dd268bc7f2eb /src/rust/tor_util | |
parent | 719db28f54ad1fa957999f2a6256e07bdb412e4f (diff) | |
download | tor-3dfe8e6522460817100582a33a382be3c3efd988.tar.gz tor-3dfe8e6522460817100582a33a382be3c3efd988.zip |
add minimal rust module for logging to tor's logger
Allows an optional no-op for testing purposes
Diffstat (limited to 'src/rust/tor_util')
-rw-r--r-- | src/rust/tor_util/Cargo.toml | 3 | ||||
-rw-r--r-- | src/rust/tor_util/ffi.rs | 13 | ||||
-rw-r--r-- | src/rust/tor_util/lib.rs | 1 |
3 files changed, 11 insertions, 6 deletions
diff --git a/src/rust/tor_util/Cargo.toml b/src/rust/tor_util/Cargo.toml index d7379a5988..adc3390b53 100644 --- a/src/rust/tor_util/Cargo.toml +++ b/src/rust/tor_util/Cargo.toml @@ -11,6 +11,9 @@ crate_type = ["rlib", "staticlib"] [dependencies.tor_allocate] path = "../tor_allocate" +[dependencies.tor_log] +path = "../tor_log" + [dependencies] libc = "0.2.22" diff --git a/src/rust/tor_util/ffi.rs b/src/rust/tor_util/ffi.rs index 5c3cdba4be..866d119740 100644 --- a/src/rust/tor_util/ffi.rs +++ b/src/rust/tor_util/ffi.rs @@ -5,8 +5,7 @@ //! called from C. //! -use libc::c_char; -use tor_allocate::allocate_and_copy_string; +use tor_log::*; /// Returns a short string to announce Rust support during startup. /// @@ -17,10 +16,12 @@ use tor_allocate::allocate_and_copy_string; /// tor_free(rust_str); /// ``` #[no_mangle] -pub extern "C" fn rust_welcome_string() -> *mut c_char { - let rust_welcome = String::from( +pub extern "C" fn rust_welcome_string() { + tor_log_msg!( + LogSeverity::Notice, + LogDomain::LdGeneral, + "rust_welcome_string", "Tor is running with Rust integration. Please report \ - any bugs you encounter.", + any bugs you encounter." ); - allocate_and_copy_string(&rust_welcome) } diff --git a/src/rust/tor_util/lib.rs b/src/rust/tor_util/lib.rs index 42fa9d5ad0..86785c344a 100644 --- a/src/rust/tor_util/lib.rs +++ b/src/rust/tor_util/lib.rs @@ -7,5 +7,6 @@ extern crate libc; extern crate tor_allocate; +extern crate tor_log; pub mod ffi; |