control verbose logging with a menu-item in developer menu

This commit is contained in:
Seth Alves 2018-04-20 15:06:11 -07:00
parent bec39369f7
commit 6fc02638d7
7 changed files with 55 additions and 42 deletions

View file

@ -152,6 +152,8 @@
#include <controllers/Logging.h>
#include <NetworkLogging.h>
#include <shared/StorageLogging.h>
#include <ScriptEngineLogging.h>
#include <ui/Logging.h>
#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<ContextOverlayInterface>();
// by default, suppress some of the logging
if (_verboseLoggin) {
const_cast<QLoggingCategory*>(&animation())->setEnabled(QtDebugMsg, false);
const_cast<QLoggingCategory*>(&animation())->setEnabled(QtInfoMsg, false);
const_cast<QLoggingCategory*>(&avatars())->setEnabled(QtDebugMsg, false);
const_cast<QLoggingCategory*>(&avatars())->setEnabled(QtInfoMsg, false);
const_cast<QLoggingCategory*>(&scriptengine())->setEnabled(QtDebugMsg, false);
const_cast<QLoggingCategory*>(&scriptengine())->setEnabled(QtInfoMsg, false);
const_cast<QLoggingCategory*>(&modelformat())->setEnabled(QtDebugMsg, false);
const_cast<QLoggingCategory*>(&modelformat())->setEnabled(QtInfoMsg, false);
const_cast<QLoggingCategory*>(&controllers())->setEnabled(QtDebugMsg, false);
const_cast<QLoggingCategory*>(&controllers())->setEnabled(QtInfoMsg, false);
const_cast<QLoggingCategory*>(&resourceLog())->setEnabled(QtDebugMsg, false);
const_cast<QLoggingCategory*>(&resourceLog())->setEnabled(QtInfoMsg, false);
const_cast<QLoggingCategory*>(&networking())->setEnabled(QtDebugMsg, false);
const_cast<QLoggingCategory*>(&networking())->setEnabled(QtInfoMsg, false);
const_cast<QLoggingCategory*>(&asset_client())->setEnabled(QtDebugMsg, false);
const_cast<QLoggingCategory*>(&asset_client())->setEnabled(QtInfoMsg, false);
// const_cast<QLoggingCategory*>(&entity_script_client())->setEnabled(QtDebugMsg, false);
// const_cast<QLoggingCategory*>(&entity_script_client())->setEnabled(QtInfoMsg, false);
const_cast<QLoggingCategory*>(&messages_client())->setEnabled(QtDebugMsg, false);
const_cast<QLoggingCategory*>(&messages_client())->setEnabled(QtInfoMsg, false);
const_cast<QLoggingCategory*>(&storagelogging())->setEnabled(QtDebugMsg, false);
const_cast<QLoggingCategory*>(&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<QLoggingCategory*>(&animation())->setEnabled(QtDebugMsg, enable);
const_cast<QLoggingCategory*>(&animation())->setEnabled(QtInfoMsg, enable);
const_cast<QLoggingCategory*>(&avatars())->setEnabled(QtDebugMsg, enable);
const_cast<QLoggingCategory*>(&avatars())->setEnabled(QtInfoMsg, enable);
const_cast<QLoggingCategory*>(&scriptengine())->setEnabled(QtDebugMsg, enable);
const_cast<QLoggingCategory*>(&scriptengine())->setEnabled(QtInfoMsg, enable);
const_cast<QLoggingCategory*>(&scriptengine())->setEnabled(QtDebugMsg, enable);
const_cast<QLoggingCategory*>(&scriptengine())->setEnabled(QtInfoMsg, enable);
const_cast<QLoggingCategory*>(&modelformat())->setEnabled(QtDebugMsg, enable);
const_cast<QLoggingCategory*>(&modelformat())->setEnabled(QtInfoMsg, enable);
const_cast<QLoggingCategory*>(&controllers())->setEnabled(QtDebugMsg, enable);
const_cast<QLoggingCategory*>(&controllers())->setEnabled(QtInfoMsg, enable);
const_cast<QLoggingCategory*>(&resourceLog())->setEnabled(QtDebugMsg, enable);
const_cast<QLoggingCategory*>(&resourceLog())->setEnabled(QtInfoMsg, enable);
const_cast<QLoggingCategory*>(&networking())->setEnabled(QtDebugMsg, enable);
const_cast<QLoggingCategory*>(&networking())->setEnabled(QtInfoMsg, enable);
const_cast<QLoggingCategory*>(&asset_client())->setEnabled(QtDebugMsg, enable);
const_cast<QLoggingCategory*>(&asset_client())->setEnabled(QtInfoMsg, enable);
const_cast<QLoggingCategory*>(&messages_client())->setEnabled(QtDebugMsg, enable);
const_cast<QLoggingCategory*>(&messages_client())->setEnabled(QtInfoMsg, enable);
const_cast<QLoggingCategory*>(&storagelogging())->setEnabled(QtDebugMsg, enable);
const_cast<QLoggingCategory*>(&storagelogging())->setEnabled(QtInfoMsg, enable);
const_cast<QLoggingCategory*>(&uiLogging())->setEnabled(QtDebugMsg, enable);
const_cast<QLoggingCategory*>(&uiLogging())->setEnabled(QtInfoMsg, enable);
const_cast<QLoggingCategory*>(&glLogging())->setEnabled(QtDebugMsg, enable);
const_cast<QLoggingCategory*>(&glLogging())->setEnabled(QtInfoMsg, enable);
}
void Application::domainConnectionRefused(const QString& reasonMessage, int reasonCodeInt, const QString& extraInfo) {
DomainHandler::ConnectionRefusedReason reasonCode = static_cast<DomainHandler::ConnectionRefusedReason>(reasonCodeInt);

View file

@ -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<bool> _pendingIdleEvent { true };
std::atomic<bool> _pendingRenderEvent { true };
bool _verboseLogging { false };
};
#endif // hifi_Application_h

View file

@ -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()));

View file

@ -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";

View file

@ -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);
}

View file

@ -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

View file

@ -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 <QLoggingCategory>