From 51d9a002e3311a2079b25253b7946a4b03a9baf4 Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Fri, 21 Feb 2020 20:32:21 +0100 Subject: [PATCH] Updating files to 1.4.9 --- src/EventLoop.cpp | 3 ++- src/EventLoop.h | 2 +- src/log/LogSinks.cpp | 7 ++++++- src/log/LogUtils.cpp | 17 ++++++++++------- src/log/LogUtils.h | 1 + 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/EventLoop.cpp b/src/EventLoop.cpp index 46343b7..9c831e6 100644 --- a/src/EventLoop.cpp +++ b/src/EventLoop.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -10,7 +11,7 @@ using namespace std; using namespace ts::event; -EventExecutor::EventExecutor(const std::string& thread_prefix) : _thread_prefix(thread_prefix) {} +EventExecutor::EventExecutor(std::string thread_prefix) : _thread_prefix{std::move(thread_prefix)} {} EventExecutor::~EventExecutor() { unique_lock lock(this->lock); this->_shutdown(lock); diff --git a/src/EventLoop.h b/src/EventLoop.h index a0a893a..f6550f3 100644 --- a/src/EventLoop.h +++ b/src/EventLoop.h @@ -43,7 +43,7 @@ namespace ts { class EventExecutor { public: - explicit EventExecutor(const std::string& /* thread prefix */); + explicit EventExecutor(std::string /* thread prefix */); virtual ~EventExecutor(); bool initialize(int /* num threads */); diff --git a/src/log/LogSinks.cpp b/src/log/LogSinks.cpp index 1b080f7..00b0a15 100644 --- a/src/log/LogSinks.cpp +++ b/src/log/LogSinks.cpp @@ -35,7 +35,12 @@ namespace logger { cout << message; } - void TerminalSink::flush_() {} + void TerminalSink::flush_() { +#ifdef HAVE_CXX_TERMINAL + if(!terminal::active()) +#endif + std::cout.flush(); + } inline void append_time(const log_clock::time_point& point, memory_buf_t& dest) { diff --git a/src/log/LogUtils.cpp b/src/log/LogUtils.cpp index d392179..3372760 100644 --- a/src/log/LogUtils.cpp +++ b/src/log/LogUtils.cpp @@ -137,14 +137,17 @@ namespace logger { } sinks.push_back(terminalSink); - if(!logging_threads) + if(!logging_threads && !logConfig->sync) logging_threads = std::make_shared(8192, 1); //Only one thread possible here, else elements get reordered -#ifdef ASYNC_LOG - auto logger = std::make_shared("Logger (" + path + ")", sinks.begin(), sinks.end(), logging_threads, async_overflow_policy::block); -#else - //FIXME! - auto logger = create("Logger (" + path + ")", sinks.begin(), sinks.end()); -#endif + + std::shared_ptr logger; + if(!logConfig->sync) { + logger = std::make_shared("Logger (" + path + ")", sinks.begin(), sinks.end(), logging_threads, async_overflow_policy::block); + } else { + logger = std::make_shared("Logger (" + path + ")", sinks.begin(), sinks.end()); + logger->flush_on(level::trace); + } + updater_logger_levels(logger); loggers[group] = logger; } diff --git a/src/log/LogUtils.h b/src/log/LogUtils.h index ee3f7e4..2024dec 100644 --- a/src/log/LogUtils.h +++ b/src/log/LogUtils.h @@ -27,6 +27,7 @@ namespace logger { struct LoggerConfig { spdlog::level::level_enum logfileLevel = spdlog::level::info; spdlog::level::level_enum terminalLevel = spdlog::level::info; + bool sync{false}; bool file_colored; std::string logPath = "log_${time}.log"; size_t vs_group_size = 1;