diff --git a/Configuration.cpp b/Configuration.cpp index 4156fe155..fdc425567 100644 --- a/Configuration.cpp +++ b/Configuration.cpp @@ -2752,7 +2752,7 @@ void Configuration::impl::handle_transceiver_update (TransceiverState const& sta void Configuration::impl::handle_transceiver_failure (QString const& reason) { - LOG_TRACE ("handle_transceiver_failure: reason: " << reason); + LOG_TRACE ("handle_transceiver_failure: reason: " << reason.toStdWString ()); close_rig (); ui_->test_PTT_push_button->setChecked (false); diff --git a/L10nLoader.cpp b/L10nLoader.cpp index 433d8d81f..3889fedee 100644 --- a/L10nLoader.cpp +++ b/L10nLoader.cpp @@ -67,7 +67,7 @@ L10nLoader::L10nLoader (QApplication * app, QLocale const& locale, QString const .arg (QLocale::languageToString (locale.language ())) .arg (QLocale::scriptToString (locale.script ())) .arg (QLocale::countryToString (locale.country ())) - .arg (locale.uiLanguages ().join (", "))); + .arg (locale.uiLanguages ().join (", ")).toStdWString ()); // we don't load translators if the language override is 'en', // 'en_US', or 'en-US'. In these cases we assume the user is trying @@ -81,7 +81,7 @@ L10nLoader::L10nLoader (QApplication * app, QLocale const& locale, QString const QString translations_dir {":/Translations"}; if (!skip_locale) { - LOG_INFO ("Looking for locale based Qt translations in resources filesystem"); + LOG_TRACE ("Looking for locale based Qt translations in resources filesystem"); if (m_->load_translator (locale, "qt", "_", translations_dir)) { LOG_INFO ("Loaded Qt translations for current locale from resources"); @@ -99,25 +99,25 @@ L10nLoader::L10nLoader (QApplication * app, QLocale const& locale, QString const // source control for translators to access and update. // try and load the base translation - LOG_INFO ("Looking for WSJT-X translations based on UI languages in the resources filesystem"); + LOG_TRACE ("Looking for WSJT-X translations based on UI languages in the resources filesystem"); for (QString locale_name : locale.uiLanguages ()) { auto language = locale_name.left (2); if (locale.uiLanguages ().front ().left (2) == language) { - LOG_TRACE (QString {"Trying %1"}.arg (language)); + LOG_TRACE (QString {"Trying %1"}.arg (language).toStdWString ()); if (m_->load_translator ("wsjtx_" + language, translations_dir)) { LOG_INFO (QString {"Loaded WSJT-X base translation file from %1 based on language %2"} .arg (translations_dir) - .arg (language)); + .arg (language).toStdWString ()); break; } } } // now try and load the most specific translations (may be a // duplicate but we shouldn't care) - LOG_INFO ("Looking for WSJT-X translations based on locale in the resources filesystem"); + LOG_TRACE ("Looking for WSJT-X translations based on locale in the resources filesystem"); if (m_->load_translator (locale, "wsjtx", "_", translations_dir)) { LOG_INFO ("Loaded WSJT-X translations for current locale from resources"); @@ -136,21 +136,21 @@ L10nLoader::L10nLoader (QApplication * app, QLocale const& locale, QString const language.replace ('-', '_'); // try and load the base translation auto base_language = language.left (2); - LOG_INFO ("Looking for WSJT-X translations based on command line region override in the resources filesystem"); + LOG_TRACE ("Looking for WSJT-X translations based on command line region override in the resources filesystem"); if (m_->load_translator ("wsjtx_" + base_language, translations_dir)) { LOG_INFO (QString {"Loaded base translation file from %1 based on language %2"} .arg (translations_dir) - .arg (base_language)); + .arg (base_language).toStdWString ()); } // now load the requested translations (may be a duplicate // but we shouldn't care) - LOG_INFO ("Looking for WSJT-X translations based on command line override country in the resources filesystem"); + LOG_TRACE ("Looking for WSJT-X translations based on command line override country in the resources filesystem"); if (m_->load_translator ("wsjtx_" + language, translations_dir)) { LOG_INFO (QString {"Loaded translation file from %1 based on language %2"} .arg (translations_dir) - .arg (language)); + .arg (language).toStdWString ()); } } @@ -163,16 +163,16 @@ L10nLoader::L10nLoader (QApplication * app, QLocale const& locale, QString const // the LANG environment variable on non-Windows system. // try and load the base translation - LOG_INFO ("Looking for WSJT-X translations based on command line override country in the current directory"); + LOG_TRACE ("Looking for WSJT-X translations based on command line override country in the current directory"); for (QString locale_name : locale.uiLanguages ()) { auto language = locale_name.left (2); if (locale.uiLanguages ().front ().left (2) == language) { - LOG_TRACE (QString {"Trying %1"}.arg (language)); + LOG_TRACE (QString {"Trying %1"}.arg (language).toStdWString ()); if (m_->load_translator ("wsjtx_" + language)) { - LOG_INFO (QString {"Loaded base translation file from $cwd based on language %1"}.arg (language)); + LOG_INFO (QString {"Loaded base translation file from $cwd based on language %1"}.arg (language).toStdWString ()); break; } } @@ -182,7 +182,7 @@ L10nLoader::L10nLoader (QApplication * app, QLocale const& locale, QString const { // now try and load the most specific translations (may be a // duplicate but we shouldn't care) - LOG_INFO ("Looking for WSJT-X translations based on locale in the resources filesystem"); + LOG_TRACE ("Looking for WSJT-X translations based on locale in the resources filesystem"); if (m_->load_translator (locale, "wsjtx", "_")) { LOG_INFO ("loaded translations for current locale from a file"); @@ -201,17 +201,17 @@ L10nLoader::L10nLoader (QApplication * app, QLocale const& locale, QString const language.replace ('-', '_'); // try and load the base translation auto base_language = language.left (2); - LOG_INFO ("Looking for WSJT-X translations based on command line override country in the current directory"); + LOG_TRACE ("Looking for WSJT-X translations based on command line override country in the current directory"); if (m_->load_translator ("wsjtx_" + base_language)) { - LOG_INFO (QString {"Loaded base translation file from $cwd based on language %1"}.arg (base_language)); + LOG_INFO (QString {"Loaded base translation file from $cwd based on language %1"}.arg (base_language).toStdWString ()); } // now load the requested translations (may be a duplicate // but we shouldn't care) - LOG_INFO ("Looking for WSJT-X translations based on command line region in the current directory"); + LOG_TRACE ("Looking for WSJT-X translations based on command line region in the current directory"); if (m_->load_translator ("wsjtx_" + language)) { - LOG_INFO (QString {"loaded translation file from $cwd based on language %1"}.arg (language)); + LOG_INFO (QString {"loaded translation file from $cwd based on language %1"}.arg (language).toStdWString ()); } } } diff --git a/Logger.cpp b/Logger.cpp index b8aecea2b..9a1b9429a 100644 --- a/Logger.cpp +++ b/Logger.cpp @@ -34,11 +34,11 @@ namespace ptime = boost::posix_time; namespace Logger { BOOST_LOG_GLOBAL_LOGGER_CTOR_ARGS (sys, - srcs::severity_channel_logger_mt, - (keywords::channel = "SYSLOG")); + srcs::wseverity_channel_logger_mt, + (keywords::channel = L"SYSLOG")); BOOST_LOG_GLOBAL_LOGGER_CTOR_ARGS (data, - srcs::severity_channel_logger_mt, - (keywords::channel = "DATALOG")); + srcs::wseverity_channel_logger_mt, + (keywords::channel = L"DATALOG")); namespace { @@ -149,24 +149,24 @@ namespace Logger void add_datafile_log (std::string const& log_file_name) { // Create a text file sink - boost::shared_ptr backend + boost::shared_ptr backend ( - new sinks::text_ostream_backend() + new sinks::wtext_ostream_backend() ); - backend->add_stream (boost::shared_ptr (new std::ofstream (log_file_name))); + backend->add_stream (boost::shared_ptr (new std::wofstream (log_file_name))); // Flush after each log record backend->auto_flush (true); // Create a sink for the backend - typedef sinks::synchronous_sink sink_t; + typedef sinks::synchronous_sink sink_t; boost::shared_ptr sink (new sink_t (backend)); // The log output formatter - sink->set_formatter (expr::format ("[%1%][%2%] %3%") + sink->set_formatter (expr::format (L"[%1%][%2%] %3%") % expr::attr ("TimeStamp") % logging::trivial::severity - % expr::smessage + % expr::message ); // Filter by severity and by DATALOG channel diff --git a/Logger.hpp b/Logger.hpp index f5af4094d..dece480ae 100644 --- a/Logger.hpp +++ b/Logger.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -12,9 +13,9 @@ namespace Logger { BOOST_LOG_GLOBAL_LOGGER (sys, - boost::log::sources::severity_channel_logger_mt); + boost::log::sources::wseverity_channel_logger_mt); BOOST_LOG_GLOBAL_LOGGER (data, - boost::log::sources::severity_channel_logger_mt); + boost::log::sources::wseverity_channel_logger_mt); // trivial logging to console void init (); diff --git a/Transceiver/DXLabSuiteCommanderTransceiver.cpp b/Transceiver/DXLabSuiteCommanderTransceiver.cpp index 21709d950..d20cfab14 100644 --- a/Transceiver/DXLabSuiteCommanderTransceiver.cpp +++ b/Transceiver/DXLabSuiteCommanderTransceiver.cpp @@ -71,7 +71,7 @@ int DXLabSuiteCommanderTransceiver::do_start () commander_->connectToHost (std::get<0> (server_details), std::get<1> (server_details)); if (!commander_->waitForConnected ()) { - TRACE_CAT ("failed to connect" << commander_->errorString ()); + TRACE_CAT ("failed to connect" << commander_->errorString ().toStdWString ()); throw error {tr ("Failed to connect to DX Lab Suite Commander\n") + commander_->errorString ()}; } @@ -127,7 +127,7 @@ int DXLabSuiteCommanderTransceiver::do_start () } else { - TRACE_CAT ("get frequency unexpected response" << reply); + TRACE_CAT ("get frequency unexpected response" << reply.toStdWString ()); throw error {tr ("DX Lab Suite Commander didn't respond correctly reading frequency: ") + reply}; } @@ -174,13 +174,13 @@ void DXLabSuiteCommanderTransceiver::do_ptt (bool on) } else { - TRACE_CAT ("unexpected TX state" << state); + TRACE_CAT ("unexpected TX state" << state.toStdWString ()); throw error {tr ("DX Lab Suite Commander sent an unrecognised TX state: ") + state}; } } else { - TRACE_CAT ("get TX unexpected response" << reply); + TRACE_CAT ("get TX unexpected response" << reply.toStdWString ()); throw error {tr ("DX Lab Suite Commander didn't respond correctly polling TX status: ") + reply}; } if (tx != on) QThread::msleep (10); // don't thrash Commander @@ -268,7 +268,7 @@ void DXLabSuiteCommanderTransceiver::do_poll () } else { - TRACE_CAT_POLL ("get frequency unexpected response" << reply); + TRACE_CAT_POLL ("get frequency unexpected response" << reply.toStdWString ()); throw error {tr ("DX Lab Suite Commander didn't respond correctly polling frequency: ") + reply}; } @@ -289,7 +289,7 @@ void DXLabSuiteCommanderTransceiver::do_poll () } else { - TRACE_CAT_POLL ("get tx frequency unexpected response" << reply); + TRACE_CAT_POLL ("get tx frequency unexpected response" << reply.toStdWString ()); throw error {tr ("DX Lab Suite Commander didn't respond correctly polling TX frequency: ") + reply}; } } @@ -308,13 +308,13 @@ void DXLabSuiteCommanderTransceiver::do_poll () } else { - TRACE_CAT_POLL ("unexpected split state" << split); + TRACE_CAT_POLL ("unexpected split state" << split.toStdWString ()); throw error {tr ("DX Lab Suite Commander sent an unrecognised split state: ") + split}; } } else { - TRACE_CAT_POLL ("get split mode unexpected response" << reply); + TRACE_CAT_POLL ("get split mode unexpected response" << reply.toStdWString ()); throw error {tr ("DX Lab Suite Commander didn't respond correctly polling split status: ") + reply}; } @@ -370,14 +370,14 @@ auto DXLabSuiteCommanderTransceiver::get_mode () -> MODE } else { - TRACE_CAT_POLL ("unexpected mode name" << mode); + TRACE_CAT_POLL ("unexpected mode name" << mode.toStdWString ()); throw error {tr ("DX Lab Suite Commander sent an unrecognised mode: \"") + mode + '"'}; } update_mode (m); } else { - TRACE_CAT_POLL ("unexpected response" << reply); + TRACE_CAT_POLL ("unexpected response" << reply.toStdWString ()); throw error {tr ("DX Lab Suite Commander didn't respond correctly polling mode: ") + reply}; } return m; @@ -387,11 +387,11 @@ void DXLabSuiteCommanderTransceiver::simple_command (QString const& cmd) { Q_ASSERT (commander_); - TRACE_CAT (cmd); + TRACE_CAT (cmd.toStdWString ()); if (!write_to_port (cmd)) { - TRACE_CAT ("failed:" << commander_->errorString ()); + TRACE_CAT ("failed:" << commander_->errorString ().toStdWString ()); throw error {tr ("DX Lab Suite Commander send command failed\n") + commander_->errorString ()}; } } @@ -402,7 +402,7 @@ QString DXLabSuiteCommanderTransceiver::command_with_reply (QString const& cmd) if (!write_to_port (cmd)) { - TRACE_CAT ("failed to send command:" << commander_->errorString ()); + TRACE_CAT ("failed to send command:" << commander_->errorString ().toStdWString ()); throw error { tr ("DX Lab Suite Commander send command failed \"%1\": %2\n") .arg (cmd) @@ -419,7 +419,7 @@ QString DXLabSuiteCommanderTransceiver::command_with_reply (QString const& cmd) replied = commander_->waitForReadyRead (); if (!replied && commander_->error () != commander_->SocketTimeoutError) { - TRACE_CAT (cmd << "failed to read reply:" << commander_->errorString ()); + TRACE_CAT (cmd.toStdWString () << "failed to read reply:" << commander_->errorString ().toStdWString ()); throw error { tr ("DX Lab Suite Commander send command \"%1\" read reply failed: %2\n") .arg (cmd) @@ -430,7 +430,7 @@ QString DXLabSuiteCommanderTransceiver::command_with_reply (QString const& cmd) if (!replied) { - TRACE_CAT (cmd << "retries exhausted"); + TRACE_CAT (cmd.toStdWString () << "retries exhausted"); throw error { tr ("DX Lab Suite Commander retries exhausted sending command \"%1\"") .arg (cmd) @@ -444,7 +444,7 @@ QString DXLabSuiteCommanderTransceiver::command_with_reply (QString const& cmd) // qDebug () << i << ":" << hex << int (result[i]); // } - TRACE_CAT (cmd << "->" << result); + TRACE_CAT (cmd.toStdWString () << "->" << QString {result}.toStdWString ()); return result; // converting raw UTF-8 bytes to QString } diff --git a/Transceiver/HRDTransceiver.cpp b/Transceiver/HRDTransceiver.cpp index cfa6f3f65..6a4c58f53 100644 --- a/Transceiver/HRDTransceiver.cpp +++ b/Transceiver/HRDTransceiver.cpp @@ -125,7 +125,7 @@ int HRDTransceiver::do_start () hrd_->connectToHost (std::get<0> (server_details), std::get<1> (server_details)); if (!hrd_->waitForConnected ()) { - TRACE_CAT ("failed to connect:" << hrd_->errorString ()); + TRACE_CAT ("failed to connect:" << hrd_->errorString ().toStdWString ()); throw error {tr ("Failed to connect to Ham Radio Deluxe\n") + hrd_->errorString ()}; } @@ -150,7 +150,7 @@ int HRDTransceiver::do_start () hrd_->connectToHost (std::get<0> (server_details), std::get<1> (server_details)); if (!hrd_->waitForConnected ()) { - TRACE_CAT ("failed to connect:" << hrd_->errorString ()); + TRACE_CAT ("failed to connect:" << hrd_->errorString ().toStdWString ()); throw error {tr ("Failed to connect to Ham Radio Deluxe\n") + hrd_->errorString ()}; } @@ -167,7 +167,7 @@ int HRDTransceiver::do_start () auto id = send_command ("get id", false, false); auto version = send_command ("get version", false, false); - TRACE_CAT ("Id:" << id << "Version:" << version); + TRACE_CAT ("Id:" << id.toStdWString () << "Version:" << version.toStdWString ()); HRD_info << "Id: " << id << "\n"; HRD_info << "Version: " << version << "\n"; @@ -189,7 +189,7 @@ int HRDTransceiver::do_start () TRACE_CAT ("radios:-"); Q_FOREACH (auto const& radio, radios_) { - TRACE_CAT ("\t[" << std::get<0> (radio) << "] " << std::get<1> (radio)); + TRACE_CAT ("\t[" << std::get<0> (radio) << "] " << std::get<1> (radio).toStdWString ()); } auto current_radio_name = send_command ("get radio", false, false); @@ -205,7 +205,7 @@ int HRDTransceiver::do_start () TRACE_CAT ("vfo count:" << vfo_count_); buttons_ = send_command ("get buttons").trimmed ().split (',', SkipEmptyParts).replaceInStrings (" ", "~"); - TRACE_CAT ("HRD Buttons: " << buttons_.join (", ")); + TRACE_CAT ("HRD Buttons: " << buttons_.join (", ").toStdWString ()); HRD_info << "Buttons: {" << buttons_.join (", ") << "}\n"; dropdown_names_ = send_command ("get dropdowns").trimmed ().split (',', SkipEmptyParts); @@ -214,7 +214,7 @@ int HRDTransceiver::do_start () Q_FOREACH (auto const& dd, dropdown_names_) { auto selections = send_command ("get dropdown-list {" + dd + "}").trimmed ().split (','); - TRACE_CAT ("\t" << dd << ": {" << selections.join (", ") << "}"); + TRACE_CAT ("\t" << dd.toStdWString () << ": {" << selections.join (", ").toStdWString () << "}"); HRD_info << "\t" << dd << ": {" << selections.join (", ") << "}\n"; dropdowns_[dd] = selections; } @@ -225,7 +225,7 @@ int HRDTransceiver::do_start () Q_FOREACH (auto const& s, slider_names_) { auto range = send_command ("get slider-range " + current_radio_name + " " + s).trimmed ().split (',', SkipEmptyParts); - TRACE_CAT ("\t" << s << ": {" << range.join (", ") << "}"); + TRACE_CAT ("\t" << s.toStdWString () << ": {" << range.join (", ").toStdWString () << "}"); HRD_info << "\t" << s << ": {" << range.join (", ") << "}\n"; sliders_[s] = range; } @@ -406,11 +406,11 @@ void HRDTransceiver::map_modes (int dropdown, ModeMap *map) map->push_back (std::forward_as_tuple (FM, find_dropdown_selection (dropdown, QRegExp ("^(FM|FM\\(N\\)|FM-N|WFM)$")))); map->push_back (std::forward_as_tuple (DIG_FM, find_dropdown_selection (dropdown, QRegExp ("^(PKT-FM|PKT|DATA\\(FM\\)|FM)$")))); - TRACE_CAT ("for dropdown" << dropdown_names_[dropdown]); + TRACE_CAT ("for dropdown" << dropdown_names_[dropdown].toStdWString ()); std::for_each (map->begin (), map->end (), [this, dropdown] (ModeMap::value_type const& item) { auto const& rhs = std::get<1> (item); - TRACE_CAT ('\t' << std::get<0> (item) << "<->" << (rhs.size () ? dropdowns_[dropdown_names_[dropdown]][rhs.front ()] : "None")); + TRACE_CAT ('\t' << std::get<0> (item) << "<->" << (rhs.size () ? dropdowns_[dropdown_names_[dropdown]][rhs.front ()].toStdWString () : L"None")); }); } @@ -472,7 +472,7 @@ void HRDTransceiver::set_dropdown (int dd, int value) } else { - TRACE_CAT ("item" << value << "not found in" << dd_name); + TRACE_CAT ("item" << value << "not found in" << dd_name.toStdWString ()); throw error {tr ("Ham Radio Deluxe: item not found in %1 dropdown list").arg (dd_name)}; } } @@ -1040,7 +1040,7 @@ QString HRDTransceiver::send_command (QString const& cmd, bool prepend_context, if (QTcpSocket::ConnectedState != hrd_->state ()) { - TRACE_CAT (cmd << "failed" << hrd_->errorString ()); + TRACE_CAT (cmd.toStdWString () << "failed" << hrd_->errorString ().toStdWString ()); throw error { tr ("Ham Radio Deluxe send command \"%1\" failed %2\n") .arg (cmd) @@ -1053,7 +1053,7 @@ QString HRDTransceiver::send_command (QString const& cmd, bool prepend_context, auto message = ((prepend_context ? context + cmd : cmd) + "\r").toLocal8Bit (); if (!write_to_port (message.constData (), message.size ())) { - TRACE_CAT ("failed to write command" << cmd << "to HRD"); + TRACE_CAT ("failed to write command" << cmd.toStdWString () << "to HRD"); throw error { tr ("Ham Radio Deluxe: failed to write command \"%1\"") .arg (cmd) @@ -1066,7 +1066,7 @@ QString HRDTransceiver::send_command (QString const& cmd, bool prepend_context, QScopedPointer message {new (string) HRDMessage}; if (!write_to_port (reinterpret_cast (message.data ()), message->size_)) { - TRACE_CAT ("failed to write command" << cmd << "to HRD"); + TRACE_CAT ("failed to write command" << cmd.toStdWString () << "to HRD"); throw error { tr ("Ham Radio Deluxe: failed to write command \"%1\"") .arg (cmd) @@ -1083,7 +1083,7 @@ QString HRDTransceiver::send_command (QString const& cmd, bool prepend_context, HRDMessage const * reply {new (buffer) HRDMessage}; if (reply->magic_1_value_ != reply->magic_1_ && reply->magic_2_value_ != reply->magic_2_) { - TRACE_CAT (cmd << "invalid reply"); + TRACE_CAT (cmd.toStdWString () << "invalid reply"); throw error { tr ("Ham Radio Deluxe sent an invalid reply to our command \"%1\"") .arg (cmd) @@ -1093,14 +1093,14 @@ QString HRDTransceiver::send_command (QString const& cmd, bool prepend_context, // keep reading until expected size arrives while (buffer.size () - offsetof (HRDMessage, size_) < reply->size_) { - TRACE_CAT (cmd << "reading more reply data"); + TRACE_CAT (cmd.toStdWString () << "reading more reply data"); buffer += read_reply (cmd); reply = new (buffer) HRDMessage; } result = QString {reply->payload_}; // this is not a memory leak (honest!) } - TRACE_CAT (cmd << " ->" << result); + TRACE_CAT (cmd.toStdWString () << " ->" << result.toStdWString ()); return result; } @@ -1131,7 +1131,7 @@ QByteArray HRDTransceiver::read_reply (QString const& cmd) replied = hrd_->waitForReadyRead (); if (!replied && hrd_->error () != hrd_->SocketTimeoutError) { - TRACE_CAT (cmd << "failed to reply" << hrd_->errorString ()); + TRACE_CAT (cmd.toStdWString () << "failed to reply" << hrd_->errorString ().toStdWString ()); throw error { tr ("Ham Radio Deluxe failed to reply to command \"%1\" %2\n") .arg (cmd) @@ -1141,7 +1141,7 @@ QByteArray HRDTransceiver::read_reply (QString const& cmd) } if (!replied) { - TRACE_CAT (cmd << "retries exhausted"); + TRACE_CAT (cmd.toStdWString () << "retries exhausted"); throw error { tr ("Ham Radio Deluxe retries exhausted sending command \"%1\"") .arg (cmd) @@ -1154,7 +1154,7 @@ void HRDTransceiver::send_simple_command (QString const& command) { if ("OK" != send_command (command)) { - TRACE_CAT (command << "unexpected response"); + TRACE_CAT (command.toStdWString () << "unexpected response"); throw error { tr ("Ham Radio Deluxe didn't respond to command \"%1\" as expected") .arg (command) diff --git a/Transceiver/HamlibTransceiver.cpp b/Transceiver/HamlibTransceiver.cpp index 766949b62..1f4660c8d 100644 --- a/Transceiver/HamlibTransceiver.cpp +++ b/Transceiver/HamlibTransceiver.cpp @@ -414,8 +414,8 @@ void HamlibTransceiver::error_check (int ret_code, QString const& doing) const int HamlibTransceiver::do_start () { - TRACE_CAT ("starting: " << QString::fromLatin1 (rig_->caps->mfg_name).trimmed () - << ": " << QString::fromLatin1 (rig_->caps->model_name).trimmed ()); + TRACE_CAT ("starting: " << rig_->caps->mfg_name + << ": " << rig_->caps->model_name); error_check (rig_open (rig_.data ()), tr ("opening connection to rig")); diff --git a/Transceiver/OmniRigTransceiver.cpp b/Transceiver/OmniRigTransceiver.cpp index 222db3402..928969bfa 100644 --- a/Transceiver/OmniRigTransceiver.cpp +++ b/Transceiver/OmniRigTransceiver.cpp @@ -152,8 +152,8 @@ int OmniRigTransceiver::do_start () , SIGNAL (CustomReply (int, QVariant const&, QVariant const&)) , this, SLOT (handle_custom_reply (int, QVariant const&, QVariant const&))); - TRACE_CAT ("OmniRig s/w version:" << QString::number (omni_rig_->SoftwareVersion ()).toLocal8Bit () - << "i/f version:" << QString::number (omni_rig_->InterfaceVersion ()).toLocal8Bit ()); + TRACE_CAT ("OmniRig s/w version:" << omni_rig_->SoftwareVersion () + << "i/f version:" << omni_rig_->InterfaceVersion ()); // fetch the interface of the RigX CoClass and instantiate a proxy object switch (rig_number_) @@ -212,7 +212,7 @@ int OmniRigTransceiver::do_start () .arg (rig_type_) .arg (readable_params_, 8, 16, QChar ('0')) .arg (writable_params_, 8, 16, QChar ('0')) - .arg (rig_number_).toLocal8Bit ()); + .arg (rig_number_).toStdWString ()); for (int i = 0; i < 5; ++i) { if (OmniRig::ST_ONLINE == rig_->Status ()) @@ -349,7 +349,7 @@ void OmniRigTransceiver::do_stop () void OmniRigTransceiver::handle_COM_exception (int code, QString source, QString desc, QString help) { - TRACE_CAT (QString::number (code) + " at " + source + ": " + desc + " (" + help + ')'); + TRACE_CAT ((QString::number (code) + " at " + source + ": " + desc + " (" + help + ')').toStdWString ()); throw_qstring (tr ("OmniRig COM/OLE error: %1 at %2: %3 (%4)").arg (QString::number (code)).arg (source). arg (desc). arg (help)); } @@ -371,18 +371,18 @@ void OmniRigTransceiver::handle_rig_type_change (int rig_number) .arg (rig_->RigType ()) .arg (readable_params_, 8, 16, QChar ('0')) .arg (writable_params_, 8, 16, QChar ('0')) - .arg (rig_number).toLocal8Bit ()); + .arg (rig_number).toStdWString ()); } } void OmniRigTransceiver::handle_status_change (int rig_number) { - TRACE_CAT (QString {"status change for rig %1"}.arg (rig_number).toLocal8Bit ()); + TRACE_CAT (QString {"status change for rig %1"}.arg (rig_number).toStdWString ()); if (rig_number_ == rig_number) { if (!rig_ || rig_->isNull ()) return; - auto const& status = rig_->StatusStr ().toLocal8Bit (); - TRACE_CAT ("OmniRig status change: new status = " << status); + auto const& status = rig_->StatusStr (); + TRACE_CAT ("OmniRig status change: new status = " << status.toStdWString ()); if (OmniRig::ST_ONLINE != rig_->Status ()) { if (!offline_timer_->isActive ()) @@ -411,7 +411,7 @@ void OmniRigTransceiver::handle_params_change (int rig_number, int params) { TRACE_CAT (QString {"params change: params = 0x%1 for rig %2"} .arg (params, 8, 16, QChar ('0')) - .arg (rig_number).toLocal8Bit () + .arg (rig_number).toStdWString () << "state before:" << state ()); if (rig_number_ == rig_number) { @@ -556,7 +556,7 @@ void OmniRigTransceiver::handle_params_change (int rig_number, int params) { auto f = readable_params_ & OmniRig::PM_FREQA ? rig_->FreqA () : rig_->Freq (); auto m = map_mode (rig_->Mode ()); - TRACE_CAT (QString {"VFOEQUAL f=%1 m=%2"}.arg (f).arg (m)); + TRACE_CAT (QString {"VFOEQUAL f=%1 m=%2"}.arg (f).arg (m).toStdWString ()); update_rx_frequency (f); update_other_frequency (f); update_mode (m); @@ -664,9 +664,9 @@ void OmniRigTransceiver::handle_custom_reply (int rig_number, QVariant const& co if (rig_number_ == rig_number) { if (!rig_ || rig_->isNull ()) return; - TRACE_CAT ("custom command" << command.toString ().toLocal8Bit () - << "with reply" << reply.toString ().toLocal8Bit () - << QString ("for rig %1").arg (rig_number).toLocal8Bit ()); + TRACE_CAT ("custom command" << command.toString ().toStdWString () + << "with reply" << reply.toString ().toStdWString () + << QString ("for rig %1").arg (rig_number).toStdWString ()); TRACE_CAT ("rig number:" << rig_number_ << ':' << state ()); } } diff --git a/Transceiver/Transceiver.cpp b/Transceiver/Transceiver.cpp index e240d151f..bc1f97ecf 100644 --- a/Transceiver/Transceiver.cpp +++ b/Transceiver/Transceiver.cpp @@ -23,14 +23,14 @@ QDebug operator << (QDebug d, Transceiver::TransceiverState const& s) } #endif -std::ostream& operator << (std::ostream& os, Transceiver::TransceiverState const& s) +std::wostream& operator << (std::wostream& os, Transceiver::TransceiverState const& s) { return os - << "Transceiver::TransceiverState(online: " << (s.online_ ? "yes" : "no") - << " Frequency {" << s.rx_frequency_ << "Hz, " << s.tx_frequency_ << "Hz} " << s.mode_ - << "; SPLIT: " << (Transceiver::TransceiverState::Split::on == s.split_ ? "on" : Transceiver::TransceiverState::Split::off == s.split_ ? "off" : "unknown") - << "; PTT: " << (s.ptt_ ? "on" : "off") - << ')'; + << L"Transceiver::TransceiverState(online: " << (s.online_ ? L"yes" : L"no") + << L" Frequency {" << s.rx_frequency_ << L"Hz, " << s.tx_frequency_ << L"Hz} " << s.mode_ + << L"; SPLIT: " << (Transceiver::TransceiverState::Split::on == s.split_ ? L"on" : Transceiver::TransceiverState::Split::off == s.split_ ? L"off" : L"unknown") + << L"; PTT: " << (s.ptt_ ? L"on" : L"off") + << L')'; } ENUM_QDATASTREAM_OPS_IMPL (Transceiver, MODE); diff --git a/Transceiver/Transceiver.hpp b/Transceiver/Transceiver.hpp index 655d11700..4175717cd 100644 --- a/Transceiver/Transceiver.hpp +++ b/Transceiver/Transceiver.hpp @@ -60,7 +60,7 @@ class Transceiver public: using Frequency = Radio::Frequency; - using logger_type = boost::log::sources::severity_channel_logger_mt; + using logger_type = boost::log::sources::wseverity_channel_logger_mt; protected: Transceiver (logger_type *, QObject * parent); @@ -115,7 +115,7 @@ public: friend QDebug operator << (QDebug, TransceiverState const&); friend bool operator != (TransceiverState const&, TransceiverState const&); - friend std::ostream& operator << (std::ostream&, Transceiver::TransceiverState const&); + friend std::wostream& operator << (std::wostream&, Transceiver::TransceiverState const&); }; // @@ -169,7 +169,7 @@ Q_DECLARE_METATYPE (Transceiver::TransceiverState); QDebug operator << (QDebug, Transceiver::TransceiverState const&); #endif -std::ostream& operator << (std::ostream&, Transceiver::TransceiverState const&); +std::wostream& operator << (std::wostream&, Transceiver::TransceiverState const&); ENUM_QDATASTREAM_OPS_DECL (Transceiver, MODE); ENUM_CONVERSION_OPS_DECL (Transceiver, MODE); diff --git a/Transceiver/TransceiverFactory.cpp b/Transceiver/TransceiverFactory.cpp index 7cc62bb4a..d2e8a956c 100644 --- a/Transceiver/TransceiverFactory.cpp +++ b/Transceiver/TransceiverFactory.cpp @@ -32,7 +32,7 @@ namespace } TransceiverFactory::TransceiverFactory () - : logger_ (boost::log::keywords::channel = "RIGCTRL") + : logger_ (boost::log::keywords::channel = L"RIGCTRL") { HamlibTransceiver::register_transceivers (&logger_, &transceivers_); DXLabSuiteCommanderTransceiver::register_transceivers (&logger_, &transceivers_, CommanderId); diff --git a/WSJTXLogging.cpp b/WSJTXLogging.cpp index c2bbda00a..aa6e39d3a 100644 --- a/WSJTXLogging.cpp +++ b/WSJTXLogging.cpp @@ -27,6 +27,7 @@ #include "qt_helpers.hpp" namespace logging = boost::log; +namespace trivial = logging::trivial; namespace keywords = logging::keywords; namespace expr = logging::expressions; namespace sinks = logging::sinks; @@ -99,7 +100,7 @@ WSJTXLogging::WSJTXLogging () std::stringbuf buffer {new_config.toStdString (), std::ios_base::in}; std::istream stream {&buffer}; Logger::init_from_config (stream); - LOG_INFO ("Unable to read logging configuration file: " << log_config.fileName ()); + LOG_INFO ("Unable to read logging configuration file: " << log_config.fileName ().toStdWString ()); } else // Default setup { @@ -107,10 +108,12 @@ WSJTXLogging::WSJTXLogging () // Define sinks, filters, and formatters using expression // templates for efficiency. // + // Default log file location. QDir app_data {QStandardPaths::writableLocation (QStandardPaths::AppLocalDataLocation)}; Logger::init (); // Basic setup of attributes auto core = logging::core::get (); + // // Sink intended for general use that passes everything above // selected severity levels per channel. Log file is appended @@ -126,6 +129,7 @@ WSJTXLogging::WSJTXLogging () , keywords::open_mode = std::ios_base::out | std::ios_base::app , keywords::enable_final_rotation = false ); + sys_sink->locked_backend ()->set_file_collector ( sinks::file::make_collector @@ -142,15 +146,16 @@ WSJTXLogging::WSJTXLogging () expr::stream << "[" << expr::format_date_time ("TimeStamp", "%Y-%m-%d %H:%M:%S.%f") << "][" << expr::format_date_time ("Uptime", "%O:%M:%S.%f") - << "][" << logging::trivial::severity + << "][" << trivial::severity << "] " << expr::message ); + core->add_sink (sys_sink); #if !defined (NDEBUG) && defined (Q_OS_WIN) - // auto windbg_sink = boost::make_shared> (); - // windbg_sink->set_filter (logging::trivial::severity >= logging::trivial::trace && expr::is_debugger_present ()); - // logging::core::get ()->add_sink (windbg_sink); + // auto windbg_sink = boost::make_shared> (); + // windbg_sink->set_filter (trivial::severity >= trivial::trace && expr::is_debugger_present ()); + // core->add_sink (windbg_sink); #endif } // Indicate start of logging @@ -169,14 +174,14 @@ WSJTXLogging::~WSJTXLogging () void WSJTXLogging::qt_log_handler (QtMsgType type, QMessageLogContext const& context, QString const& msg) { // Convert Qt message types to logger severities - auto severity = boost::log::trivial::trace; + auto severity = trivial::trace; switch (type) { - case QtDebugMsg: severity = boost::log::trivial::debug; break; - case QtInfoMsg: severity = boost::log::trivial::info; break; - case QtWarningMsg: severity = boost::log::trivial::warning; break; - case QtCriticalMsg: severity = boost::log::trivial::error; break; - case QtFatalMsg: severity = boost::log::trivial::fatal; break; + 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. @@ -187,15 +192,15 @@ void WSJTXLogging::qt_log_handler (QtMsgType type, QMessageLogContext const& con << boost::log::add_value ("Line", context.line) << boost::log::add_value ("File", context.file) << boost::log::add_value ("Function", context.function) - << msg.toStdString (); + << msg.toStdWString (); } else { - BOOST_LOG_CHANNEL_SEV (log, context.category, severity) + BOOST_LOG_CHANNEL_SEV (log, QString {context.category}.toStdWString (), severity) << boost::log::add_value ("Line", context.line) << boost::log::add_value ("File", context.file) << boost::log::add_value ("Function", context.function) - << msg.toStdString (); + << msg.toStdWString (); } if (QtFatalMsg == type) { diff --git a/WSJTXLogging.hpp b/WSJTXLogging.hpp index bd0a12157..d36e9afd2 100644 --- a/WSJTXLogging.hpp +++ b/WSJTXLogging.hpp @@ -16,7 +16,10 @@ public: // // Install this as the Qt message handler (qInstallMessageHandler) - // to integrate Qt messages. + // to integrate Qt messages. This handler can be installed at any + // time, it does not rely on an instance of WSJTXLogging existing, + // so logging occurring before the logging sinks, filters, and + // formatters, etc, are established can take place. static void qt_log_handler (QtMsgType type, QMessageLogContext const& context, QString const&); }; diff --git a/main.cpp b/main.cpp index a19004d05..a52ece821 100644 --- a/main.cpp +++ b/main.cpp @@ -209,7 +209,7 @@ int main(int argc, char *argv[]) } WSJTXLogging lg; - LOG_INFO (program_title (revision ()) << " - Program startup"); + LOG_INFO (program_title (revision ()).toStdWString () << L" - Program startup"); // load UI translations L10nLoader l10n {&a, locale, parser.value (lang_option)};