mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-05-10 00:48:20 +02:00
Migrate logging functionality to shared library
This commit is contained in:
parent
82db3d5d55
commit
f33d3a3b36
14 changed files with 83 additions and 49 deletions
|
@ -44,12 +44,12 @@
|
||||||
#include <AbstractUriHandler.h>
|
#include <AbstractUriHandler.h>
|
||||||
#include <shared/RateCounter.h>
|
#include <shared/RateCounter.h>
|
||||||
#include <ThreadSafeValueCache.h>
|
#include <ThreadSafeValueCache.h>
|
||||||
|
#include <shared/FileLogger.h>
|
||||||
|
|
||||||
#include "avatar/MyAvatar.h"
|
#include "avatar/MyAvatar.h"
|
||||||
#include "Bookmarks.h"
|
#include "Bookmarks.h"
|
||||||
#include "Camera.h"
|
#include "Camera.h"
|
||||||
#include "ConnectionMonitor.h"
|
#include "ConnectionMonitor.h"
|
||||||
#include "FileLogger.h"
|
|
||||||
#include "gpu/Context.h"
|
#include "gpu/Context.h"
|
||||||
#include "Menu.h"
|
#include "Menu.h"
|
||||||
#include "octree/OctreePacketProcessor.h"
|
#include "octree/OctreePacketProcessor.h"
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
#include <QSyntaxHighlighter>
|
#include <QSyntaxHighlighter>
|
||||||
|
|
||||||
#include "AbstractLoggerInterface.h"
|
#include <shared/AbstractLoggerInterface.h>
|
||||||
|
|
||||||
class KeywordHighlighter : public QSyntaxHighlighter {
|
class KeywordHighlighter : public QSyntaxHighlighter {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#include <AddressManager.h>
|
#include <AddressManager.h>
|
||||||
#include <avatar/AvatarManager.h>
|
#include <avatar/AvatarManager.h>
|
||||||
#include <avatar/MyAvatar.h>
|
#include <avatar/MyAvatar.h>
|
||||||
#include <FileUtils.h>
|
#include <shared/FileUtils.h>
|
||||||
#include <NodeList.h>
|
#include <NodeList.h>
|
||||||
#include <OffscreenUi.h>
|
#include <OffscreenUi.h>
|
||||||
#include <SharedUtil.h>
|
#include <SharedUtil.h>
|
||||||
|
|
|
@ -124,36 +124,6 @@ QDataStream& operator>>(QDataStream& dataStream, HifiSockAddr& sockAddr) {
|
||||||
return dataStream;
|
return dataStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
QHostAddress getGuessedLocalAddress() {
|
|
||||||
|
|
||||||
QHostAddress localAddress;
|
|
||||||
|
|
||||||
foreach(const QNetworkInterface &networkInterface, QNetworkInterface::allInterfaces()) {
|
|
||||||
if (networkInterface.flags() & QNetworkInterface::IsUp
|
|
||||||
&& networkInterface.flags() & QNetworkInterface::IsRunning
|
|
||||||
&& networkInterface.flags() & ~QNetworkInterface::IsLoopBack) {
|
|
||||||
// we've decided that this is the active NIC
|
|
||||||
// enumerate it's addresses to grab the IPv4 address
|
|
||||||
foreach(const QNetworkAddressEntry &entry, networkInterface.addressEntries()) {
|
|
||||||
// make sure it's an IPv4 address that isn't the loopback
|
|
||||||
if (entry.ip().protocol() == QAbstractSocket::IPv4Protocol && !entry.ip().isLoopback()) {
|
|
||||||
|
|
||||||
// set our localAddress and break out
|
|
||||||
localAddress = entry.ip();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!localAddress.isNull()) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// return the looked up local address
|
|
||||||
return localAddress;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint qHash(const HifiSockAddr& key, uint seed) {
|
uint qHash(const HifiSockAddr& key, uint seed) {
|
||||||
// use the existing QHostAddress and quint16 hash functions to get our hash
|
// use the existing QHostAddress and quint16 hash functions to get our hash
|
||||||
return qHash(key.getAddress(), seed) ^ qHash(key.getPort(), seed);
|
return qHash(key.getAddress(), seed) ^ qHash(key.getPort(), seed);
|
||||||
|
|
|
@ -91,9 +91,6 @@ namespace std {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QHostAddress getGuessedLocalAddress();
|
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(HifiSockAddr);
|
Q_DECLARE_METATYPE(HifiSockAddr);
|
||||||
|
|
||||||
#endif // hifi_HifiSockAddr_h
|
#endif // hifi_HifiSockAddr_h
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include <tbb/parallel_for.h>
|
#include <tbb/parallel_for.h>
|
||||||
|
|
||||||
#include <LogHandler.h>
|
#include <LogHandler.h>
|
||||||
|
#include <shared/NetworkUtils.h>
|
||||||
#include <NumericalConstants.h>
|
#include <NumericalConstants.h>
|
||||||
#include <SettingHandle.h>
|
#include <SettingHandle.h>
|
||||||
#include <SharedUtil.h>
|
#include <SharedUtil.h>
|
||||||
|
|
|
@ -15,11 +15,12 @@
|
||||||
#include <QtCore/QDir>
|
#include <QtCore/QDir>
|
||||||
#include <QtGui/QDesktopServices>
|
#include <QtGui/QDesktopServices>
|
||||||
|
|
||||||
#include <NumericalConstants.h>
|
#include "FileUtils.h"
|
||||||
#include <FileUtils.h>
|
#include "NetworkUtils.h"
|
||||||
#include <SharedUtil.h>
|
|
||||||
|
#include "../NumericalConstants.h"
|
||||||
|
#include "../SharedUtil.h"
|
||||||
|
|
||||||
#include "HifiSockAddr.h"
|
|
||||||
|
|
||||||
static const QString FILENAME_FORMAT = "hifi-log_%1_%2.txt";
|
static const QString FILENAME_FORMAT = "hifi-log_%1_%2.txt";
|
||||||
static const QString DATETIME_FORMAT = "yyyy-MM-dd_hh.mm.ss";
|
static const QString DATETIME_FORMAT = "yyyy-MM-dd_hh.mm.ss";
|
|
@ -13,7 +13,7 @@
|
||||||
#define hifi_FileLogger_h
|
#define hifi_FileLogger_h
|
||||||
|
|
||||||
#include "AbstractLoggerInterface.h"
|
#include "AbstractLoggerInterface.h"
|
||||||
#include <GenericQueueThread.h>
|
#include "../GenericQueueThread.h"
|
||||||
|
|
||||||
#include <QtCore/QFile>
|
#include <QtCore/QFile>
|
||||||
|
|
42
libraries/shared/src/shared/NetworkUtils.cpp
Normal file
42
libraries/shared/src/shared/NetworkUtils.cpp
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
//
|
||||||
|
// Created by Bradley Austin Davis on 2016/09/20
|
||||||
|
// Copyright 2013-2016 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "NetworkUtils.h"
|
||||||
|
#include <QtNetwork/QNetworkInterface>
|
||||||
|
|
||||||
|
QHostAddress getGuessedLocalAddress() {
|
||||||
|
|
||||||
|
QHostAddress localAddress;
|
||||||
|
|
||||||
|
foreach(const QNetworkInterface &networkInterface, QNetworkInterface::allInterfaces()) {
|
||||||
|
if (networkInterface.flags() & QNetworkInterface::IsUp
|
||||||
|
&& networkInterface.flags() & QNetworkInterface::IsRunning
|
||||||
|
&& networkInterface.flags() & ~QNetworkInterface::IsLoopBack) {
|
||||||
|
// we've decided that this is the active NIC
|
||||||
|
// enumerate it's addresses to grab the IPv4 address
|
||||||
|
foreach(const QNetworkAddressEntry &entry, networkInterface.addressEntries()) {
|
||||||
|
// make sure it's an IPv4 address that isn't the loopback
|
||||||
|
if (entry.ip().protocol() == QAbstractSocket::IPv4Protocol && !entry.ip().isLoopback()) {
|
||||||
|
|
||||||
|
// set our localAddress and break out
|
||||||
|
localAddress = entry.ip();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!localAddress.isNull()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// return the looked up local address
|
||||||
|
return localAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
17
libraries/shared/src/shared/NetworkUtils.h
Normal file
17
libraries/shared/src/shared/NetworkUtils.h
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
//
|
||||||
|
// Created by Bradley Austin Davis on 2016/09/20
|
||||||
|
// Copyright 2013-2016 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#ifndef hifi_shared_NetworkUtils_h
|
||||||
|
#define hifi_shared_NetworkUtils_h
|
||||||
|
|
||||||
|
#include <QtNetwork/QHostAddress>
|
||||||
|
|
||||||
|
QHostAddress getGuessedLocalAddress();
|
||||||
|
|
||||||
|
#endif // hifi_shared_NetworkUtils_h
|
|
@ -32,12 +32,11 @@
|
||||||
|
|
||||||
|
|
||||||
#include <shared/RateCounter.h>
|
#include <shared/RateCounter.h>
|
||||||
|
#include <shared/NetworkUtils.h>
|
||||||
|
#include <shared/FileLogger.h>
|
||||||
|
#include <LogHandler.h>
|
||||||
#include <AssetClient.h>
|
#include <AssetClient.h>
|
||||||
|
|
||||||
//#include <gl/OffscreenGLCanvas.h>
|
|
||||||
//#include <gl/GLHelpers.h>
|
|
||||||
//#include <gl/QOpenGLContextWrapper.h>
|
|
||||||
|
|
||||||
#include <gpu/gl/GLBackend.h>
|
#include <gpu/gl/GLBackend.h>
|
||||||
#include <gpu/gl/GLFramebuffer.h>
|
#include <gpu/gl/GLFramebuffer.h>
|
||||||
#include <gpu/gl/GLTexture.h>
|
#include <gpu/gl/GLTexture.h>
|
||||||
|
@ -149,6 +148,7 @@ public:
|
||||||
|
|
||||||
};
|
};
|
||||||
#else
|
#else
|
||||||
|
|
||||||
class QWindowCamera : public Camera {
|
class QWindowCamera : public Camera {
|
||||||
Key forKey(int key) {
|
Key forKey(int key) {
|
||||||
switch (key) {
|
switch (key) {
|
||||||
|
@ -417,6 +417,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
render::ItemID BackgroundRenderData::_item = 0;
|
render::ItemID BackgroundRenderData::_item = 0;
|
||||||
|
QSharedPointer<FileLogger> logger;
|
||||||
|
|
||||||
namespace render {
|
namespace render {
|
||||||
template <> const ItemKey payloadGetKey(const BackgroundRenderData::Pointer& stuff) {
|
template <> const ItemKey payloadGetKey(const BackgroundRenderData::Pointer& stuff) {
|
||||||
|
@ -1069,12 +1070,14 @@ private:
|
||||||
bool QTestWindow::_cullingEnabled = true;
|
bool QTestWindow::_cullingEnabled = true;
|
||||||
|
|
||||||
void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message) {
|
void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message) {
|
||||||
if (!message.isEmpty()) {
|
QString logMessage = LogHandler::getInstance().printMessage((LogMsgType)type, context, message);
|
||||||
|
|
||||||
|
if (!logMessage.isEmpty()) {
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
OutputDebugStringA(message.toLocal8Bit().constData());
|
OutputDebugStringA(logMessage.toLocal8Bit().constData());
|
||||||
OutputDebugStringA("\n");
|
OutputDebugStringA("\n");
|
||||||
#endif
|
#endif
|
||||||
std::cout << message.toLocal8Bit().constData() << std::endl;
|
logger->addMessage(qPrintable(logMessage + "\n"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1082,11 +1085,14 @@ const char * LOG_FILTER_RULES = R"V0G0N(
|
||||||
hifi.gpu=true
|
hifi.gpu=true
|
||||||
)V0G0N";
|
)V0G0N";
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
QApplication app(argc, argv);
|
QGuiApplication app(argc, argv);
|
||||||
QCoreApplication::setApplicationName("RenderPerf");
|
QCoreApplication::setApplicationName("RenderPerf");
|
||||||
QCoreApplication::setOrganizationName("High Fidelity");
|
QCoreApplication::setOrganizationName("High Fidelity");
|
||||||
QCoreApplication::setOrganizationDomain("highfidelity.com");
|
QCoreApplication::setOrganizationDomain("highfidelity.com");
|
||||||
|
logger.reset(new FileLogger());
|
||||||
|
|
||||||
qInstallMessageHandler(messageHandler);
|
qInstallMessageHandler(messageHandler);
|
||||||
QLoggingCategory::setFilterRules(LOG_FILTER_RULES);
|
QLoggingCategory::setFilterRules(LOG_FILTER_RULES);
|
||||||
QTestWindow::setup();
|
QTestWindow::setup();
|
||||||
|
|
Loading…
Reference in a new issue