Merge pull request #11326 from cain-kilgore/21537

WL 21537 - Improve log naming
This commit is contained in:
Ryan Huffman 2017-10-06 08:51:42 -07:00 committed by GitHub
commit 9c06afc4c8
4 changed files with 34 additions and 13 deletions

View file

@ -797,8 +797,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
installNativeEventFilter(&MyNativeEventFilter::getInstance());
#endif
_logger = new FileLogger(this); // After setting organization name in order to get correct directory
_logger = new FileLogger(this);
qInstallMessageHandler(messageHandler);
QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "styles/Inconsolata.otf");
@ -814,6 +814,13 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
(new DeadlockWatchdogThread())->start();
}
// Set File Logger Session UUID
auto avatarManager = DependencyManager::get<AvatarManager>();
auto myAvatar = avatarManager ? avatarManager->getMyAvatar() : nullptr;
auto accountManager = DependencyManager::get<AccountManager>();
_logger->setSessionID(accountManager->getSessionID());
if (steamClient) {
qCDebug(interfaceapp) << "[VERSION] SteamVR buildID:" << steamClient->getSteamVRBuildID();
}
@ -930,8 +937,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
// send a location update immediately
discoverabilityManager->updateLocation();
auto myAvatar = getMyAvatar();
connect(nodeList.data(), &NodeList::nodeAdded, this, &Application::nodeAdded);
connect(nodeList.data(), &NodeList::nodeKilled, this, &Application::nodeKilled);
connect(nodeList.data(), &NodeList::nodeActivated, this, &Application::nodeActivated);
@ -942,9 +947,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
// you might think we could just do this in NodeList but we only want this connection for Interface
connect(nodeList.data(), &NodeList::limitOfSilentDomainCheckInsReached, nodeList.data(), &NodeList::reset);
// connect to appropriate slots on AccountManager
auto accountManager = DependencyManager::get<AccountManager>();
auto dialogsManager = DependencyManager::get<DialogsManager>();
connect(accountManager.data(), &AccountManager::authRequired, dialogsManager.data(), &DialogsManager::showLoginDialog);
connect(accountManager.data(), &AccountManager::usernameChanged, this, &Application::updateWindowTitle);
@ -2100,7 +2102,6 @@ Application::~Application() {
_octreeProcessor.terminate();
_entityEditSender.terminate();
DependencyManager::destroy<AvatarManager>();
DependencyManager::destroy<AnimationCache>();
DependencyManager::destroy<FramebufferCache>();

View file

@ -381,7 +381,7 @@ class AvatarData : public QObject, public SpatiallyNestable {
Q_PROPERTY(QStringList jointNames READ getJointNames)
Q_PROPERTY(QUuid sessionUUID READ getSessionUUID)
Q_PROPERTY(QUuid sessionUUID READ getSessionUUID NOTIFY sessionUUIDChanged)
Q_PROPERTY(glm::mat4 sensorToWorldMatrix READ getSensorToWorldMatrix)
Q_PROPERTY(glm::mat4 controllerLeftHandMatrix READ getControllerLeftHandMatrix)
@ -670,13 +670,19 @@ public:
signals:
void displayNameChanged();
void lookAtSnappingChanged(bool enabled);
void sessionUUIDChanged();
public slots:
void sendAvatarDataPacket();
void sendIdentityPacket();
void setJointMappingsFromNetworkReply();
void setSessionUUID(const QUuid& sessionUUID) { setID(sessionUUID); }
void setSessionUUID(const QUuid& sessionUUID) {
if (sessionUUID != getID()) {
setID(sessionUUID);
emit sessionUUIDChanged();
}
}
virtual glm::quat getAbsoluteJointRotationInObjectFrame(int index) const override;
virtual glm::vec3 getAbsoluteJointTranslationInObjectFrame(int index) const override;

View file

@ -26,7 +26,6 @@ class FilePersistThread : public GenericQueueThread < QString > {
Q_OBJECT
public:
FilePersistThread(const FileLogger& logger);
signals:
void rollingLogFile(QString newFilename);
@ -42,12 +41,14 @@ private:
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 LOGS_DIRECTORY = "Logs";
static const QString IPADDR_WILDCARD = "[0-9]*.[0-9]*.[0-9]*.[0-9]*";
static const QString DATETIME_WILDCARD = "20[0-9][0-9]-[0,1][0-9]-[0-3][0-9]_[0-2][0-9].[0-6][0-9].[0-6][0-9]";
static const QString FILENAME_WILDCARD = "hifi-log_" + IPADDR_WILDCARD + "_" + DATETIME_WILDCARD + ".txt";
static QUuid SESSION_ID;
// Max log size is 512 KB. We send log files to our crash reporter, so we want to keep this relatively
// small so it doesn't go over the 2MB zipped limit for all of the files we send.
static const qint64 MAX_LOG_SIZE = 512 * 1024;
@ -62,7 +63,13 @@ QString getLogRollerFilename() {
QString result = FileUtils::standardPath(LOGS_DIRECTORY);
QHostAddress clientAddress = getGuessedLocalAddress();
QDateTime now = QDateTime::currentDateTime();
result.append(QString(FILENAME_FORMAT).arg(clientAddress.toString(), now.toString(DATETIME_FORMAT)));
QString fileSessionID;
if (!SESSION_ID.isNull()) {
fileSessionID = "_" + SESSION_ID.toString().replace("{", "").replace("}", "");
}
result.append(QString(FILENAME_FORMAT).arg(now.toString(DATETIME_FORMAT), fileSessionID));
return result;
}
@ -142,6 +149,12 @@ FileLogger::~FileLogger() {
_persistThreadInstance->terminate();
}
void FileLogger::setSessionID(const QUuid& message) {
// This is for the output of log files. Once the application is first started,
// this function runs and grabs the AccountManager Session ID and saves it here.
SESSION_ID = message;
}
void FileLogger::addMessage(const QString& message) {
_persistThreadInstance->queueItem(message);
emit logReceived(message);

View file

@ -26,6 +26,7 @@ public:
QString getFilename() const { return _fileName; }
virtual void addMessage(const QString&) override;
virtual void setSessionID(const QUuid&);
virtual QString getLogData() override;
virtual void locateLog() override;
virtual void sync() override;