#ifndef LOG_H__ #define LOG_H__ #include #include #include "Queue.h" struct LogMsg { std::stringstream s; std::ostream& output; LogMsg (std::ostream& o = std::cout): output (o) {}; void Process () { output << s.str (); } }; extern i2p::util::MsgQueue g_Log; template void LogPrint (std::stringstream& s, TValue arg) { s << arg; } template void LogPrint (std::stringstream& s, TValue arg, TArgs... args) { LogPrint (s, arg); LogPrint (s, args...); } template void LogPrint (TArgs... args) { LogMsg * msg = new LogMsg (); LogPrint (msg->s, args...); msg->s << std::endl; g_Log.Put (msg); } #endif