diff --git a/example/example.cpp b/example/example.cpp index 69e24b64..35b1524e 100644 --- a/example/example.cpp +++ b/example/example.cpp @@ -58,11 +58,11 @@ int main(int argc, char* argv[]) auto &logger2 = c11log::get_logger("logger2"); //logger2.add_sink(fsink2); logger2.add_sink(std::make_shared()); - logger2.add_sink(std::make_shared()); + logger2.add_sink(std::make_shared()); - info_logger info(&logger2); - info << "Hello info logger" << "!!"; - return 0; + info_logger info(&logger2); + info << "Hello info logger" << "!!"; + return 0; auto start = system_clock::now(); const unsigned int howmany = 10000000; for(unsigned int i = 0; i < howmany ; i++) diff --git a/include/c11log/details/blocking_queue.h b/include/c11log/details/blocking_queue.h index 50a5b6c1..99a08467 100644 --- a/include/c11log/details/blocking_queue.h +++ b/include/c11log/details/blocking_queue.h @@ -58,7 +58,7 @@ public: // If the queue is full, block the calling thread until there is room. template void push(TT&& item) { - constexpr std::chrono::hours one_hour(1); + constexpr std::chrono::hours one_hour(1); while (!push(std::forward(item), one_hour)); } @@ -86,7 +86,7 @@ public: // Pop a copy of the front item in the queue into the given item ref. // If the queue is empty, block the calling thread util there is item to pop. void pop(T& item) { - constexpr std::chrono::hours one_hour(1); + constexpr std::chrono::hours one_hour(1); while (!pop(item, one_hour)); } diff --git a/include/c11log/details/os.h b/include/c11log/details/os.h index 87a777eb..b45be277 100644 --- a/include/c11log/details/os.h +++ b/include/c11log/details/os.h @@ -31,3 +31,8 @@ inline std::tm c11log::details::os::localtime() std::time_t now_t = time(0); return localtime(now_t); } + +// Take care of snprintf in visual studio +#ifdef _MSC_VER +#define snprintf _snprintf +#endif diff --git a/include/c11log/formatter.h b/include/c11log/formatter.h index 004480b5..45fffa96 100644 --- a/include/c11log/formatter.h +++ b/include/c11log/formatter.h @@ -42,7 +42,7 @@ private: inline void c11log::formatters::default_formatter::_format_time(const log_clock::time_point& tp, std::ostream &dest) -{ +{ auto tm = details::os::localtime(log_clock::to_time_t(tp)); char buff[64]; int size = snprintf(buff, sizeof(buff), "[%d-%02d-%02d %02d:%02d:%02d]", diff --git a/include/c11log/logger.h b/include/c11log/logger.h index 40486474..44039ece 100644 --- a/include/c11log/logger.h +++ b/include/c11log/logger.h @@ -173,13 +173,13 @@ inline c11log::logger& c11log::get_logger(const std::string& name) namespace c11log { class info_logger { public: - info_logger (c11log::logger* logger):_logger(logger) {} - template - details::line_logger& operator<<(const T& msg) { - return _logger->info() << msg; - } + info_logger (c11log::logger* logger):_logger(logger) {} + template + details::line_logger& operator<<(const T& msg) { + return _logger->info() << msg; + } private: - c11log::logger* _logger; + c11log::logger* _logger; }; }