util: BlackholeLogger, a quiet Logger drop-in replacement
The compiler should be able to completely optimize away side-effect free usage of this logger. Can be used as a drop-in replacement for Loggers to silence logging output for known-good code without having to remove the corresponding "LOG << ..." code. Change-Id: Ifb276223f61686773dd6108aafd567e99c88b223
This commit is contained in:
25
src/core/util/BlackholeLogger.hpp
Normal file
25
src/core/util/BlackholeLogger.hpp
Normal file
@ -0,0 +1,25 @@
|
||||
#ifndef __BLACKHOLE_LOGGER_HPP__
|
||||
#define __BLACKHOLE_LOGGER_HPP__
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace fail {
|
||||
|
||||
/**
|
||||
* \class BlackholeLogger
|
||||
* A /dev/null sink as a drop-in replacement for Logger. Should be completely
|
||||
* optimized away on non-trivial optimization levels.
|
||||
*/
|
||||
class BlackholeLogger {
|
||||
public:
|
||||
Logger(const std::string& description = "Fail*", bool show_time = true,
|
||||
std::ostream& dest = std::cout) { }
|
||||
void setDescription(const std::string& descr) { }
|
||||
void showTime(bool choice) { }
|
||||
template<class T>
|
||||
inline std::ostream& operator <<(const T& v) { }
|
||||
};
|
||||
|
||||
} // end-of-namespace: fail
|
||||
|
||||
#endif // __BLACKHOLE_LOGGER_HPP__
|
||||
Reference in New Issue
Block a user