aboutsummaryrefslogtreecommitdiff
path: root/src/rust/tor_log
diff options
context:
space:
mode:
authorChelsea Holland Komlo <me@chelseakomlo.com>2017-12-15 21:23:10 -0500
committerChelsea Holland Komlo <me@chelseakomlo.com>2017-12-21 15:29:33 -0500
commit0e032fe9ea494ab03e5db5ca901ddbddd147eb19 (patch)
tree259b9518acdb4752766071dfd6f807c98de8aa90 /src/rust/tor_log
parentcd8bcacfe1053d067127507b4ebd8bd7b33309e9 (diff)
downloadtor-0e032fe9ea494ab03e5db5ca901ddbddd147eb19.tar.gz
tor-0e032fe9ea494ab03e5db5ca901ddbddd147eb19.zip
fixups from code review
Diffstat (limited to 'src/rust/tor_log')
-rw-r--r--src/rust/tor_log/tor_log.rs19
1 files changed, 6 insertions, 13 deletions
diff --git a/src/rust/tor_log/tor_log.rs b/src/rust/tor_log/tor_log.rs
index 394e232442..badbf3a29d 100644
--- a/src/rust/tor_log/tor_log.rs
+++ b/src/rust/tor_log/tor_log.rs
@@ -43,11 +43,11 @@ macro_rules! tor_log_msg {
/// Default function name to log in case of errors when converting
/// a function name to a CString
- const ERR_LOG_FUNCTION: &'static str = "tor_log_msg";
+ const ERR_LOG_FUNCTION: &str = "tor_log_msg";
/// Default message to log in case of errors when converting a log
/// message to a CString
- const ERR_LOG_MSG: &'static str = "Unable to log message from Rust
+ const ERR_LOG_MSG: &str = "Unable to log message from Rust
module due to error when converting to CString";
let func = match CString::new($function) {
@@ -63,11 +63,11 @@ macro_rules! tor_log_msg {
let func_ptr = func.as_ptr();
let msg_ptr = msg.as_ptr();
+ let c_severity = unsafe { translate_severity($severity) };
+ let c_domain = unsafe { translate_domain($domain) };
+
unsafe {
- tor_log_string(translate_severity($severity),
- translate_domain($domain),
- func_ptr, msg_ptr
- )
+ $crate::tor_log_string(c_severity, c_domain, func_ptr, msg_ptr )
}
}
};
@@ -134,27 +134,20 @@ pub mod log {
/// Translate Rust defintions of log domain levels to C. This exposes a 1:1
/// mapping between types.
- ///
- /// Allow for default cases in case Rust and C log types get out of sync
- #[allow(unreachable_patterns)]
pub unsafe fn translate_domain(domain: LogDomain) -> u32 {
match domain {
LogDomain::LdNet => _LD_NET,
LogDomain::LdGeneral => _LD_GENERAL,
- _ => _LD_GENERAL,
}
}
/// Translate Rust defintions of log severity levels to C. This exposes a
/// 1:1 mapping between types.
- ///
- /// Allow for default cases in case Rust and C log types get out of sync
#[allow(unreachable_patterns)]
pub unsafe fn translate_severity(severity: LogSeverity) -> c_int {
match severity {
LogSeverity::Warn => _LOG_WARN,
LogSeverity::Notice => _LOG_NOTICE,
- _ => _LOG_NOTICE,
}
}