From b12e9004bbc0caf595009b463e43f87824285485 Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Sun, 11 Oct 2020 00:03:10 +0100 Subject: [PATCH] Make settings trace output human readable --- main.cpp | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/main.cpp b/main.cpp index 77e753780..2fa435f02 100644 --- a/main.cpp +++ b/main.cpp @@ -28,6 +28,10 @@ #include #include #include +#include +#include +#include +#include #include "ExceptionCatchingApplication.hpp" #include "Logger.hpp" @@ -68,23 +72,24 @@ namespace void safe_stream_QVariant (boost::log::record_ostream& os, QVariant const& v) { - if (QMetaType::QByteArray == static_cast (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 (*p++); - if (p != a.end ()) - { - os << ' '; - } - } - os.flags (f); - } - else + 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; + + default: os << v.toString (); } }