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