Go to the documentation of this file.
13 #ifndef TLX_LOGGER_CORE_HEADER
14 #define TLX_LOGGER_CORE_HEADER
24 template <
typename AnyType,
typename Enable =
void>
25 class LoggerFormatter;
82 std::ostringstream
oss_;
89 template <
typename AnyType>
110 std::ostringstream
oss_;
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)
162 class LoggerPrefixHook
224 std::ostringstream
oss_;
230 template <
typename AnyType>
234 static void print(std::ostream& os,
const AnyType& t) {
239 template <
typename A,
typename B>
240 class LoggerFormatter<std::pair<A, B> >
243 static void print(std::ostream& os,
const std::pair<A, B>& p) {
252 template <
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 <<
',';
270 #endif // !TLX_LOGGER_CORE_HEADER
LoggerOutputHook * set_logger_output_hook(LoggerOutputHook *hook)
set new LoggerOutputHook instance to receive global log lines.
LoggerCollectOutput(bool echo=false)
virtual ~LoggerPrefixHook()
virtual destructor
Logger & operator<<(const AnyType &at)
output any type, including io manipulators
std::ostringstream oss_
collector stream
A logging class which outputs spaces between elements pushed via operator<<.
void clear()
clear transcript
bool echo_
whether to echo each line to next logger output
Logger()
construction: add prefix if desired
bool first_
true until the first element it outputted.
void append_log_line(const std::string &line) final
method the receive log lines
LOG and sLOG for development and debugging.
~Logger()
destructor: output a newline
std::ostringstream oss_
string stream collecting
SpacingLogger & operator<<(const AnyType &at)
output any type, including io manipulators
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.
virtual void append_log_line(const std::string &line)=0
method the receive log lines
SpacingLogger()
construction: add prefix if desired
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.
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
Class to hook logger output in the local thread.
virtual ~LoggerOutputHook()
virtual destructor