Go to the documentation of this file.
25 class DefaultLoggerOutputCOut :
public LoggerOutputHook
34 std::unique_lock<std::mutex> lock(
mutex_);
35 (std::cout << line).flush();
40 class DefaultLoggerOutputCErr :
public LoggerOutputHook
49 std::unique_lock<std::mutex> lock(
mutex_);
50 (std::cerr << line).flush();
94 (*s_logger_output_hook).append_log_line(
oss_.str());
105 (*s_logger_output_hook).append_log_line(
oss_.str());
129 oss_.str(std::string());
LoggerOutputHook * set_logger_output_hook(LoggerOutputHook *hook)
set new LoggerOutputHook instance to receive global log lines.
LoggerCollectOutput(bool echo=false)
static DefaultLoggerOutputCOut s_default_logger_cout
default logger singletons
std::mutex mutex_
the global mutex of logger and spacing logger
virtual ~LoggerPrefixHook()
virtual destructor
std::ostringstream oss_
collector stream
void append_log_line(const std::string &line) final
method the receive log lines
static std::atomic< LoggerPrefixHook * > s_logger_prefix_hook
global logger prefix hook
default output logger to cerr
void clear()
clear transcript
bool echo_
whether to echo each line to next logger output
Logger()
construction: add prefix if desired
void append_log_line(const std::string &line) final
method the receive log lines
void append_log_line(const std::string &line) final
method the receive log lines
~Logger()
destructor: output a newline
default output logger to cout
std::ostringstream oss_
string stream collecting
std::ostringstream oss_
collector stream
std::string get()
return transcript of log
LoggerPrefixHook * set_logger_prefix_hook(LoggerPrefixHook *hook)
Set new LoggerPrefixHook instance to prefix global log lines.
static std::atomic< LoggerOutputHook * > s_logger_output_hook
global logger output hook
virtual void append_log_line(const std::string &line)=0
method the receive log lines
SpacingLogger()
construction: add prefix if desired
std::mutex mutex_
the global mutex of logger and spacing logger
LoggerOutputHook * set_logger_to_stderr()
install default logger to cerr / stderr instead of stdout.
~SpacingLogger()
destructor: output a newline
Abstract class to implement prefix output hooks for logging.
static DefaultLoggerOutputCErr s_default_logger_cerr
default logger singletons
LoggerOutputHook * next_
previous logger, will be restored by destructor
Abstract class to implement output hooks for logging.
virtual void add_log_prefix(std::ostream &os)=0
method to add prefix to log lines
virtual ~LoggerOutputHook()
virtual destructor