From b9a6c078aa3ee40e9bc577ecdb972289f433f3b7 Mon Sep 17 00:00:00 2001 From: Pedro Pinto Date: Mon, 9 Oct 2017 22:24:21 +0000 Subject: [PATCH] Cleaned MD use of logs. --- src/lib/config/protos/MarketData.proto | 1 - src/lib/logging/Sink.cpp | 14 +++----------- src/lib/logging/logging.cpp | 13 ++++++++++++- src/lib/logging/logging.h | 3 +++ src/lib/md/relay/RelayRecorder.cpp | 2 +- 5 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/lib/config/protos/MarketData.proto b/src/lib/config/protos/MarketData.proto index 2ae232f23..9e9902e59 100755 --- a/src/lib/config/protos/MarketData.proto +++ b/src/lib/config/protos/MarketData.proto @@ -88,7 +88,6 @@ message CMEOptions // New settings } optional string onixs_license = 1 [default = "{default}"]; - optional string onixs_log_path = 2 [default = "/var/log/bts/onixs"]; repeated CMEChannel channel = 3; repeated FeedEngineSettings feed_engine = 5; diff --git a/src/lib/logging/Sink.cpp b/src/lib/logging/Sink.cpp index b7481f636..c2cc1a5d3 100644 --- a/src/lib/logging/Sink.cpp +++ b/src/lib/logging/Sink.cpp @@ -96,19 +96,11 @@ std::ifstream::pos_type filesize(std::string const&filename) } } -boost::filesystem::path log_path () -{ - auto store_root = os::bts_data_path(); - std::string base_path = store_root; - boost::filesystem::path result = utils::normalize_data_path (base_path); - result /= "logging"; - result /= "log"; - return result; -} - Sink file_sink() { auto f= formatter(); - auto path = log_path(); + auto path = log_path(); + path /= "log"; + auto parent = path.parent_path(); if (!boost::filesystem::is_directory(parent)) diff --git a/src/lib/logging/logging.cpp b/src/lib/logging/logging.cpp index a2d29f4b8..eee24ff40 100644 --- a/src/lib/logging/logging.cpp +++ b/src/lib/logging/logging.cpp @@ -33,6 +33,15 @@ typename M::const_iterator find_key(M const&m, typename M::mapped_type const &v) return m.end(); } +boost::filesystem::path log_path () +{ + auto store_root = os::bts_data_path(); + std::string base_path = store_root; + boost::filesystem::path result = utils::normalize_data_path (base_path); + result /= "logging"; + return result; +} + void start_default_logging_thread() { _default_logger_hub.start(); @@ -85,7 +94,9 @@ void configure_logging(bts::config::Logging const&cfg) {log::Api,"Api"}, {log::Persistence,"Persistence"}, {log::User,"User"}, - {log::OrderMan,"OrderMan"}}; + {log::OrderMan,"OrderMan"}, + {log::Latency,"Latency"}, + }; real_cfg.sinks["console"] = std::make_pair (console_sink(),get_filter(real_cfg,cfg.console())); diff --git a/src/lib/logging/logging.h b/src/lib/logging/logging.h index 6e7eaf639..c6673620b 100644 --- a/src/lib/logging/logging.h +++ b/src/lib/logging/logging.h @@ -32,6 +32,7 @@ constexpr log::Subsystem Api {MarketData.ordinal+1}; constexpr log::Subsystem Persistence{Api.ordinal+1}; constexpr log::Subsystem User {Persistence.ordinal+1}; constexpr log::Subsystem OrderMan {User.ordinal+1}; +constexpr log::Subsystem Latency {OrderMan.ordinal+1}; struct LoggerHandle { LoggerHandle(LoggerHandle const&) = delete; @@ -63,6 +64,8 @@ private: std::atomic _done; }; +boost::filesystem::path log_path (); + #define LOG(subsystem,level,...) bts::log::_thread_logger.logger->enqueue(bts::log::subsystem,level,__FILE__,__LINE__,__VA_ARGS__) #define LOG_ONCE_MAYBE(subsystem,level,...) bts::log::_thread_logger.logger->enqueue_once_maybe(log::subsystem,level,__FILE__,__LINE__,__VA_ARGS__) diff --git a/src/lib/md/relay/RelayRecorder.cpp b/src/lib/md/relay/RelayRecorder.cpp index fa5fbf033..2de1534ce 100644 --- a/src/lib/md/relay/RelayRecorder.cpp +++ b/src/lib/md/relay/RelayRecorder.cpp @@ -138,7 +138,7 @@ void replay_file(const std::string& filename, IRelayWriter& writer, int32_t nagg replay_recording(in, writer, naggle_ms); } else { - cout << "Cannot read file: " << filename; + LOG(MarketData,Diag, "Cannot read file {}", filename); } }