Function safelog::flags::with_safe_logging_suppressed

source ·
pub fn with_safe_logging_suppressed<F, V>(func: F) -> V
where F: FnOnce() -> V,
Expand description

Run a given function with the regular safelog functionality suppressed.

The provided function, and everything it calls, will display Sensitive values as if they were not sensitive.

§Examples

use safelog::{Sensitive, with_safe_logging_suppressed};

let string = Sensitive::new("swordfish");

// Ordinarily, the string isn't displayed as normal
assert_eq!(format!("The value is {}", string),
           "The value is [scrubbed]");

// But you can override that:
assert_eq!(
    with_safe_logging_suppressed(|| format!("The value is {}", string)),
    "The value is swordfish"
);