Skip to content

Instantly share code, notes, and snippets.

@ChrisMacNaughton
Created February 6, 2017 19:59
Show Gist options
  • Select an option

  • Save ChrisMacNaughton/017948a5c71bc0109b89a3cac2e31b0c to your computer and use it in GitHub Desktop.

Select an option

Save ChrisMacNaughton/017948a5c71bc0109b89a3cac2e31b0c to your computer and use it in GitHub Desktop.
#[macro_export]
macro_rules! log {
($message:expr) => {{
log!($message, Debug)
}};
($message:expr, $level:ident) => {{
charmhelpers::core::hookenv::log(
$message.to_string(),
Some(LogLevel::$level),
);
}}
}
#[cfg(test)]
mod tests {
#[allow(dead_code)]
mod log {
use charmhelpers;
use log::LogLevel;
fn it_logs_default() {
log!("This is a test");
}
fn it_logs_specific_level() {
log!("test 2", Warn);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment