Minor improvements to logging.

This commit is contained in:
Pedro Pinto committed 2017-08-18 15:30:48 +00:00
1 parent d4445fe3e3
commit 2ebf337805
3 files changed
+18 -11

No files matched your search

+3 -2
View File
@@ -1,6 +1,7 @@
#include "LoggerHub.h"
#include "lib/utils/bts_assert.h"
#include "lib/utils/bts_chrono.h"
#include "Logger.h"
#include "lib/os/os.h"
#include <thread>
@@ -106,8 +107,8 @@ void LoggerHub::do_work()
std::lock_guard<std::mutex> l (me->lock);
consumed = consume_log_recs();
}
if (consumed == 0)
std::this_thread::yield();
if (consumed == 0)
std::this_thread::sleep_for (10ms);
}
for (;;) {
+3 -3
View File
@@ -37,15 +37,15 @@ struct InitSysLog {
auto formatter() {
return [] (LogMsg const&m) {
return fmt::format("{} | {} {} {}:{} tid:{} pid:{} {}",
return fmt::format("{}: {} | {} {} {}:{} tid:{} pid:{}",
datetime::time_string(datetime::now()),
m.msg,
m.subsystem_name,
m.level_name,
boost::filesystem::path(m.file).filename().string() ,
m.line,
m.tid,
os::process_id(),
datetime::time_string(datetime::now()));
os::process_id());
};
}
+12 -6
View File
@@ -71,15 +71,21 @@ void configure_logging(bts::config::Logging const&cfg)
real_cfg.subsystem_names = { {Gen,"Gen"},
{Cfg,"Cfg"},
{QBus,"QBus"},
{Log,"Log"} };
{Log,"Log"},
{Jetfix,"Jetfix"},
{MarketData,"MarketData"},
{Api,"Api"},
{Persistence,"Persistence"} };
real_cfg.sinks["console"] = std::make_pair (console_sink(),get_filter(real_cfg,cfg.console()));
real_cfg.sinks["syslog"] = std::make_pair (syslog_sink(),get_filter(real_cfg,cfg.syslog()));
real_cfg.sinks["console"] =
std::make_pair (console_sink(),get_filter(real_cfg,cfg.console()));
real_cfg.sinks["syslog"] =
std::make_pair (syslog_sink(),get_filter(real_cfg,cfg.syslog()));
configure_logging(real_cfg);
}
LoggingConfigPoller::LoggingConfigPoller (bts::config::Logging const&cfg) : _poller_thread(),
_done(false)
LoggingConfigPoller::LoggingConfigPoller (bts::config::Logging const&cfg)
: _poller_thread(), _done(false)
{
init(cfg);
}
@@ -104,7 +110,7 @@ void LoggingConfigPoller::init (bts::config::Logging const&cfg)
configure_logging(cfg);
_poller_thread = std::thread([this,log_cache_file] {
os::set_thread_name("log config poll");
os::set_thread_name("log_config_poller");
auto last_ts = std::time(nullptr);
while (!_done) {