diff --git a/example/example.cpp b/example/example.cpp index 0ee78dd0..07d6be29 100644 --- a/example/example.cpp +++ b/example/example.cpp @@ -21,6 +21,7 @@ int main(int argc, char* argv[]) if(argc || argv) {}; auto fsink = std::make_shared("log", "txt", 1024*1024*50 , 5, 0); + //auto fsink = std::make_shared("simplelog", "txt"); auto null_sink = std::make_shared(); @@ -29,11 +30,11 @@ int main(int argc, char* argv[]) cout_logger.info() << "Hello cout logger!"; - logger my_logger ("my_logger", {fsink}); + logger my_logger ("my_logger", {null_sink}); auto start = system_clock::now(); - const unsigned int howmany = 15000000; + const unsigned int howmany = 500000; for(unsigned int i = 0; i < howmany ; i++) my_logger.info() << "Hello logger " << i; diff --git a/example/makefile b/example/makefile index 330d3af0..aee86858 100644 --- a/example/makefile +++ b/example/makefile @@ -1,6 +1,6 @@ CXX = g++ CXXFLAGS = -march=native -Wall -Wextra -Wshadow -pedantic -std=c++11 -pthread -I../include -CXX_RELEASE_FLAGS = -O3 -flto +CXX_RELEASE_FLAGS = -O3 -flto -g CXX_DEBUG_FLAGS= -g OUTBIN = example diff --git a/include/c11log/details/line_logger.h b/include/c11log/details/line_logger.h index 80c044c8..cecea1f9 100644 --- a/include/c11log/details/line_logger.h +++ b/include/c11log/details/line_logger.h @@ -49,14 +49,14 @@ public: { if (_enabled) { - _oss << '\n'; + _oss << os::eol(); _callback_logger->_log_it(_oss.str_ref(), _level); } } template - line_logger&& operator<<(const T& msg) && + line_logger&& operator<<(const T& msg) { if (_enabled) _oss << msg; diff --git a/include/c11log/details/os.h b/include/c11log/details/os.h index b799f601..509e6ed8 100644 --- a/include/c11log/details/os.h +++ b/include/c11log/details/os.h @@ -14,7 +14,7 @@ inline std::tm localtime(const std::time_t &time_tt) { std::tm tm; -#ifdef _MSC_VER +#ifdef _WIN32 localtime_s(&tm, &time_tt); #else localtime_r(&time_tt, &tm); @@ -47,9 +47,17 @@ inline bool operator!=(const std::tm& tm1, const std::tm& tm2) return !(tm1==tm2); } +inline const char* eol() +{ +#ifdef _WIN32 + return "\r\n"; +#else + return "\n"; +#endif } -} -} +} //os +} //details +} //c11log