Revert to narrow character logging

This commit is contained in:
Bill Somerville 2020-09-27 16:52:19 +01:00
parent 6ab7889cd4
commit fe4c2b59ee
No known key found for this signature in database
GPG Key ID: D864B06D1E81618F
12 changed files with 94 additions and 94 deletions

View File

@ -2752,7 +2752,7 @@ void Configuration::impl::handle_transceiver_update (TransceiverState const& sta
void Configuration::impl::handle_transceiver_failure (QString const& reason) void Configuration::impl::handle_transceiver_failure (QString const& reason)
{ {
LOG_ERROR ("handle_transceiver_failure: reason: " << reason.toStdWString ()); LOG_ERROR ("handle_transceiver_failure: reason: " << reason);
close_rig (); close_rig ();
ui_->test_PTT_push_button->setChecked (false); ui_->test_PTT_push_button->setChecked (false);

View File

@ -67,7 +67,7 @@ L10nLoader::L10nLoader (QApplication * app, QLocale const& locale, QString const
.arg (QLocale::languageToString (locale.language ())) .arg (QLocale::languageToString (locale.language ()))
.arg (QLocale::scriptToString (locale.script ())) .arg (QLocale::scriptToString (locale.script ()))
.arg (QLocale::countryToString (locale.country ())) .arg (QLocale::countryToString (locale.country ()))
.arg (locale.uiLanguages ().join (", ")).toStdWString ()); .arg (locale.uiLanguages ().join (", ")));
// we don't load translators if the language override is 'en', // 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 // 'en_US', or 'en-US'. In these cases we assume the user is trying
@ -105,12 +105,12 @@ L10nLoader::L10nLoader (QApplication * app, QLocale const& locale, QString const
auto language = locale_name.left (2); auto language = locale_name.left (2);
if (locale.uiLanguages ().front ().left (2) == language) if (locale.uiLanguages ().front ().left (2) == language)
{ {
LOG_TRACE (QString {"Trying %1"}.arg (language).toStdWString ()); LOG_TRACE (QString {"Trying %1"}.arg (language));
if (m_->load_translator ("wsjtx_" + language, translations_dir)) if (m_->load_translator ("wsjtx_" + language, translations_dir))
{ {
LOG_INFO (QString {"Loaded WSJT-X base translation file from %1 based on language %2"} LOG_INFO (QString {"Loaded WSJT-X base translation file from %1 based on language %2"}
.arg (translations_dir) .arg (translations_dir)
.arg (language).toStdWString ()); .arg (language));
break; break;
} }
} }
@ -141,7 +141,7 @@ L10nLoader::L10nLoader (QApplication * app, QLocale const& locale, QString const
{ {
LOG_INFO (QString {"Loaded base translation file from %1 based on language %2"} LOG_INFO (QString {"Loaded base translation file from %1 based on language %2"}
.arg (translations_dir) .arg (translations_dir)
.arg (base_language).toStdWString ()); .arg (base_language));
} }
// now load the requested translations (may be a duplicate // now load the requested translations (may be a duplicate
// but we shouldn't care) // but we shouldn't care)
@ -150,7 +150,7 @@ L10nLoader::L10nLoader (QApplication * app, QLocale const& locale, QString const
{ {
LOG_INFO (QString {"Loaded translation file from %1 based on language %2"} LOG_INFO (QString {"Loaded translation file from %1 based on language %2"}
.arg (translations_dir) .arg (translations_dir)
.arg (language).toStdWString ()); .arg (language));
} }
} }
@ -169,10 +169,10 @@ L10nLoader::L10nLoader (QApplication * app, QLocale const& locale, QString const
auto language = locale_name.left (2); auto language = locale_name.left (2);
if (locale.uiLanguages ().front ().left (2) == language) if (locale.uiLanguages ().front ().left (2) == language)
{ {
LOG_TRACE (QString {"Trying %1"}.arg (language).toStdWString ()); LOG_TRACE (QString {"Trying %1"}.arg (language));
if (m_->load_translator ("wsjtx_" + language)) if (m_->load_translator ("wsjtx_" + language))
{ {
LOG_INFO (QString {"Loaded base translation file from $cwd based on language %1"}.arg (language).toStdWString ()); LOG_INFO (QString {"Loaded base translation file from $cwd based on language %1"}.arg (language));
break; break;
} }
} }
@ -204,14 +204,14 @@ L10nLoader::L10nLoader (QApplication * app, QLocale const& locale, QString const
LOG_TRACE ("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)) if (m_->load_translator ("wsjtx_" + base_language))
{ {
LOG_INFO (QString {"Loaded base translation file from $cwd based on language %1"}.arg (base_language).toStdWString ()); LOG_INFO (QString {"Loaded base translation file from $cwd based on language %1"}.arg (base_language));
} }
// now load the requested translations (may be a duplicate // now load the requested translations (may be a duplicate
// but we shouldn't care) // but we shouldn't care)
LOG_TRACE ("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)) if (m_->load_translator ("wsjtx_" + language))
{ {
LOG_INFO (QString {"loaded translation file from $cwd based on language %1"}.arg (language).toStdWString ()); LOG_INFO (QString {"loaded translation file from $cwd based on language %1"}.arg (language));
} }
} }
} }

View File

@ -34,11 +34,11 @@ namespace ptime = boost::posix_time;
namespace Logger namespace Logger
{ {
BOOST_LOG_GLOBAL_LOGGER_CTOR_ARGS (sys, BOOST_LOG_GLOBAL_LOGGER_CTOR_ARGS (sys,
srcs::wseverity_channel_logger_mt<logging::trivial::severity_level>, srcs::severity_channel_logger_mt<logging::trivial::severity_level>,
(keywords::channel = L"SYSLOG")); (keywords::channel = "SYSLOG"));
BOOST_LOG_GLOBAL_LOGGER_CTOR_ARGS (data, BOOST_LOG_GLOBAL_LOGGER_CTOR_ARGS (data,
srcs::wseverity_channel_logger_mt<logging::trivial::severity_level>, srcs::severity_channel_logger_mt<logging::trivial::severity_level>,
(keywords::channel = L"DATALOG")); (keywords::channel = "DATALOG"));
namespace namespace
{ {
@ -149,21 +149,21 @@ namespace Logger
void add_datafile_log (std::string const& log_file_name) void add_datafile_log (std::string const& log_file_name)
{ {
// Create a text file sink // Create a text file sink
boost::shared_ptr<sinks::wtext_ostream_backend> backend boost::shared_ptr<sinks::text_ostream_backend> backend
( (
new sinks::wtext_ostream_backend() new sinks::text_ostream_backend()
); );
backend->add_stream (boost::shared_ptr<std::wostream> (new std::wofstream (log_file_name))); backend->add_stream (boost::shared_ptr<std::ostream> (new std::ofstream (log_file_name)));
// Flush after each log record // Flush after each log record
backend->auto_flush (true); backend->auto_flush (true);
// Create a sink for the backend // Create a sink for the backend
typedef sinks::synchronous_sink<sinks::wtext_ostream_backend> sink_t; typedef sinks::synchronous_sink<sinks::text_ostream_backend> sink_t;
boost::shared_ptr<sink_t> sink (new sink_t (backend)); boost::shared_ptr<sink_t> sink (new sink_t (backend));
// The log output formatter // The log output formatter
sink->set_formatter (expr::format (L"[%1%][%2%] %3%") sink->set_formatter (expr::format ("[%1%][%2%] %3%")
% expr::attr<ptime::ptime> ("TimeStamp") % expr::attr<ptime::ptime> ("TimeStamp")
% logging::trivial::severity % logging::trivial::severity
% expr::message % expr::message

View File

@ -13,9 +13,9 @@
namespace Logger namespace Logger
{ {
BOOST_LOG_GLOBAL_LOGGER (sys, BOOST_LOG_GLOBAL_LOGGER (sys,
boost::log::sources::wseverity_channel_logger_mt<boost::log::trivial::severity_level>); boost::log::sources::severity_channel_logger_mt<boost::log::trivial::severity_level>);
BOOST_LOG_GLOBAL_LOGGER (data, BOOST_LOG_GLOBAL_LOGGER (data,
boost::log::sources::wseverity_channel_logger_mt<boost::log::trivial::severity_level>); boost::log::sources::severity_channel_logger_mt<boost::log::trivial::severity_level>);
// trivial logging to console // trivial logging to console
void init (); void init ();

View File

@ -71,7 +71,7 @@ int DXLabSuiteCommanderTransceiver::do_start ()
commander_->connectToHost (std::get<0> (server_details), std::get<1> (server_details)); commander_->connectToHost (std::get<0> (server_details), std::get<1> (server_details));
if (!commander_->waitForConnected ()) if (!commander_->waitForConnected ())
{ {
CAT_ERROR ("failed to connect" << commander_->errorString ().toStdWString ()); CAT_ERROR ("failed to connect" << commander_->errorString ());
throw error {tr ("Failed to connect to DX Lab Suite Commander\n") + commander_->errorString ()}; throw error {tr ("Failed to connect to DX Lab Suite Commander\n") + commander_->errorString ()};
} }
@ -127,7 +127,7 @@ int DXLabSuiteCommanderTransceiver::do_start ()
} }
else else
{ {
CAT_ERROR ("get frequency unexpected response" << reply.toStdWString ()); CAT_ERROR ("get frequency unexpected response" << reply);
throw error {tr ("DX Lab Suite Commander didn't respond correctly reading frequency: ") + reply}; 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 else
{ {
CAT_ERROR ("unexpected TX state" << state.toStdWString ()); CAT_ERROR ("unexpected TX state" << state);
throw error {tr ("DX Lab Suite Commander sent an unrecognised TX state: ") + state}; throw error {tr ("DX Lab Suite Commander sent an unrecognised TX state: ") + state};
} }
} }
else else
{ {
CAT_ERROR ("get TX unexpected response" << reply.toStdWString ()); CAT_ERROR ("get TX unexpected response" << reply);
throw error {tr ("DX Lab Suite Commander didn't respond correctly polling TX status: ") + reply}; 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 if (tx != on) QThread::msleep (10); // don't thrash Commander
@ -268,7 +268,7 @@ void DXLabSuiteCommanderTransceiver::do_poll ()
} }
else else
{ {
CAT_ERROR ("get frequency unexpected response" << reply.toStdWString ()); CAT_ERROR ("get frequency unexpected response" << reply);
throw error {tr ("DX Lab Suite Commander didn't respond correctly polling frequency: ") + reply}; throw error {tr ("DX Lab Suite Commander didn't respond correctly polling frequency: ") + reply};
} }
@ -289,7 +289,7 @@ void DXLabSuiteCommanderTransceiver::do_poll ()
} }
else else
{ {
CAT_ERROR ("get tx frequency unexpected response" << reply.toStdWString ()); CAT_ERROR ("get tx frequency unexpected response" << reply);
throw error {tr ("DX Lab Suite Commander didn't respond correctly polling TX frequency: ") + reply}; throw error {tr ("DX Lab Suite Commander didn't respond correctly polling TX frequency: ") + reply};
} }
} }
@ -308,13 +308,13 @@ void DXLabSuiteCommanderTransceiver::do_poll ()
} }
else else
{ {
CAT_ERROR ("unexpected split state" << split.toStdWString ()); CAT_ERROR ("unexpected split state" << split);
throw error {tr ("DX Lab Suite Commander sent an unrecognised split state: ") + split}; throw error {tr ("DX Lab Suite Commander sent an unrecognised split state: ") + split};
} }
} }
else else
{ {
CAT_ERROR ("get split mode unexpected response" << reply.toStdWString ()); CAT_ERROR ("get split mode unexpected response" << reply);
throw error {tr ("DX Lab Suite Commander didn't respond correctly polling split status: ") + reply}; 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 else
{ {
CAT_ERROR ("unexpected mode name" << mode.toStdWString ()); CAT_ERROR ("unexpected mode name" << mode);
throw error {tr ("DX Lab Suite Commander sent an unrecognised mode: \"") + mode + '"'}; throw error {tr ("DX Lab Suite Commander sent an unrecognised mode: \"") + mode + '"'};
} }
update_mode (m); update_mode (m);
} }
else else
{ {
CAT_ERROR ("unexpected response" << reply.toStdWString ()); CAT_ERROR ("unexpected response" << reply);
throw error {tr ("DX Lab Suite Commander didn't respond correctly polling mode: ") + reply}; throw error {tr ("DX Lab Suite Commander didn't respond correctly polling mode: ") + reply};
} }
return m; return m;
@ -387,11 +387,11 @@ void DXLabSuiteCommanderTransceiver::simple_command (QString const& cmd)
{ {
Q_ASSERT (commander_); Q_ASSERT (commander_);
CAT_TRACE (cmd.toStdWString ()); CAT_TRACE (cmd);
if (!write_to_port (cmd)) if (!write_to_port (cmd))
{ {
CAT_ERROR ("failed:" << commander_->errorString ().toStdWString ()); CAT_ERROR ("failed:" << commander_->errorString ());
throw error {tr ("DX Lab Suite Commander send command failed\n") + commander_->errorString ()}; 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)) if (!write_to_port (cmd))
{ {
CAT_ERROR ("failed to send command:" << commander_->errorString ().toStdWString ()); CAT_ERROR ("failed to send command:" << commander_->errorString ());
throw error { throw error {
tr ("DX Lab Suite Commander send command failed \"%1\": %2\n") tr ("DX Lab Suite Commander send command failed \"%1\": %2\n")
.arg (cmd) .arg (cmd)
@ -419,7 +419,7 @@ QString DXLabSuiteCommanderTransceiver::command_with_reply (QString const& cmd)
replied = commander_->waitForReadyRead (); replied = commander_->waitForReadyRead ();
if (!replied && commander_->error () != commander_->SocketTimeoutError) if (!replied && commander_->error () != commander_->SocketTimeoutError)
{ {
CAT_ERROR (cmd.toStdWString () << "failed to read reply:" << commander_->errorString ().toStdWString ()); CAT_ERROR (cmd << "failed to read reply:" << commander_->errorString ());
throw error { throw error {
tr ("DX Lab Suite Commander send command \"%1\" read reply failed: %2\n") tr ("DX Lab Suite Commander send command \"%1\" read reply failed: %2\n")
.arg (cmd) .arg (cmd)
@ -430,7 +430,7 @@ QString DXLabSuiteCommanderTransceiver::command_with_reply (QString const& cmd)
if (!replied) if (!replied)
{ {
CAT_ERROR (cmd.toStdWString () << "retries exhausted"); CAT_ERROR (cmd << "retries exhausted");
throw error { throw error {
tr ("DX Lab Suite Commander retries exhausted sending command \"%1\"") tr ("DX Lab Suite Commander retries exhausted sending command \"%1\"")
.arg (cmd) .arg (cmd)
@ -444,7 +444,7 @@ QString DXLabSuiteCommanderTransceiver::command_with_reply (QString const& cmd)
// qDebug () << i << ":" << hex << int (result[i]); // qDebug () << i << ":" << hex << int (result[i]);
// } // }
CAT_TRACE (cmd.toStdWString () << "->" << QString {result}.toStdWString ()); CAT_TRACE (cmd << "->" << QString {result});
return result; // converting raw UTF-8 bytes to QString return result; // converting raw UTF-8 bytes to QString
} }

View File

@ -125,7 +125,7 @@ int HRDTransceiver::do_start ()
hrd_->connectToHost (std::get<0> (server_details), std::get<1> (server_details)); hrd_->connectToHost (std::get<0> (server_details), std::get<1> (server_details));
if (!hrd_->waitForConnected ()) if (!hrd_->waitForConnected ())
{ {
CAT_ERROR ("failed to connect:" << hrd_->errorString ().toStdWString ()); CAT_ERROR ("failed to connect:" << hrd_->errorString ());
throw error {tr ("Failed to connect to Ham Radio Deluxe\n") + hrd_->errorString ()}; 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)); hrd_->connectToHost (std::get<0> (server_details), std::get<1> (server_details));
if (!hrd_->waitForConnected ()) if (!hrd_->waitForConnected ())
{ {
CAT_ERROR ("failed to connect:" << hrd_->errorString ().toStdWString ()); CAT_ERROR ("failed to connect:" << hrd_->errorString ());
throw error {tr ("Failed to connect to Ham Radio Deluxe\n") + hrd_->errorString ()}; 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 id = send_command ("get id", false, false);
auto version = send_command ("get version", false, false); auto version = send_command ("get version", false, false);
CAT_INFO ("Id: " << id.toStdWString () << "Version: " << version.toStdWString ()); CAT_INFO ("Id: " << id << "Version: " << version);
HRD_info << "Id: " << id << "\n"; HRD_info << "Id: " << id << "\n";
HRD_info << "Version: " << version << "\n"; HRD_info << "Version: " << version << "\n";
@ -189,7 +189,7 @@ int HRDTransceiver::do_start ()
CAT_TRACE ("radios:-"); CAT_TRACE ("radios:-");
Q_FOREACH (auto const& radio, radios_) Q_FOREACH (auto const& radio, radios_)
{ {
CAT_TRACE ("\t[" << std::get<0> (radio) << "] " << std::get<1> (radio).toStdWString ()); CAT_TRACE ("\t[" << std::get<0> (radio) << "] " << std::get<1> (radio));
} }
auto current_radio_name = send_command ("get radio", false, false); auto current_radio_name = send_command ("get radio", false, false);
@ -205,7 +205,7 @@ int HRDTransceiver::do_start ()
CAT_TRACE ("vfo count:" << vfo_count_); CAT_TRACE ("vfo count:" << vfo_count_);
buttons_ = send_command ("get buttons").trimmed ().split (',', SkipEmptyParts).replaceInStrings (" ", "~"); buttons_ = send_command ("get buttons").trimmed ().split (',', SkipEmptyParts).replaceInStrings (" ", "~");
CAT_TRACE ("HRD Buttons: " << buttons_.join (", ").toStdWString ()); CAT_TRACE ("HRD Buttons: " << buttons_.join (", "));
HRD_info << "Buttons: {" << buttons_.join (", ") << "}\n"; HRD_info << "Buttons: {" << buttons_.join (", ") << "}\n";
dropdown_names_ = send_command ("get dropdowns").trimmed ().split (',', SkipEmptyParts); dropdown_names_ = send_command ("get dropdowns").trimmed ().split (',', SkipEmptyParts);
@ -214,7 +214,7 @@ int HRDTransceiver::do_start ()
Q_FOREACH (auto const& dd, dropdown_names_) Q_FOREACH (auto const& dd, dropdown_names_)
{ {
auto selections = send_command ("get dropdown-list {" + dd + "}").trimmed ().split (','); auto selections = send_command ("get dropdown-list {" + dd + "}").trimmed ().split (',');
CAT_TRACE ("\t" << dd.toStdWString () << ": {" << selections.join (", ").toStdWString () << "}"); CAT_TRACE ("\t" << dd << ": {" << selections.join (", ") << "}");
HRD_info << "\t" << dd << ": {" << selections.join (", ") << "}\n"; HRD_info << "\t" << dd << ": {" << selections.join (", ") << "}\n";
dropdowns_[dd] = selections; dropdowns_[dd] = selections;
} }
@ -225,7 +225,7 @@ int HRDTransceiver::do_start ()
Q_FOREACH (auto const& s, slider_names_) Q_FOREACH (auto const& s, slider_names_)
{ {
auto range = send_command ("get slider-range " + current_radio_name + " " + s).trimmed ().split (',', SkipEmptyParts); auto range = send_command ("get slider-range " + current_radio_name + " " + s).trimmed ().split (',', SkipEmptyParts);
CAT_TRACE ("\t" << s.toStdWString () << ": {" << range.join (", ").toStdWString () << "}"); CAT_TRACE ("\t" << s << ": {" << range.join (", ") << "}");
HRD_info << "\t" << s << ": {" << range.join (", ") << "}\n"; HRD_info << "\t" << s << ": {" << range.join (", ") << "}\n";
sliders_[s] = range; 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 (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)$")))); 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].toStdWString ()); CAT_TRACE ("for dropdown" << dropdown_names_[dropdown]);
std::for_each (map->begin (), map->end (), [this, dropdown] (ModeMap::value_type const& item) std::for_each (map->begin (), map->end (), [this, dropdown] (ModeMap::value_type const& item)
{ {
auto const& rhs = std::get<1> (item); auto const& rhs = std::get<1> (item);
CAT_TRACE ('\t' << std::get<0> (item) << "<->" << (rhs.size () ? dropdowns_[dropdown_names_[dropdown]][rhs.front ()].toStdWString () : L"None")); CAT_TRACE ('\t' << std::get<0> (item) << "<->" << (rhs.size () ? dropdowns_[dropdown_names_[dropdown]][rhs.front ()] : "None"));
}); });
} }
@ -472,7 +472,7 @@ void HRDTransceiver::set_dropdown (int dd, int value)
} }
else else
{ {
CAT_ERROR ("item" << value << "not found in" << dd_name.toStdWString ()); CAT_ERROR ("item" << value << "not found in" << dd_name);
throw error {tr ("Ham Radio Deluxe: item not found in %1 dropdown list").arg (dd_name)}; 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 ()) if (QTcpSocket::ConnectedState != hrd_->state ())
{ {
CAT_ERROR (cmd.toStdWString () << "failed" << hrd_->errorString ().toStdWString ()); CAT_ERROR (cmd << "failed" << hrd_->errorString ());
throw error { throw error {
tr ("Ham Radio Deluxe send command \"%1\" failed %2\n") tr ("Ham Radio Deluxe send command \"%1\" failed %2\n")
.arg (cmd) .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 (); auto message = ((prepend_context ? context + cmd : cmd) + "\r").toLocal8Bit ();
if (!write_to_port (message.constData (), message.size ())) if (!write_to_port (message.constData (), message.size ()))
{ {
CAT_ERROR ("failed to write command" << cmd.toStdWString () << "to HRD"); CAT_ERROR ("failed to write command" << cmd << "to HRD");
throw error { throw error {
tr ("Ham Radio Deluxe: failed to write command \"%1\"") tr ("Ham Radio Deluxe: failed to write command \"%1\"")
.arg (cmd) .arg (cmd)
@ -1066,7 +1066,7 @@ QString HRDTransceiver::send_command (QString const& cmd, bool prepend_context,
QScopedPointer<HRDMessage> message {new (string) HRDMessage}; QScopedPointer<HRDMessage> message {new (string) HRDMessage};
if (!write_to_port (reinterpret_cast<char const *> (message.data ()), message->size_)) if (!write_to_port (reinterpret_cast<char const *> (message.data ()), message->size_))
{ {
CAT_ERROR ("failed to write command" << cmd.toStdWString () << "to HRD"); CAT_ERROR ("failed to write command" << cmd << "to HRD");
throw error { throw error {
tr ("Ham Radio Deluxe: failed to write command \"%1\"") tr ("Ham Radio Deluxe: failed to write command \"%1\"")
.arg (cmd) .arg (cmd)
@ -1083,7 +1083,7 @@ QString HRDTransceiver::send_command (QString const& cmd, bool prepend_context,
HRDMessage const * reply {new (buffer) HRDMessage}; HRDMessage const * reply {new (buffer) HRDMessage};
if (reply->magic_1_value_ != reply->magic_1_ && reply->magic_2_value_ != reply->magic_2_) if (reply->magic_1_value_ != reply->magic_1_ && reply->magic_2_value_ != reply->magic_2_)
{ {
CAT_ERROR (cmd.toStdWString () << "invalid reply"); CAT_ERROR (cmd << "invalid reply");
throw error { throw error {
tr ("Ham Radio Deluxe sent an invalid reply to our command \"%1\"") tr ("Ham Radio Deluxe sent an invalid reply to our command \"%1\"")
.arg (cmd) .arg (cmd)
@ -1093,14 +1093,14 @@ QString HRDTransceiver::send_command (QString const& cmd, bool prepend_context,
// keep reading until expected size arrives // keep reading until expected size arrives
while (buffer.size () - offsetof (HRDMessage, size_) < reply->size_) while (buffer.size () - offsetof (HRDMessage, size_) < reply->size_)
{ {
CAT_TRACE (cmd.toStdWString () << "reading more reply data"); CAT_TRACE (cmd << "reading more reply data");
buffer += read_reply (cmd); buffer += read_reply (cmd);
reply = new (buffer) HRDMessage; reply = new (buffer) HRDMessage;
} }
result = QString {reply->payload_}; // this is not a memory leak (honest!) result = QString {reply->payload_}; // this is not a memory leak (honest!)
} }
CAT_TRACE (cmd.toStdWString () << " ->" << result.toStdWString ()); CAT_TRACE (cmd << " ->" << result);
return result; return result;
} }
@ -1131,7 +1131,7 @@ QByteArray HRDTransceiver::read_reply (QString const& cmd)
replied = hrd_->waitForReadyRead (); replied = hrd_->waitForReadyRead ();
if (!replied && hrd_->error () != hrd_->SocketTimeoutError) if (!replied && hrd_->error () != hrd_->SocketTimeoutError)
{ {
CAT_ERROR (cmd.toStdWString () << "failed to reply" << hrd_->errorString ().toStdWString ()); CAT_ERROR (cmd << "failed to reply" << hrd_->errorString ());
throw error { throw error {
tr ("Ham Radio Deluxe failed to reply to command \"%1\" %2\n") tr ("Ham Radio Deluxe failed to reply to command \"%1\" %2\n")
.arg (cmd) .arg (cmd)
@ -1141,7 +1141,7 @@ QByteArray HRDTransceiver::read_reply (QString const& cmd)
} }
if (!replied) if (!replied)
{ {
CAT_ERROR (cmd.toStdWString () << "retries exhausted"); CAT_ERROR (cmd << "retries exhausted");
throw error { throw error {
tr ("Ham Radio Deluxe retries exhausted sending command \"%1\"") tr ("Ham Radio Deluxe retries exhausted sending command \"%1\"")
.arg (cmd) .arg (cmd)
@ -1154,7 +1154,7 @@ void HRDTransceiver::send_simple_command (QString const& command)
{ {
if ("OK" != send_command (command)) if ("OK" != send_command (command))
{ {
CAT_ERROR (command.toStdWString () << "unexpected response"); CAT_ERROR (command << "unexpected response");
throw error { throw error {
tr ("Ham Radio Deluxe didn't respond to command \"%1\" as expected") tr ("Ham Radio Deluxe didn't respond to command \"%1\" as expected")
.arg (command) .arg (command)

View File

@ -212,7 +212,7 @@ int OmniRigTransceiver::do_start ()
.arg (rig_type_) .arg (rig_type_)
.arg (readable_params_, 8, 16, QChar ('0')) .arg (readable_params_, 8, 16, QChar ('0'))
.arg (writable_params_, 8, 16, QChar ('0')) .arg (writable_params_, 8, 16, QChar ('0'))
.arg (rig_number_).toStdWString ()); .arg (rig_number_));
for (int i = 0; i < 5; ++i) for (int i = 0; i < 5; ++i)
{ {
if (OmniRig::ST_ONLINE == rig_->Status ()) 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) void OmniRigTransceiver::handle_COM_exception (int code, QString source, QString desc, QString help)
{ {
CAT_ERROR ((QString::number (code) + " at " + source + ": " + desc + " (" + help + ')').toStdWString ()); CAT_ERROR ((QString::number (code) + " at " + source + ": " + desc + " (" + help + ')'));
throw_qstring (tr ("OmniRig COM/OLE error: %1 at %2: %3 (%4)").arg (QString::number (code)).arg (source). arg (desc). arg (help)); 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 (rig_->RigType ())
.arg (readable_params_, 8, 16, QChar ('0')) .arg (readable_params_, 8, 16, QChar ('0'))
.arg (writable_params_, 8, 16, QChar ('0')) .arg (writable_params_, 8, 16, QChar ('0'))
.arg (rig_number).toStdWString ()); .arg (rig_number));
} }
} }
void OmniRigTransceiver::handle_status_change (int rig_number) void OmniRigTransceiver::handle_status_change (int rig_number)
{ {
CAT_TRACE (QString {"status change for rig %1"}.arg (rig_number).toStdWString ()); CAT_TRACE (QString {"status change for rig %1"}.arg (rig_number));
if (rig_number_ == rig_number) if (rig_number_ == rig_number)
{ {
if (!rig_ || rig_->isNull ()) return; if (!rig_ || rig_->isNull ()) return;
auto const& status = rig_->StatusStr (); auto const& status = rig_->StatusStr ();
CAT_TRACE ("OmniRig status change: new status = " << status.toStdWString ()); CAT_TRACE ("OmniRig status change: new status = " << status);
if (OmniRig::ST_ONLINE != rig_->Status ()) if (OmniRig::ST_ONLINE != rig_->Status ())
{ {
if (!offline_timer_->isActive ()) if (!offline_timer_->isActive ())
@ -411,7 +411,7 @@ void OmniRigTransceiver::handle_params_change (int rig_number, int params)
{ {
CAT_TRACE (QString {"params change: params=0x%1 for rig %2"} CAT_TRACE (QString {"params change: params=0x%1 for rig %2"}
.arg (params, 8, 16, QChar ('0')) .arg (params, 8, 16, QChar ('0'))
.arg (rig_number).toStdWString () .arg (rig_number)
<< "state before:" << state ()); << "state before:" << state ());
if (rig_number_ == rig_number) 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 f = readable_params_ & OmniRig::PM_FREQA ? rig_->FreqA () : rig_->Freq ();
auto m = map_mode (rig_->Mode ()); auto m = map_mode (rig_->Mode ());
CAT_TRACE (QString {"VFOEQUAL f=%1 m=%2"}.arg (f).arg (m).toStdWString ()); CAT_TRACE (QString {"VFOEQUAL f=%1 m=%2"}.arg (f).arg (m));
update_rx_frequency (f); update_rx_frequency (f);
update_other_frequency (f); update_other_frequency (f);
update_mode (m); 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_number_ == rig_number)
{ {
if (!rig_ || rig_->isNull ()) return; if (!rig_ || rig_->isNull ()) return;
CAT_TRACE ("custom command" << command.toString ().toStdWString () CAT_TRACE ("custom command" << command.toString ()
<< "with reply" << reply.toString ().toStdWString () << "with reply" << reply.toString ()
<< QString ("for rig %1").arg (rig_number).toStdWString ()); << QString ("for rig %1").arg (rig_number));
CAT_TRACE ("rig number:" << rig_number_ << ':' << state ()); CAT_TRACE ("rig number:" << rig_number_ << ':' << state ());
} }
} }

View File

@ -23,14 +23,14 @@ QDebug operator << (QDebug d, Transceiver::TransceiverState const& s)
} }
#endif #endif
std::wostream& operator << (std::wostream& os, Transceiver::TransceiverState const& s) std::ostream& operator << (std::ostream& os, Transceiver::TransceiverState const& s)
{ {
return os return os
<< L"Transceiver::TransceiverState(online: " << (s.online_ ? L"yes" : L"no") << "Transceiver::TransceiverState(online: " << (s.online_ ? "yes" : "no")
<< L" Frequency {" << s.rx_frequency_ << L"Hz, " << s.tx_frequency_ << L"Hz} " << s.mode_ << " Frequency {" << s.rx_frequency_ << "Hz, " << s.tx_frequency_ << "Hz} " << s.mode_
<< L"; SPLIT: " << (Transceiver::TransceiverState::Split::on == s.split_ ? L"on" : Transceiver::TransceiverState::Split::off == s.split_ ? L"off" : L"unknown") << "; SPLIT: " << (Transceiver::TransceiverState::Split::on == s.split_ ? "on" : Transceiver::TransceiverState::Split::off == s.split_ ? "off" : "unknown")
<< L"; PTT: " << (s.ptt_ ? L"on" : L"off") << "; PTT: " << (s.ptt_ ? "on" : "off")
<< L')'; << ')';
} }
ENUM_QDATASTREAM_OPS_IMPL (Transceiver, MODE); ENUM_QDATASTREAM_OPS_IMPL (Transceiver, MODE);

View File

@ -60,7 +60,7 @@ class Transceiver
public: public:
using Frequency = Radio::Frequency; using Frequency = Radio::Frequency;
using logger_type = boost::log::sources::wseverity_channel_logger_mt<boost::log::trivial::severity_level>; using logger_type = boost::log::sources::severity_channel_logger_mt<boost::log::trivial::severity_level>;
protected: protected:
Transceiver (logger_type *, QObject * parent); Transceiver (logger_type *, QObject * parent);
@ -115,7 +115,7 @@ public:
friend QDebug operator << (QDebug, TransceiverState const&); friend QDebug operator << (QDebug, TransceiverState const&);
friend bool operator != (TransceiverState const&, TransceiverState const&); friend bool operator != (TransceiverState const&, TransceiverState const&);
friend std::wostream& operator << (std::wostream&, Transceiver::TransceiverState const&); friend std::ostream& operator << (std::ostream&, Transceiver::TransceiverState const&);
}; };
// //
@ -169,7 +169,7 @@ Q_DECLARE_METATYPE (Transceiver::TransceiverState);
QDebug operator << (QDebug, Transceiver::TransceiverState const&); QDebug operator << (QDebug, Transceiver::TransceiverState const&);
#endif #endif
std::wostream& operator << (std::wostream&, Transceiver::TransceiverState const&); std::ostream& operator << (std::ostream&, Transceiver::TransceiverState const&);
ENUM_QDATASTREAM_OPS_DECL (Transceiver, MODE); ENUM_QDATASTREAM_OPS_DECL (Transceiver, MODE);
ENUM_CONVERSION_OPS_DECL (Transceiver, MODE); ENUM_CONVERSION_OPS_DECL (Transceiver, MODE);

View File

@ -32,7 +32,7 @@ namespace
} }
TransceiverFactory::TransceiverFactory () TransceiverFactory::TransceiverFactory ()
: logger_ (boost::log::keywords::channel = L"RIGCTRL") : logger_ (boost::log::keywords::channel = "RIGCTRL")
{ {
HamlibTransceiver::register_transceivers (&logger_, &transceivers_); HamlibTransceiver::register_transceivers (&logger_, &transceivers_);
DXLabSuiteCommanderTransceiver::register_transceivers (&logger_, &transceivers_, CommanderId); DXLabSuiteCommanderTransceiver::register_transceivers (&logger_, &transceivers_, CommanderId);

View File

@ -37,7 +37,7 @@ namespace ptime = boost::posix_time;
namespace container = boost::container; namespace container = boost::container;
BOOST_LOG_ATTRIBUTE_KEYWORD(severity, "Severity", trivial::severity_level) BOOST_LOG_ATTRIBUTE_KEYWORD(severity, "Severity", trivial::severity_level)
BOOST_LOG_ATTRIBUTE_KEYWORD(channel, "Channel", std::wstring) BOOST_LOG_ATTRIBUTE_KEYWORD(channel, "Channel", std::string)
namespace namespace
{ {
@ -105,7 +105,7 @@ WSJTXLogging::WSJTXLogging ()
std::stringbuf buffer {new_config.toStdString (), std::ios_base::in}; std::stringbuf buffer {new_config.toStdString (), std::ios_base::in};
std::istream stream {&buffer}; std::istream stream {&buffer};
Logger::init_from_config (stream); Logger::init_from_config (stream);
LOG_INFO ("Unable to read logging configuration file: " << log_config.fileName ().toStdWString ()); LOG_INFO ("Unable to read logging configuration file: " << log_config.fileName ());
} }
else // Default setup else // Default setup
{ {
@ -148,11 +148,11 @@ WSJTXLogging::WSJTXLogging ()
sys_sink->locked_backend ()->scan_for_files (); sys_sink->locked_backend ()->scan_for_files ();
// Per channel severity level filter // Per channel severity level filter
using min_severity_filter = expr::channel_severity_filter_actor<std::wstring, trivial::severity_level>; using min_severity_filter = expr::channel_severity_filter_actor<std::string, trivial::severity_level>;
min_severity_filter min_severity = expr::channel_severity_filter (channel, severity); min_severity_filter min_severity = expr::channel_severity_filter (channel, severity);
min_severity[L"SYSLOG"] = trivial::info; min_severity["SYSLOG"] = trivial::info;
min_severity[L"RIGCTRL"] = trivial::info; min_severity["RIGCTRL"] = trivial::info;
min_severity[L"DATALOG"] = trivial::info; min_severity["DATALOG"] = trivial::info;
sys_sink->set_filter (min_severity || severity >= trivial::fatal); sys_sink->set_filter (min_severity || severity >= trivial::fatal);
sys_sink->set_formatter sys_sink->set_formatter
@ -168,7 +168,7 @@ WSJTXLogging::WSJTXLogging ()
core->add_sink (sys_sink); core->add_sink (sys_sink);
#if !defined (NDEBUG) && defined (Q_OS_WIN) #if !defined (NDEBUG) && defined (Q_OS_WIN)
// auto windbg_sink = boost::make_shared<sinks::synchronous_sink<sinks::wdebug_output_backend>> (); // auto windbg_sink = boost::make_shared<sinks::synchronous_sink<sinks::debug_output_backend>> ();
// windbg_sink->set_filter (trivial::severity >= trivial::trace && expr::is_debugger_present ()); // windbg_sink->set_filter (trivial::severity >= trivial::trace && expr::is_debugger_present ());
// core->add_sink (windbg_sink); // core->add_sink (windbg_sink);
#endif #endif
@ -201,8 +201,8 @@ void WSJTXLogging::qt_log_handler (QtMsgType type, QMessageLogContext const& con
// Map non-default Qt categories to logger channels, Qt logger // Map non-default Qt categories to logger channels, Qt logger
// context is mapped to the appropriate logger attributes. // context is mapped to the appropriate logger attributes.
auto log = Logger::sys::get (); auto log = Logger::sys::get ();
std::wstring file; std::string file;
std::wstring function; std::string function;
if (context.file) if (context.file)
{ {
file = context.file; file = context.file;
@ -217,15 +217,15 @@ void WSJTXLogging::qt_log_handler (QtMsgType type, QMessageLogContext const& con
<< boost::log::add_value ("Line", context.line) << boost::log::add_value ("Line", context.line)
<< boost::log::add_value ("File", context.file) << boost::log::add_value ("File", context.file)
<< boost::log::add_value ("Function", context.function) << boost::log::add_value ("Function", context.function)
<< msg.toStdWString (); << msg.toStdString ();
} }
else else
{ {
BOOST_LOG_CHANNEL_SEV (log, std::wstring {context.category}, severity) BOOST_LOG_CHANNEL_SEV (log, std::string {context.category}, severity)
<< boost::log::add_value ("Line", context.line) << boost::log::add_value ("Line", context.line)
<< boost::log::add_value ("File", context.file) << boost::log::add_value ("File", context.file)
<< boost::log::add_value ("Function", context.function) << boost::log::add_value ("Function", context.function)
<< msg.toStdWString (); << msg.toStdString ();
} }
if (QtFatalMsg == type) if (QtFatalMsg == type)
{ {

View File

@ -66,7 +66,7 @@ namespace
} seeding; } seeding;
#endif #endif
void safe_stream_QVariant (boost::log::wrecord_ostream& os, QVariant const& v) void safe_stream_QVariant (boost::log::record_ostream& os, QVariant const& v)
{ {
if (QMetaType::QByteArray == static_cast<QMetaType::Type> (v.type ())) if (QMetaType::QByteArray == static_cast<QMetaType::Type> (v.type ()))
{ {
@ -85,7 +85,7 @@ namespace
} }
else else
{ {
os << v.toString ().toStdWString (); os << v.toString ();
} }
} }
} }
@ -234,7 +234,7 @@ int main(int argc, char *argv[])
} }
WSJTXLogging lg; WSJTXLogging lg;
LOG_INFO (program_title (revision ()).toStdWString () << L" - Program startup"); LOG_INFO (program_title (revision ()) << " - Program startup");
// load UI translations // load UI translations
L10nLoader l10n {&a, locale, parser.value (lang_option)}; L10nLoader l10n {&a, locale, parser.value (lang_option)};
@ -323,7 +323,7 @@ int main(int argc, char *argv[])
boost::log::keywords::severity = boost::log::trivial::trace) boost::log::keywords::severity = boost::log::trivial::trace)
) )
{ {
boost::log::wrecord_ostream strm (rec); boost::log::record_ostream strm (rec);
strm << "++++++++++++++++++++++++++++ Settings ++++++++++++++++++++++++++++\n"; strm << "++++++++++++++++++++++++++++ Settings ++++++++++++++++++++++++++++\n";
for (auto const& key: multi_settings.settings ()->allKeys ()) for (auto const& key: multi_settings.settings ()->allKeys ())
{ {
@ -333,7 +333,7 @@ int main(int argc, char *argv[])
if (value.canConvert<QVariantList> ()) if (value.canConvert<QVariantList> ())
{ {
auto const sequence = value.value<QSequentialIterable> (); auto const sequence = value.value<QSequentialIterable> ();
strm << key.toStdWString () << ":\n"; strm << key << ":\n";
for (auto const& item: sequence) for (auto const& item: sequence)
{ {
strm << "\t"; strm << "\t";
@ -343,7 +343,7 @@ int main(int argc, char *argv[])
} }
else else
{ {
strm << key.toStdWString () << ": "; strm << key << ": ";
safe_stream_QVariant (strm, value); safe_stream_QVariant (strm, value);
strm << '\n'; strm << '\n';
} }