mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-21 11:31:51 -05:00
Temporarily remove global Boost::log loggers
This commit is contained in:
parent
29b147eef0
commit
5a9b56bfc0
12
Logger.cpp
12
Logger.cpp
@ -34,12 +34,12 @@ namespace expr = logging::expressions;
|
||||
namespace attrs = logging::attributes;
|
||||
namespace ptime = boost::posix_time;
|
||||
|
||||
BOOST_LOG_GLOBAL_LOGGER_CTOR_ARGS (sys,
|
||||
srcs::severity_channel_logger_mt<logging::trivial::severity_level>,
|
||||
(keywords::channel = "SYSLOG"));
|
||||
BOOST_LOG_GLOBAL_LOGGER_CTOR_ARGS (data,
|
||||
srcs::severity_channel_logger_mt<logging::trivial::severity_level>,
|
||||
(keywords::channel = "DATALOG"));
|
||||
// BOOST_LOG_GLOBAL_LOGGER_CTOR_ARGS (sys,
|
||||
// srcs::severity_channel_logger_mt<logging::trivial::severity_level>,
|
||||
// (keywords::channel = "SYSLOG"));
|
||||
// BOOST_LOG_GLOBAL_LOGGER_CTOR_ARGS (data,
|
||||
// srcs::severity_channel_logger_mt<logging::trivial::severity_level>,
|
||||
// (keywords::channel = "DATALOG"));
|
||||
|
||||
namespace Logger
|
||||
{
|
||||
|
20
Logger.hpp
20
Logger.hpp
@ -10,10 +10,10 @@
|
||||
#include <iosfwd>
|
||||
#include <string>
|
||||
|
||||
BOOST_LOG_GLOBAL_LOGGER (sys,
|
||||
boost::log::sources::severity_channel_logger_mt<boost::log::trivial::severity_level>);
|
||||
BOOST_LOG_GLOBAL_LOGGER (data,
|
||||
boost::log::sources::severity_channel_logger_mt<boost::log::trivial::severity_level>);
|
||||
// BOOST_LOG_GLOBAL_LOGGER (sys,
|
||||
// boost::log::sources::severity_channel_logger_mt<boost::log::trivial::severity_level>);
|
||||
// BOOST_LOG_GLOBAL_LOGGER (data,
|
||||
// boost::log::sources::severity_channel_logger_mt<boost::log::trivial::severity_level>);
|
||||
|
||||
namespace Logger
|
||||
{
|
||||
@ -31,12 +31,16 @@ namespace Logger
|
||||
void add_data_file_log (std::string const& log_file_name);
|
||||
}
|
||||
|
||||
#if 0
|
||||
#define LOG_LOG_LOCATION(LOGGER, LEVEL, ARG) \
|
||||
BOOST_LOG_SEV (LOGGER, boost::log::trivial::LEVEL) \
|
||||
<< boost::log::add_value ("Line", __LINE__) \
|
||||
<< boost::log::add_value ("File", __FILE__) \
|
||||
<< boost::log::add_value ("Function", __FUNCTION__) << ARG;
|
||||
|
||||
<< boost::log::add_value ("Line", __LINE__) \
|
||||
<< boost::log::add_value ("File", __FILE__) \
|
||||
<< boost::log::add_value ("Function", __FUNCTION__) << ARG;
|
||||
#endif
|
||||
|
||||
#define LOG_LOG_LOCATION(LOGGER, LEVEL, ARG)
|
||||
|
||||
/// System Log macros.
|
||||
/// TRACE < DEBUG < INFO < WARN < ERROR < FATAL
|
||||
#define LOG_TRACE(ARG) LOG_LOG_LOCATION (sys::get(), trace, ARG);
|
||||
|
@ -187,10 +187,10 @@ int HRDTransceiver::do_start ()
|
||||
}
|
||||
|
||||
CAT_TRACE ("radios:-");
|
||||
Q_FOREACH (auto const& radio, radios_)
|
||||
{
|
||||
CAT_TRACE ("\t[" << std::get<0> (radio) << "] " << std::get<1> (radio));
|
||||
}
|
||||
// Q_FOREACH (auto const& radio, radios_)
|
||||
// {
|
||||
// CAT_TRACE ("\t[" << std::get<0> (radio) << "] " << std::get<1> (radio));
|
||||
// }
|
||||
|
||||
auto current_radio_name = send_command ("get radio", false, false);
|
||||
HRD_info << "Current radio: " << current_radio_name << "\n";
|
||||
@ -407,11 +407,11 @@ void HRDTransceiver::map_modes (int dropdown, ModeMap *map)
|
||||
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]);
|
||||
std::for_each (map->begin (), map->end (), [this, dropdown] (ModeMap::value_type const& item)
|
||||
{
|
||||
auto const& rhs = std::get<1> (item);
|
||||
CAT_TRACE ('\t' << std::get<0> (item) << "<->" << (rhs.size () ? dropdowns_[dropdown_names_[dropdown]][rhs.front ()] : "None"));
|
||||
});
|
||||
// std::for_each (map->begin (), map->end (), [this, dropdown] (ModeMap::value_type const& item)
|
||||
// {
|
||||
// auto const& rhs = std::get<1> (item);
|
||||
// CAT_TRACE ('\t' << std::get<0> (item) << "<->" << (rhs.size () ? dropdowns_[dropdown_names_[dropdown]][rhs.front ()] : "None"));
|
||||
// });
|
||||
}
|
||||
|
||||
int HRDTransceiver::lookup_mode (MODE mode, ModeMap const& map) const
|
||||
|
@ -193,21 +193,21 @@ WSJTXLogging::~WSJTXLogging ()
|
||||
}
|
||||
|
||||
// Reroute Qt messages to the system logger
|
||||
void WSJTXLogging::qt_log_handler (QtMsgType type, QMessageLogContext const& context, QString const& msg)
|
||||
void WSJTXLogging::qt_log_handler (QtMsgType type, QMessageLogContext const& context, QString const& /*msg*/)
|
||||
{
|
||||
// Convert Qt message types to logger severities
|
||||
auto severity = trivial::trace;
|
||||
switch (type)
|
||||
{
|
||||
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;
|
||||
}
|
||||
// auto severity = trivial::trace;
|
||||
// switch (type)
|
||||
// {
|
||||
// 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.
|
||||
auto log = sys::get ();
|
||||
// auto log = sys::get ();
|
||||
std::string file;
|
||||
std::string function;
|
||||
if (context.file)
|
||||
@ -220,19 +220,19 @@ void WSJTXLogging::qt_log_handler (QtMsgType type, QMessageLogContext const& con
|
||||
}
|
||||
if (!context.category || !qstrcmp (context.category, "default"))
|
||||
{
|
||||
BOOST_LOG_SEV (log, severity)
|
||||
<< boost::log::add_value ("Line", context.line)
|
||||
<< boost::log::add_value ("File", file)
|
||||
<< boost::log::add_value ("Function", function)
|
||||
<< msg.toStdString ();
|
||||
// BOOST_LOG_SEV (log, severity)
|
||||
// << boost::log::add_value ("Line", context.line)
|
||||
// << boost::log::add_value ("File", file)
|
||||
// << boost::log::add_value ("Function", function)
|
||||
// << msg.toStdString ();
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOST_LOG_CHANNEL_SEV (log, std::string {context.category}, severity)
|
||||
<< boost::log::add_value ("Line", context.line)
|
||||
<< boost::log::add_value ("File", file)
|
||||
<< boost::log::add_value ("Function", function)
|
||||
<< msg.toStdString ();
|
||||
// BOOST_LOG_CHANNEL_SEV (log, std::string {context.category}, severity)
|
||||
// << boost::log::add_value ("Line", context.line)
|
||||
// << boost::log::add_value ("File", file)
|
||||
// << boost::log::add_value ("Function", function)
|
||||
// << msg.toStdString ();
|
||||
}
|
||||
if (QtFatalMsg == type)
|
||||
{
|
||||
|
114
main.cpp
114
main.cpp
@ -71,29 +71,29 @@ namespace
|
||||
} seeding;
|
||||
#endif
|
||||
|
||||
void safe_stream_QVariant (boost::log::record_ostream& os, QVariant const& v)
|
||||
{
|
||||
switch (static_cast<QMetaType::Type> (v.type ()))
|
||||
{
|
||||
case QMetaType::QByteArray:
|
||||
os << "0x" << v.toByteArray ().toHex (':').toStdString ();
|
||||
break;
|
||||
// void safe_stream_QVariant (boost::log::record_ostream& os, QVariant const& v)
|
||||
// {
|
||||
// switch (static_cast<QMetaType::Type> (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;
|
||||
// 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 ();
|
||||
}
|
||||
}
|
||||
// default:
|
||||
// os << v.toString ();
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
@ -325,42 +325,42 @@ int main(int argc, char *argv[])
|
||||
do
|
||||
{
|
||||
// dump settings
|
||||
auto sys_lg = sys::get ();
|
||||
if (auto rec = sys_lg.open_record
|
||||
(
|
||||
boost::log::keywords::severity = boost::log::trivial::trace)
|
||||
)
|
||||
{
|
||||
boost::log::record_ostream strm (rec);
|
||||
strm << "++++++++++++++++++++++++++++ Settings ++++++++++++++++++++++++++++\n";
|
||||
for (auto const& key: multi_settings.settings ()->allKeys ())
|
||||
{
|
||||
if (!key.contains (QRegularExpression {"^MultiSettings/[^/]*/"}))
|
||||
{
|
||||
auto const& value = multi_settings.settings ()->value (key);
|
||||
if (value.canConvert<QVariantList> ())
|
||||
{
|
||||
auto const sequence = value.value<QSequentialIterable> ();
|
||||
strm << key << ":\n";
|
||||
for (auto const& item: sequence)
|
||||
{
|
||||
strm << "\t";
|
||||
safe_stream_QVariant (strm, item);
|
||||
strm << '\n';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
strm << key << ": ";
|
||||
safe_stream_QVariant (strm, value);
|
||||
strm << '\n';
|
||||
}
|
||||
}
|
||||
}
|
||||
strm << "---------------------------- Settings ----------------------------\n";
|
||||
strm.flush ();
|
||||
sys_lg.push_record (boost::move (rec));
|
||||
}
|
||||
// auto sys_lg = sys::get ();
|
||||
// if (auto rec = sys_lg.open_record
|
||||
// (
|
||||
// boost::log::keywords::severity = boost::log::trivial::trace)
|
||||
// )
|
||||
// {
|
||||
// boost::log::record_ostream strm (rec);
|
||||
// strm << "++++++++++++++++++++++++++++ Settings ++++++++++++++++++++++++++++\n";
|
||||
// for (auto const& key: multi_settings.settings ()->allKeys ())
|
||||
// {
|
||||
// if (!key.contains (QRegularExpression {"^MultiSettings/[^/]*/"}))
|
||||
// {
|
||||
// auto const& value = multi_settings.settings ()->value (key);
|
||||
// if (value.canConvert<QVariantList> ())
|
||||
// {
|
||||
// auto const sequence = value.value<QSequentialIterable> ();
|
||||
// strm << key << ":\n";
|
||||
// for (auto const& item: sequence)
|
||||
// {
|
||||
// strm << "\t";
|
||||
// safe_stream_QVariant (strm, item);
|
||||
// strm << '\n';
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// strm << key << ": ";
|
||||
// safe_stream_QVariant (strm, value);
|
||||
// strm << '\n';
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// strm << "---------------------------- Settings ----------------------------\n";
|
||||
// strm.flush ();
|
||||
// sys_lg.push_record (boost::move (rec));
|
||||
// }
|
||||
|
||||
// Create and initialize shared memory segment
|
||||
// Multiple instances: use rig_name as shared memory key
|
||||
|
Loading…
Reference in New Issue
Block a user