diff --git a/example/example.cpp b/example/example.cpp index 6232d970..493cbc36 100644 --- a/example/example.cpp +++ b/example/example.cpp @@ -54,10 +54,10 @@ int main(int argc, char* argv[]) using std::cout; using std::endl; - auto fsink2 = std::make_shared("log", "txt", 1024*1024*50 , 5, seconds(1)); + //auto fsink2 = std::make_shared("log", "txt", 1024*1024*50 , 5, seconds(1)); auto &logger2 = c11log::get_logger("logger2"); - logger2.add_sink(fsink2); - //logger2.add_sink(std::make_shared()); + //logger2.add_sink(fsink2); + logger2.add_sink(std::make_shared()); auto start = system_clock::now(); const unsigned int howmany = 10000000; diff --git a/example/makefile b/example/makefile index b102c8f4..330d3af0 100644 --- a/example/makefile +++ b/example/makefile @@ -1,4 +1,4 @@ -CXX = ccache g++ +CXX = g++ CXXFLAGS = -march=native -Wall -Wextra -Wshadow -pedantic -std=c++11 -pthread -I../include CXX_RELEASE_FLAGS = -O3 -flto CXX_DEBUG_FLAGS= -g diff --git a/include/c11log/details/blocking_queue.h b/include/c11log/details/blocking_queue.h index cea541a2..94641a26 100644 --- a/include/c11log/details/blocking_queue.h +++ b/include/c11log/details/blocking_queue.h @@ -58,7 +58,8 @@ public: // If the queue is full, block the calling thread until there is room. template void push(TT&& item) { - while (!push(std::forward(item), _one_hour)); + static constexpr std::chrono::hours one_hour(1); + while (!push(std::forward(item), one_hour)); } // Pop a copy of the front item in the queue into the given item ref. @@ -85,7 +86,8 @@ 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) { - while (!pop(item, _one_hour)); + static constexpr std::chrono::hours one_hour(1); + while (!pop(item, one_hour)); } // Clear the queue @@ -103,7 +105,6 @@ private: std::mutex _mutex; std::condition_variable _item_pushed_cond; std::condition_variable _item_popped_cond; - static constexpr auto _one_hour = std::chrono::hours(1); }; } diff --git a/include/c11log/formatter.h b/include/c11log/formatter.h index fa424293..004480b5 100644 --- a/include/c11log/formatter.h +++ b/include/c11log/formatter.h @@ -42,9 +42,7 @@ private: inline void c11log::formatters::default_formatter::_format_time(const log_clock::time_point& tp, std::ostream &dest) -{ - using namespace std::chrono; - +{ 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]",