Use wide character logging for efficiency as most o/p is QString

This commit is contained in:
Bill Somerville
2020-09-26 14:15:44 +01:00
parent db9b2d538d
commit 1d43ddd38b
14 changed files with 116 additions and 107 deletions
+16 -16
View File
@@ -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
}