1
0
mirror of https://github.com/saitohirga/WSJT-X.git synced 2025-06-18 06:13:23 -04:00

Dump current settings to trace log at startup

This commit is contained in:
Bill Somerville 2020-09-26 15:14:51 +01:00
parent d587325f65
commit 030c8868ab
No known key found for this signature in database
GPG Key ID: D864B06D1E81618F

@ -2,7 +2,9 @@
#include <exception> #include <exception>
#include <stdexcept> #include <stdexcept>
#include <string> #include <string>
#include <iterator>
#include <algorithm>
#include <ios>
#include <locale.h> #include <locale.h>
#include <fftw3.h> #include <fftw3.h>
@ -63,6 +65,29 @@ namespace
} }
} seeding; } seeding;
#endif #endif
void safe_stream_QVariant (boost::log::wrecord_ostream& os, QVariant const& v)
{
if (QMetaType::QByteArray == static_cast<QMetaType::Type> (v.type ()))
{
auto const& a =v.toByteArray ();
std::ios::fmtflags f (os.flags ());
os << std::hex << std::showbase;
for (auto p = a.begin (); p != a.end (); )
{
os << static_cast<int8_t> (*p++);
if (p != a.end ())
{
os << ' ';
}
}
os.flags (f);
}
else
{
os << v.toString ().toStdWString ();
}
}
} }
int main(int argc, char *argv[]) int main(int argc, char *argv[])
@ -291,28 +316,43 @@ int main(int argc, char *argv[])
auto const& original_style_sheet = a.styleSheet (); auto const& original_style_sheet = a.styleSheet ();
do do
{ {
#if WSJT_QDEBUG_TO_FILE // dump settings
// announce to trace file and dump settings auto sys_lg = Logger::sys::get ();
qDebug () << "++++++++++++++++++++++++++++ Settings ++++++++++++++++++++++++++++"; if (auto rec = sys_lg.open_record
for (auto const& key: multi_settings.settings ()->allKeys ()) (
boost::log::keywords::severity = boost::log::trivial::trace)
)
{ {
auto const& value = multi_settings.settings ()->value (key); boost::log::wrecord_ostream strm (rec);
if (value.canConvert<QVariantList> ()) strm << "++++++++++++++++++++++++++++ Settings ++++++++++++++++++++++++++++\n";
for (auto const& key: multi_settings.settings ()->allKeys ())
{ {
auto const sequence = value.value<QSequentialIterable> (); if (!key.contains (QRegularExpression {"^MultiSettings/[^/]*/"}))
qDebug ().nospace () << key << ": ";
for (auto const& item: sequence)
{ {
qDebug ().nospace () << '\t' << item; auto const& value = multi_settings.settings ()->value (key);
if (value.canConvert<QVariantList> ())
{
auto const sequence = value.value<QSequentialIterable> ();
strm << key.toStdWString () << ":\n";
for (auto const& item: sequence)
{
strm << "\t";
safe_stream_QVariant (strm, item);
strm << '\n';
}
}
else
{
strm << key.toStdWString () << ": ";
safe_stream_QVariant (strm, value);
strm << '\n';
}
} }
} }
else strm << "---------------------------- Settings ----------------------------\n";
{ strm.flush ();
qDebug ().nospace () << key << ": " << value; sys_lg.push_record (boost::move (rec));
}
} }
qDebug () << "---------------------------- Settings ----------------------------";
#endif
// Create and initialize shared memory segment // Create and initialize shared memory segment
// Multiple instances: use rig_name as shared memory key // Multiple instances: use rig_name as shared memory key