view src/infolog.rs @ 433:9d8aae30be98

cmp: Make memtable key comparisons ~4x faster. Similar to the internal key comparison improvement: Only parse expensive FixedInts when required. This change brings rusty-leveldb within 10% of the original for write-heavy workloads and 25% for iterating workloads.
author Lewin Bormann <lbo@spheniscida.de>
date Sun, 22 Oct 2017 09:42:19 +0200
parents 7cd36dae08dd
children 9f01a2fbcda2
line wrap: on
line source


use std::io::{self, Write};

pub struct Logger(pub Box<Write>);

pub fn stderr() -> Logger {
    Logger(Box::new(io::stderr()))
}

#[macro_export]
macro_rules! log {
    ($l:expr) => ($l.as_ref().map(|l| l.borrow_mut().0.write("\n".as_bytes()).is_ok()));
    ($l:expr, $fmt:expr) => (
        $l.as_ref().map(|l| l.borrow_mut().0.write(concat!($fmt, "\n").as_bytes()).is_ok()));
    ($l:expr, $fmt:expr, $($arg:tt)*) => (
        $l.as_ref().map(
            |l| l.borrow_mut().0.write_fmt(format_args!(concat!($fmt, "\n"), $($arg)*)).is_ok()));
}