From 6fc02638d74e5fe0a069fd40ef2713526c4cc215 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Fri, 20 Apr 2018 15:06:11 -0700 Subject: [PATCH] control verbose logging with a menu-item in developer menu --- interface/src/Application.cpp | 82 +++++++++++-------- interface/src/Application.h | 4 +- interface/src/Menu.cpp | 3 + interface/src/Menu.h | 1 + .../networking/src/EntityScriptClient.cpp | 2 - libraries/networking/src/NetworkLogging.h | 1 - libraries/ui/src/ui/Logging.h | 4 +- 7 files changed, 55 insertions(+), 42 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 363c3c23a9..3087c0cb71 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -152,6 +152,8 @@ #include #include #include +#include +#include #include "AudioClient.h" #include "audio/AudioScope.h" @@ -1424,41 +1426,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo _overlays.init(); // do this before scripts load DependencyManager::set(); - // by default, suppress some of the logging - if (_verboseLoggin) { - const_cast(&animation())->setEnabled(QtDebugMsg, false); - const_cast(&animation())->setEnabled(QtInfoMsg, false); - - const_cast(&avatars())->setEnabled(QtDebugMsg, false); - const_cast(&avatars())->setEnabled(QtInfoMsg, false); - - const_cast(&scriptengine())->setEnabled(QtDebugMsg, false); - const_cast(&scriptengine())->setEnabled(QtInfoMsg, false); - - const_cast(&modelformat())->setEnabled(QtDebugMsg, false); - const_cast(&modelformat())->setEnabled(QtInfoMsg, false); - - const_cast(&controllers())->setEnabled(QtDebugMsg, false); - const_cast(&controllers())->setEnabled(QtInfoMsg, false); - - const_cast(&resourceLog())->setEnabled(QtDebugMsg, false); - const_cast(&resourceLog())->setEnabled(QtInfoMsg, false); - - const_cast(&networking())->setEnabled(QtDebugMsg, false); - const_cast(&networking())->setEnabled(QtInfoMsg, false); - - const_cast(&asset_client())->setEnabled(QtDebugMsg, false); - const_cast(&asset_client())->setEnabled(QtInfoMsg, false); - - // const_cast(&entity_script_client())->setEnabled(QtDebugMsg, false); - // const_cast(&entity_script_client())->setEnabled(QtInfoMsg, false); - - const_cast(&messages_client())->setEnabled(QtDebugMsg, false); - const_cast(&messages_client())->setEnabled(QtInfoMsg, false); - - const_cast(&storagelogging())->setEnabled(QtDebugMsg, false); - const_cast(&storagelogging())->setEnabled(QtInfoMsg, false); - } + // adjust which logging categories will be sent to the logs + updateVerboseLogging(); // Make sure we don't time out during slow operations at startup updateHeartbeat(); @@ -2181,6 +2150,49 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo qCDebug(interfaceapp) << "Metaverse session ID is" << uuidStringWithoutCurlyBraces(accountManager->getSessionID()); } +void Application::updateVerboseLogging() { + bool enable = Menu::getInstance()->isOptionChecked(MenuOption::VerboseLogging); + + const_cast(&animation())->setEnabled(QtDebugMsg, enable); + const_cast(&animation())->setEnabled(QtInfoMsg, enable); + + const_cast(&avatars())->setEnabled(QtDebugMsg, enable); + const_cast(&avatars())->setEnabled(QtInfoMsg, enable); + + const_cast(&scriptengine())->setEnabled(QtDebugMsg, enable); + const_cast(&scriptengine())->setEnabled(QtInfoMsg, enable); + + const_cast(&scriptengine())->setEnabled(QtDebugMsg, enable); + const_cast(&scriptengine())->setEnabled(QtInfoMsg, enable); + + const_cast(&modelformat())->setEnabled(QtDebugMsg, enable); + const_cast(&modelformat())->setEnabled(QtInfoMsg, enable); + + const_cast(&controllers())->setEnabled(QtDebugMsg, enable); + const_cast(&controllers())->setEnabled(QtInfoMsg, enable); + + const_cast(&resourceLog())->setEnabled(QtDebugMsg, enable); + const_cast(&resourceLog())->setEnabled(QtInfoMsg, enable); + + const_cast(&networking())->setEnabled(QtDebugMsg, enable); + const_cast(&networking())->setEnabled(QtInfoMsg, enable); + + const_cast(&asset_client())->setEnabled(QtDebugMsg, enable); + const_cast(&asset_client())->setEnabled(QtInfoMsg, enable); + + const_cast(&messages_client())->setEnabled(QtDebugMsg, enable); + const_cast(&messages_client())->setEnabled(QtInfoMsg, enable); + + const_cast(&storagelogging())->setEnabled(QtDebugMsg, enable); + const_cast(&storagelogging())->setEnabled(QtInfoMsg, enable); + + const_cast(&uiLogging())->setEnabled(QtDebugMsg, enable); + const_cast(&uiLogging())->setEnabled(QtInfoMsg, enable); + + const_cast(&glLogging())->setEnabled(QtDebugMsg, enable); + const_cast(&glLogging())->setEnabled(QtInfoMsg, enable); +} + void Application::domainConnectionRefused(const QString& reasonMessage, int reasonCodeInt, const QString& extraInfo) { DomainHandler::ConnectionRefusedReason reasonCode = static_cast(reasonCodeInt); diff --git a/interface/src/Application.h b/interface/src/Application.h index cdc2d1eed6..eedc5e17ee 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -398,6 +398,8 @@ public slots: Q_INVOKABLE bool askBeforeSetAvatarUrl(const QString& avatarUrl) { return askToSetAvatarUrl(avatarUrl); } + void updateVerboseLogging(); + private slots: void onDesktopRootItemCreated(QQuickItem* qmlContext); void onDesktopRootContextCreated(QQmlContext* qmlContext); @@ -718,7 +720,5 @@ private: std::atomic _pendingIdleEvent { true }; std::atomic _pendingRenderEvent { true }; - - bool _verboseLogging { false }; }; #endif // hifi_Application_h diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 4384635147..50ff65ad1a 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -810,6 +810,9 @@ Menu::Menu() { scriptEngines->loadScript(defaultScriptsLoc.toString()); }); + addCheckableActionToQMenuAndActionHash(developerMenu, MenuOption::VerboseLogging, 0, false, + qApp, SLOT(updateVerboseLogging())); + #if 0 /// -------------- REMOVED FOR NOW -------------- addDisabledActionAndSeparator(navigateMenu, "History"); QAction* backAction = addActionToQMenuAndActionHash(navigateMenu, MenuOption::Back, 0, addressManager.data(), SLOT(goBack())); diff --git a/interface/src/Menu.h b/interface/src/Menu.h index bba70a6a89..c8c8ee42df 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -142,6 +142,7 @@ namespace MenuOption { const QString Pair = "Pair"; const QString PhysicsShowHulls = "Draw Collision Shapes"; const QString PhysicsShowOwned = "Highlight Simulation Ownership"; + const QString VerboseLogging = "Verbose Logging"; const QString PipelineWarnings = "Log Render Pipeline Warnings"; const QString Preferences = "General..."; const QString Quit = "Quit"; diff --git a/libraries/networking/src/EntityScriptClient.cpp b/libraries/networking/src/EntityScriptClient.cpp index 75ae7369fb..1eab5bf2d7 100644 --- a/libraries/networking/src/EntityScriptClient.cpp +++ b/libraries/networking/src/EntityScriptClient.cpp @@ -192,8 +192,6 @@ void EntityScriptClient::handleNodeClientConnectionReset(SharedNodePointer node) return; } - //qCDebug(entity_script_client) << "EntityScriptClient detected client connection reset handshake with Asset Server - failing any pending requests"; - forceFailureOfPendingRequests(node); } diff --git a/libraries/networking/src/NetworkLogging.h b/libraries/networking/src/NetworkLogging.h index 518c600efe..30116ff405 100644 --- a/libraries/networking/src/NetworkLogging.h +++ b/libraries/networking/src/NetworkLogging.h @@ -17,7 +17,6 @@ Q_DECLARE_LOGGING_CATEGORY(resourceLog) Q_DECLARE_LOGGING_CATEGORY(networking) Q_DECLARE_LOGGING_CATEGORY(asset_client) -Q_DECLARE_LOGGING_CATEGORY(entity_script_client) Q_DECLARE_LOGGING_CATEGORY(messages_client) #endif // hifi_NetworkLogging_h diff --git a/libraries/ui/src/ui/Logging.h b/libraries/ui/src/ui/Logging.h index 6d31b0e86a..dd14268dba 100644 --- a/libraries/ui/src/ui/Logging.h +++ b/libraries/ui/src/ui/Logging.h @@ -6,8 +6,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef hifi_Controllers_Logging_h -#define hifi_Controllers_Logging_h +#ifndef hifi_UI_Logging_h +#define hifi_UI_Logging_h #include