diff --git a/Logger.cpp b/Logger.cpp index 316a9ebed..6c92ca407 100644 --- a/Logger.cpp +++ b/Logger.cpp @@ -34,12 +34,12 @@ namespace expr = logging::expressions; namespace attrs = logging::attributes; namespace ptime = boost::posix_time; -// BOOST_LOG_GLOBAL_LOGGER_CTOR_ARGS (sys, -// srcs::severity_channel_logger_mt, -// (keywords::channel = "SYSLOG")); -// BOOST_LOG_GLOBAL_LOGGER_CTOR_ARGS (data, -// srcs::severity_channel_logger_mt, -// (keywords::channel = "DATALOG")); +BOOST_LOG_GLOBAL_LOGGER_CTOR_ARGS (sys, + srcs::severity_channel_logger_mt, + (keywords::channel = "SYSLOG")); +BOOST_LOG_GLOBAL_LOGGER_CTOR_ARGS (data, + srcs::severity_channel_logger_mt, + (keywords::channel = "DATALOG")); namespace Logger { diff --git a/Logger.hpp b/Logger.hpp index c9058bd23..6e29789e4 100644 --- a/Logger.hpp +++ b/Logger.hpp @@ -10,10 +10,10 @@ #include #include -// BOOST_LOG_GLOBAL_LOGGER (sys, -// boost::log::sources::severity_channel_logger_mt); -// BOOST_LOG_GLOBAL_LOGGER (data, -// boost::log::sources::severity_channel_logger_mt); +BOOST_LOG_GLOBAL_LOGGER (sys, + boost::log::sources::severity_channel_logger_mt); +BOOST_LOG_GLOBAL_LOGGER (data, + boost::log::sources::severity_channel_logger_mt); namespace Logger { @@ -31,16 +31,12 @@ namespace Logger void add_data_file_log (std::string const& log_file_name); } -#if 0 #define LOG_LOG_LOCATION(LOGGER, LEVEL, ARG) \ BOOST_LOG_SEV (LOGGER, boost::log::trivial::LEVEL) \ - << boost::log::add_value ("Line", __LINE__) \ - << boost::log::add_value ("File", __FILE__) \ - << boost::log::add_value ("Function", __FUNCTION__) << ARG; -#endif - -#define LOG_LOG_LOCATION(LOGGER, LEVEL, ARG) - + << boost::log::add_value ("Line", __LINE__) \ + << boost::log::add_value ("File", __FILE__) \ + << boost::log::add_value ("Function", __FUNCTION__) << ARG; + /// System Log macros. /// TRACE < DEBUG < INFO < WARN < ERROR < FATAL #define LOG_TRACE(ARG) LOG_LOG_LOCATION (sys::get(), trace, ARG); diff --git a/Transceiver/HRDTransceiver.cpp b/Transceiver/HRDTransceiver.cpp index 5fe0dcb58..9ea10949c 100644 --- a/Transceiver/HRDTransceiver.cpp +++ b/Transceiver/HRDTransceiver.cpp @@ -187,10 +187,10 @@ int HRDTransceiver::do_start () } CAT_TRACE ("radios:-"); - // Q_FOREACH (auto const& radio, radios_) - // { - // CAT_TRACE ("\t[" << std::get<0> (radio) << "] " << std::get<1> (radio)); - // } + Q_FOREACH (auto const& radio, radios_) + { + CAT_TRACE ("\t[" << std::get<0> (radio) << "] " << std::get<1> (radio)); + } auto current_radio_name = send_command ("get radio", false, false); HRD_info << "Current radio: " << current_radio_name << "\n"; @@ -407,11 +407,11 @@ void HRDTransceiver::map_modes (int dropdown, ModeMap *map) map->push_back (std::forward_as_tuple (DIG_FM, find_dropdown_selection (dropdown, QRegExp ("^(PKT-FM|PKT|DATA\\(FM\\)|FM)$")))); CAT_TRACE ("for dropdown" << dropdown_names_[dropdown]); - // std::for_each (map->begin (), map->end (), [this, dropdown] (ModeMap::value_type const& item) - // { - // auto const& rhs = std::get<1> (item); - // CAT_TRACE ('\t' << std::get<0> (item) << "<->" << (rhs.size () ? dropdowns_[dropdown_names_[dropdown]][rhs.front ()] : "None")); - // }); + std::for_each (map->begin (), map->end (), [this, dropdown] (ModeMap::value_type const& item) + { + auto const& rhs = std::get<1> (item); + CAT_TRACE ('\t' << std::get<0> (item) << "<->" << (rhs.size () ? dropdowns_[dropdown_names_[dropdown]][rhs.front ()] : "None")); + }); } int HRDTransceiver::lookup_mode (MODE mode, ModeMap const& map) const diff --git a/WSJTXLogging.cpp b/WSJTXLogging.cpp index 6cfe32a67..76adf81b0 100644 --- a/WSJTXLogging.cpp +++ b/WSJTXLogging.cpp @@ -193,21 +193,21 @@ WSJTXLogging::~WSJTXLogging () } // Reroute Qt messages to the system logger -void WSJTXLogging::qt_log_handler (QtMsgType type, QMessageLogContext const& context, QString const& /*msg*/) +void WSJTXLogging::qt_log_handler (QtMsgType type, QMessageLogContext const& context, QString const& msg) { // Convert Qt message types to logger severities - // auto severity = trivial::trace; - // switch (type) - // { - // case QtDebugMsg: severity = trivial::debug; break; - // case QtInfoMsg: severity = trivial::info; break; - // case QtWarningMsg: severity = trivial::warning; break; - // case QtCriticalMsg: severity = trivial::error; break; - // case QtFatalMsg: severity = trivial::fatal; break; - // } + auto severity = trivial::trace; + switch (type) + { + case QtDebugMsg: severity = trivial::debug; break; + case QtInfoMsg: severity = trivial::info; break; + case QtWarningMsg: severity = trivial::warning; break; + case QtCriticalMsg: severity = trivial::error; break; + case QtFatalMsg: severity = trivial::fatal; break; + } // Map non-default Qt categories to logger channels, Qt logger // context is mapped to the appropriate logger attributes. - // auto log = sys::get (); + auto log = sys::get (); std::string file; std::string function; if (context.file) @@ -220,19 +220,19 @@ void WSJTXLogging::qt_log_handler (QtMsgType type, QMessageLogContext const& con } if (!context.category || !qstrcmp (context.category, "default")) { - // BOOST_LOG_SEV (log, severity) - // << boost::log::add_value ("Line", context.line) - // << boost::log::add_value ("File", file) - // << boost::log::add_value ("Function", function) - // << msg.toStdString (); + BOOST_LOG_SEV (log, severity) + << boost::log::add_value ("Line", context.line) + << boost::log::add_value ("File", file) + << boost::log::add_value ("Function", function) + << msg.toStdString (); } else { - // BOOST_LOG_CHANNEL_SEV (log, std::string {context.category}, severity) - // << boost::log::add_value ("Line", context.line) - // << boost::log::add_value ("File", file) - // << boost::log::add_value ("Function", function) - // << msg.toStdString (); + BOOST_LOG_CHANNEL_SEV (log, std::string {context.category}, severity) + << boost::log::add_value ("Line", context.line) + << boost::log::add_value ("File", file) + << boost::log::add_value ("Function", function) + << msg.toStdString (); } if (QtFatalMsg == type) { diff --git a/main.cpp b/main.cpp index 2bbaf5e33..021e327b4 100644 --- a/main.cpp +++ b/main.cpp @@ -71,29 +71,29 @@ namespace } seeding; #endif - // void safe_stream_QVariant (boost::log::record_ostream& os, QVariant const& v) - // { - // switch (static_cast (v.type ())) - // { - // case QMetaType::QByteArray: - // os << "0x" << v.toByteArray ().toHex (':').toStdString (); - // break; + void safe_stream_QVariant (boost::log::record_ostream& os, QVariant const& v) + { + switch (static_cast (v.type ())) + { + case QMetaType::QByteArray: + os << "0x" << v.toByteArray ().toHex (':').toStdString (); + break; - // case QMetaType::QBitArray: - // { - // auto const& bits = v.toBitArray (); - // os << "0b"; - // for (int i = 0; i < bits.size (); ++ i) - // { - // os << (bits[i] ? '1' : '0'); - // } - // } - // break; + case QMetaType::QBitArray: + { + auto const& bits = v.toBitArray (); + os << "0b"; + for (int i = 0; i < bits.size (); ++ i) + { + os << (bits[i] ? '1' : '0'); + } + } + break; - // default: - // os << v.toString (); - // } - // } + default: + os << v.toString (); + } + } } int main(int argc, char *argv[]) @@ -325,42 +325,42 @@ int main(int argc, char *argv[]) do { // dump settings - // auto sys_lg = sys::get (); - // if (auto rec = sys_lg.open_record - // ( - // boost::log::keywords::severity = boost::log::trivial::trace) - // ) - // { - // boost::log::record_ostream strm (rec); - // strm << "++++++++++++++++++++++++++++ Settings ++++++++++++++++++++++++++++\n"; - // for (auto const& key: multi_settings.settings ()->allKeys ()) - // { - // if (!key.contains (QRegularExpression {"^MultiSettings/[^/]*/"})) - // { - // auto const& value = multi_settings.settings ()->value (key); - // if (value.canConvert ()) - // { - // auto const sequence = value.value (); - // strm << key << ":\n"; - // for (auto const& item: sequence) - // { - // strm << "\t"; - // safe_stream_QVariant (strm, item); - // strm << '\n'; - // } - // } - // else - // { - // strm << key << ": "; - // safe_stream_QVariant (strm, value); - // strm << '\n'; - // } - // } - // } - // strm << "---------------------------- Settings ----------------------------\n"; - // strm.flush (); - // sys_lg.push_record (boost::move (rec)); - // } + auto sys_lg = sys::get (); + if (auto rec = sys_lg.open_record + ( + boost::log::keywords::severity = boost::log::trivial::trace) + ) + { + boost::log::record_ostream strm (rec); + strm << "++++++++++++++++++++++++++++ Settings ++++++++++++++++++++++++++++\n"; + for (auto const& key: multi_settings.settings ()->allKeys ()) + { + if (!key.contains (QRegularExpression {"^MultiSettings/[^/]*/"})) + { + auto const& value = multi_settings.settings ()->value (key); + if (value.canConvert ()) + { + auto const sequence = value.value (); + strm << key << ":\n"; + for (auto const& item: sequence) + { + strm << "\t"; + safe_stream_QVariant (strm, item); + strm << '\n'; + } + } + else + { + strm << key << ": "; + safe_stream_QVariant (strm, value); + strm << '\n'; + } + } + } + strm << "---------------------------- Settings ----------------------------\n"; + strm.flush (); + sys_lg.push_record (boost::move (rec)); + } // Create and initialize shared memory segment // Multiple instances: use rig_name as shared memory key