void log( LogLevel level, std::ostream& stream, std::mutex& mutex, const char* file, unsigned line, const char* function, const crossbow::string& str, Args&&... args) { if (config.level > level) return; boost::format formatter(str.c_str()); LogFormatter<Args...> fmt; fmt.format(formatter, std::forward<Args>(args)...); std::lock_guard<std::mutex> _(mutex); stream << formatter.str(); stream << " (in " << function << " at " << file << ':' << line << ')' << std::endl; }
void FileLogAppender::write(LogFormatter &format, const LogEntry &entry) { std::ostringstream ostr; format.format(ostr, entry); ostr << "\r\n"; auto str = ostr.str(); truncate(str.length()); logging_.write(str.c_str(), str.length()); logging_.flush(); }
void DebugOutputLogSink::write(LogFormatter &format, LogEntry const &record) { std::ostringstream ostr; format.format(ostr, record); ::OutputDebugStringA(ostr.str().c_str()); }
void format(boost::format& f, Head h, Tail&&... tail) const { f % h; base.format(f, std::forward<Tail>(tail)...); }