1
0
Fork 0
forked from lthn/blockchain

--enable-qt-logs implemented

This commit is contained in:
sowle 2019-09-28 18:02:25 +03:00
parent ec4b6caee5
commit e0967147bd
No known key found for this signature in database
GPG key ID: C07A24B2D89D49FC
3 changed files with 35 additions and 5 deletions

View file

@ -40,7 +40,8 @@ daemon_backend::daemon_backend():m_pview(&m_view_stub),
m_offers_service(nullptr),
m_ui_opt(AUTO_VAL_INIT(m_ui_opt)),
m_remote_node_mode(false),
m_is_pos_allowed(false)
m_is_pos_allowed(false),
m_qt_logs_enbaled(false)
{
m_offers_service.set_disabled(true);
//m_ccore.get_blockchain_storage().get_attachment_services_manager().add_service(&m_offers_service);
@ -52,6 +53,7 @@ const command_line::arg_descriptor<std::string> arg_xcode_stub = {"-NSDocumentRe
const command_line::arg_descriptor<bool> arg_enable_gui_debug_mode = { "gui-debug-mode", "Enable debug options in GUI", false, true };
const command_line::arg_descriptor<uint32_t> arg_qt_remote_debugging_port = { "remote-debugging-port", "Specify port for Qt remote debugging", 30333, true };
const command_line::arg_descriptor<std::string> arg_remote_node = { "remote-node", "Switch GUI to work with remote node instead of local daemon", "", true };
const command_line::arg_descriptor<bool> arg_enable_qt_logs = { "enable-qt-logs", "Forward Qt log messages into main log", false, true };
void wallet_lock_time_watching_policy::watch_lock_time(uint64_t lock_time)
{
@ -124,9 +126,7 @@ bool daemon_backend::init(int argc, char* argv[], view::i_view* pview_handler)
command_line::add_arg(desc_cmd_sett, arg_enable_gui_debug_mode);
command_line::add_arg(desc_cmd_sett, arg_qt_remote_debugging_port);
command_line::add_arg(desc_cmd_sett, arg_remote_node);
command_line::add_arg(desc_cmd_sett, arg_enable_qt_logs);
currency::core::init_options(desc_cmd_sett);
@ -220,6 +220,8 @@ bool daemon_backend::init(int argc, char* argv[], view::i_view* pview_handler)
// configure for remote node
}
m_qt_logs_enbaled = command_line::get_arg(m_vm, arg_enable_qt_logs);
m_pview->init(path_to_html);
if (!coomand_line_parsed)

View file

@ -142,6 +142,7 @@ public:
void unsubscribe_to_core_events();
void get_gui_options(view::gui_options& opt);
std::string get_wallet_log_prefix(size_t wallet_id) const;
bool is_qt_logs_enabled() const { return m_qt_logs_enbaled; }
private:
void main_worker(const po::variables_map& vm);
@ -187,6 +188,7 @@ private:
currency::core_rpc_server m_rpc_server;
bool m_remote_node_mode;
bool m_qt_logs_enbaled;
std::atomic<bool> m_is_pos_allowed;

View file

@ -609,10 +609,36 @@ bool MainWindow::show_msg_box(const std::string& message)
return true;
CATCH_ENTRY2(false);
}
void qt_log_message_handler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{
QByteArray local_msg = msg.toLocal8Bit();
const char* msg_type = "";
switch (type)
{
case QtDebugMsg: msg_type = "DEBG "; break;
case QtInfoMsg: msg_type = "INFO "; break;
case QtWarningMsg: msg_type = "WARN "; break;
case QtCriticalMsg: msg_type = "CRIT "; break;
case QtFatalMsg: msg_type = "FATAL "; break;
}
LOG_PRINT("[QT] " << msg_type << local_msg.constData() << " @ " << context.file << ":" << context.line << ", " << (context.function ? context.function : ""), LOG_LEVEL_0);
}
bool MainWindow::init_backend(int argc, char* argv[])
{
TRY_ENTRY();
return m_backend.init(argc, argv, this);
if (!m_backend.init(argc, argv, this))
return false;
if (m_backend.is_qt_logs_enabled())
{
qInstallMessageHandler(qt_log_message_handler);
QLoggingCategory::setFilterRules("*=true"); // enable all logs
}
return true;
CATCH_ENTRY2(false);
}