Commit 08ba1791 authored by gabime's avatar gabime

platform eol

parent 9d9a955e
...@@ -21,6 +21,7 @@ int main(int argc, char* argv[]) ...@@ -21,6 +21,7 @@ int main(int argc, char* argv[])
if(argc || argv) {}; if(argc || argv) {};
auto fsink = std::make_shared<sinks::rotating_file_sink>("log", "txt", 1024*1024*50 , 5, 0); auto fsink = std::make_shared<sinks::rotating_file_sink>("log", "txt", 1024*1024*50 , 5, 0);
//auto fsink = std::make_shared<sinks::simple_file_sink>("simplelog", "txt");
auto null_sink = std::make_shared<sinks::null_sink>(); auto null_sink = std::make_shared<sinks::null_sink>();
...@@ -29,11 +30,11 @@ int main(int argc, char* argv[]) ...@@ -29,11 +30,11 @@ int main(int argc, char* argv[])
cout_logger.info() << "Hello cout logger!"; cout_logger.info() << "Hello cout logger!";
logger my_logger ("my_logger", {fsink}); logger my_logger ("my_logger", {null_sink});
auto start = system_clock::now(); auto start = system_clock::now();
const unsigned int howmany = 15000000; const unsigned int howmany = 500000;
for(unsigned int i = 0; i < howmany ; i++) for(unsigned int i = 0; i < howmany ; i++)
my_logger.info() << "Hello logger " << i; my_logger.info() << "Hello logger " << i;
......
CXX = g++ CXX = g++
CXXFLAGS = -march=native -Wall -Wextra -Wshadow -pedantic -std=c++11 -pthread -I../include 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 CXX_DEBUG_FLAGS= -g
OUTBIN = example OUTBIN = example
......
...@@ -49,14 +49,14 @@ public: ...@@ -49,14 +49,14 @@ public:
{ {
if (_enabled) if (_enabled)
{ {
_oss << '\n'; _oss << os::eol();
_callback_logger->_log_it(_oss.str_ref(), _level); _callback_logger->_log_it(_oss.str_ref(), _level);
} }
} }
template<typename T> template<typename T>
line_logger&& operator<<(const T& msg) && line_logger&& operator<<(const T& msg)
{ {
if (_enabled) if (_enabled)
_oss << msg; _oss << msg;
......
...@@ -14,7 +14,7 @@ inline std::tm localtime(const std::time_t &time_tt) ...@@ -14,7 +14,7 @@ inline std::tm localtime(const std::time_t &time_tt)
{ {
std::tm tm; std::tm tm;
#ifdef _MSC_VER #ifdef _WIN32
localtime_s(&tm, &time_tt); localtime_s(&tm, &time_tt);
#else #else
localtime_r(&time_tt, &tm); localtime_r(&time_tt, &tm);
...@@ -47,9 +47,17 @@ inline bool operator!=(const std::tm& tm1, const std::tm& tm2) ...@@ -47,9 +47,17 @@ inline bool operator!=(const std::tm& tm1, const std::tm& tm2)
return !(tm1==tm2); return !(tm1==tm2);
} }
inline const char* eol()
{
#ifdef _WIN32
return "\r\n";
#else
return "\n";
#endif
} }
} } //os
} } //details
} //c11log
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment