diff options
author | Gerald Combs <gerald@wireshark.org> | 2017-12-16 14:15:28 -0800 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2017-12-17 02:30:40 +0000 |
commit | 6a5e90f2d91892248f5f7defe1c610e00298d789 (patch) | |
tree | f12e93fe35f2c658fb133335d1e8980c93e4dc20 /wireshark-qt.cpp | |
parent | 18c42e1dca9631b336dd2a8b813aad782569f69a (diff) |
Log output updates.
Add a Qt message handler that calls g_log. Add milliseconds to the
g_log_message_handler timestamp.
Change-Id: I5b1c1d902b6b05cd8daa01741b19d6c2048dfb9a
Reviewed-on: https://code.wireshark.org/review/24865
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'wireshark-qt.cpp')
-rw-r--r-- | wireshark-qt.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/wireshark-qt.cpp b/wireshark-qt.cpp index 94b20298a6..c65bb75775 100644 --- a/wireshark-qt.cpp +++ b/wireshark-qt.cpp @@ -256,6 +256,33 @@ get_wireshark_runtime_info(GString *str) #endif } +void +g_log_message_handler(QtMsgType type, const QMessageLogContext &, const QString &msg) +{ + GLogLevelFlags log_level = G_LOG_LEVEL_DEBUG; + + switch (type) { + case QtDebugMsg: + default: + break; +#if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)) + case QtInfoMsg: + log_level = G_LOG_LEVEL_INFO; + break; +#endif + case QtWarningMsg: + log_level = G_LOG_LEVEL_WARNING; + break; + case QtCriticalMsg: + log_level = G_LOG_LEVEL_CRITICAL; + break; + case QtFatalMsg: + log_level = G_LOG_FLAG_FATAL; + break; + } + g_log(LOG_DOMAIN_MAIN, log_level, "%s", qUtf8Printable(msg)); +} + #ifdef HAVE_LIBPCAP /* Check if there's something important to tell the user during startup. * We want to do this *after* showing the main window so that any windows @@ -582,6 +609,7 @@ int main(int argc, char *qt_argv[]) #endif set_console_log_handler(); + qInstallMessageHandler(g_log_message_handler); #ifdef DEBUG_STARTUP_TIME g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_INFO, "set_console_log_handler, elapsed time %" G_GUINT64_FORMAT " us \n", g_get_monotonic_time() - start_time); #endif |