13#ifndef TLX_LOGGER_CORE_HEADER
14#define TLX_LOGGER_CORE_HEADER
24template <
typename AnyType,
typename Enable =
void>
89 template <
typename AnyType>
117 template <
typename AnyType>
137#define TLX_LOGC(cond) \
138 !(cond) ? (void)0 : ::tlx::LoggerVoidify() & ::tlx::Logger()
141#define TLX_LOG TLX_LOGC(debug)
144#define TLX_LOG0 TLX_LOGC(false)
145#define TLX_LOG1 TLX_LOGC(true)
148#define TLX_sLOGC(cond) \
149 !(cond) ? (void)0 : ::tlx::LoggerVoidify() & ::tlx::SpacingLogger()
152#define TLX_sLOG TLX_sLOGC(debug)
155#define TLX_sLOG0 TLX_sLOGC(false)
156#define TLX_sLOG1 TLX_sLOGC(true)
230template <
typename AnyType>
234 static void print(std::ostream& os,
const AnyType& t) {
239template <
typename A,
typename B>
243 static void print(std::ostream& os,
const std::pair<A, B>& p) {
252template <
typename T,
class A>
256 static void print(std::ostream& os,
const std::vector<T, A>& data) {
258 for (
typename std::vector<T>::const_iterator it = data.begin();
259 it != data.end(); ++it)
261 if (it != data.begin()) os <<
',';
Class to hook logger output in the local thread.
void append_log_line(const std::string &line) final
method the receive log lines
std::string get()
return transcript of log
LoggerOutputHook * next_
previous logger, will be restored by destructor
void clear()
clear transcript
std::ostringstream oss_
string stream collecting
bool echo_
whether to echo each line to next logger output
LoggerCollectOutput(bool echo=false)
Abstract class to implement output hooks for logging.
virtual void append_log_line(const std::string &line)=0
method the receive log lines
virtual ~LoggerOutputHook()
virtual destructor
Abstract class to implement prefix output hooks for logging.
virtual void add_log_prefix(std::ostream &os)=0
method to add prefix to log lines
virtual ~LoggerPrefixHook()
virtual destructor
LOG and sLOG for development and debugging.
~Logger()
destructor: output a newline
Logger()
construction: add prefix if desired
std::ostringstream oss_
collector stream
Logger & operator<<(const AnyType &at)
output any type, including io manipulators
A logging class which outputs spaces between elements pushed via operator<<.
SpacingLogger()
construction: add prefix if desired
SpacingLogger & operator<<(const AnyType &at)
output any type, including io manipulators
bool first_
true until the first element it outputted.
~SpacingLogger()
destructor: output a newline
std::ostringstream oss_
collector stream
LoggerOutputHook * set_logger_output_hook(LoggerOutputHook *hook)
set new LoggerOutputHook instance to receive global log lines.
LoggerPrefixHook * set_logger_prefix_hook(LoggerPrefixHook *hook)
Set new LoggerPrefixHook instance to prefix global log lines.
LoggerOutputHook * set_logger_to_stderr()
install default logger to cerr / stderr instead of stdout.