#ifndef _LOGGER_H_ #define _LOGGER_H_ #include #include #include #include class logger { private: std::atomic _isLogging; std::stringstream _logLine; public: logger(); void log(const char* s); template void log(const char* s, const T& value, const Args&... args) { if(!_isLogging) { _isLogging.store(true); _logLine.str(""); } while (*s) { if (*s == '%' && *++s != '%') { _logLine << value; return log(s, args...); } _logLine << *s++; } throw std::runtime_error("extra arguments provided"); } }; extern logger ulog; #endif // _LOGGER_H_