Fix priority and formatting on many debug messages

This commit is contained in:
Cameron Gutman 2018-07-25 23:47:32 -07:00
parent 7c74cdc50b
commit b16aac0c06
4 changed files with 25 additions and 22 deletions

View file

@ -140,12 +140,12 @@ NvComputer::NvComputer(QString address, QString serverInfo)
bool NvComputer::wake()
{
if (state == NvComputer::CS_ONLINE) {
qWarning() << name << " is already online";
qWarning() << name << "is already online";
return true;
}
if (macAddress.isNull()) {
qWarning() << name << " has no MAC address stored";
qWarning() << name << "has no MAC address stored";
return false;
}
@ -184,7 +184,7 @@ bool NvComputer::wake()
// Send to all ports
for (quint16 port : WOL_PORTS) {
if (sock.writeDatagram(wolPayload, address, port)) {
qDebug() << "Send WoL packet to " << name << " via " << address.toString() << ":" << port;
qInfo().nospace().noquote() << "Send WoL packet to " << name << " via " << address.toString() << ":" << port;
success = true;
}
}
@ -362,7 +362,7 @@ void ComputerManager::startPolling()
m_MdnsBrowser = new QMdnsEngine::Browser(&m_MdnsServer, "_nvstream._tcp.local.", &m_MdnsCache);
connect(m_MdnsBrowser, &QMdnsEngine::Browser::serviceAdded,
this, [this](const QMdnsEngine::Service& service) {
qDebug() << "Discovered mDNS host: " << service.hostname();
qInfo() << "Discovered mDNS host:" << service.hostname();
MdnsPendingComputer* pendingComputer = new MdnsPendingComputer(&m_MdnsServer, &m_MdnsCache, service);
connect(pendingComputer, SIGNAL(resolvedv4(MdnsPendingComputer*,QHostAddress)),
@ -381,7 +381,7 @@ void ComputerManager::startPolling()
void ComputerManager::handleMdnsServiceResolved(MdnsPendingComputer* computer,
const QHostAddress& address)
{
qDebug() << "Resolved " << computer->hostname() << " to " << address.toString();
qInfo() << "Resolved" << computer->hostname() << "to" << address.toString();
addNewHost(address.toString(), true);

View file

@ -101,7 +101,7 @@ void IdentityManager::createCredentials(QSettings& settings)
settings.setValue(SER_CERT, m_CachedPemCert);
settings.setValue(SER_KEY, m_CachedPrivateKey);
qDebug() << "Wrote new identity credentials to settings";
qInfo() << "Wrote new identity credentials to settings";
}
IdentityManager::IdentityManager()
@ -112,7 +112,7 @@ IdentityManager::IdentityManager()
m_CachedPrivateKey = settings.value(SER_KEY).toByteArray();
if (m_CachedPemCert.isEmpty() || m_CachedPrivateKey.isEmpty()) {
qDebug() << "No existing credentials found";
qInfo() << "No existing credentials found";
createCredentials(settings);
}
else if (getSslCertificate().isNull()) {
@ -191,7 +191,7 @@ IdentityManager::getUniqueId()
// Load the unique ID from settings
m_CachedUniqueId = settings.value(SER_UNIQUEID).toString();
if (!m_CachedUniqueId.isEmpty() && !m_CachedUniqueId.isNull()) {
qDebug() << "Loaded unique ID from settings: " << m_CachedUniqueId;
qInfo() << "Loaded unique ID from settings:" << m_CachedUniqueId;
}
else {
// Generate a new unique ID in base 16
@ -199,7 +199,7 @@ IdentityManager::getUniqueId()
RAND_bytes(reinterpret_cast<unsigned char*>(&uid), sizeof(uid));
m_CachedUniqueId = QString::number(uid, 16);
qDebug() << "Generated new unique ID: " << m_CachedUniqueId;
qInfo() << "Generated new unique ID:" << m_CachedUniqueId;
settings.setValue(SER_UNIQUEID, m_CachedUniqueId);
}

View file

@ -275,7 +275,10 @@ NvHTTP::verifyResponseStatus(QString xml)
else
{
QString statusMessage = xmlReader.attributes().value("status_message").toString();
qDebug() << "Request failed: " << statusCode << " " << statusMessage;
if (statusCode != 401) {
// 401 is expected for unpaired PCs when we fetch serverinfo over HTTPS
qWarning() << "Request failed:" << statusCode << statusMessage;
}
throw GfeHttpResponseException(statusCode, statusMessage);
}
}
@ -376,13 +379,13 @@ NvHTTP::openConnection(QUrl baseUrl,
{
QTimer::singleShot(REQUEST_TIMEOUT_MS, &loop, SLOT(quit()));
}
qDebug() << "Executing request: " << url.toString();
qInfo() << "Executing request:" << url.toString();
loop.exec(QEventLoop::ExcludeUserInputEvents);
// Abort the request if it timed out
if (!reply->isFinished())
{
qDebug() << "Aborting timed out request for " << url.toString();
qWarning() << "Aborting timed out request for" << url.toString();
reply->abort();
}
@ -393,7 +396,7 @@ NvHTTP::openConnection(QUrl baseUrl,
// Handle error
if (reply->error() != QNetworkReply::NoError)
{
qDebug() << command << " request failed with error " << reply->error();
qWarning() << command << " request failed with error " << reply->error();
GfeHttpResponseException exception(reply->error(), reply->errorString());
delete reply;
throw exception;

View file

@ -164,7 +164,7 @@ NvPairingManager::PairState
NvPairingManager::pair(QString appVersion, QString pin)
{
int serverMajorVersion = NvHTTP::parseQuad(appVersion).at(0);
qDebug() << "Pairing with server generation: " << serverMajorVersion;
qInfo() << "Pairing with server generation:" << serverMajorVersion;
QCryptographicHash::Algorithm hashAlgo;
int hashLength;
@ -196,14 +196,14 @@ NvPairingManager::pair(QString appVersion, QString pin)
NvHTTP::verifyResponseStatus(getCert);
if (NvHTTP::getXmlString(getCert, "paired") != "1")
{
qDebug() << "Failed pairing at stage #1";
qCritical() << "Failed pairing at stage #1";
return PairState::FAILED;
}
QByteArray serverCert = NvHTTP::getXmlStringFromHex(getCert, "plaincert");
if (serverCert == nullptr)
{
qDebug() << "Server likely already pairing";
qCritical() << "Server likely already pairing";
m_Http.openConnectionToString(m_Http.m_BaseUrlHttp, "unpair", nullptr, true);
return PairState::ALREADY_IN_PROGRESS;
}
@ -218,7 +218,7 @@ NvPairingManager::pair(QString appVersion, QString pin)
NvHTTP::verifyResponseStatus(challengeXml);
if (NvHTTP::getXmlString(challengeXml, "paired") != "1")
{
qDebug() << "Failed pairing at stage #2";
qCritical() << "Failed pairing at stage #2";
m_Http.openConnectionToString(m_Http.m_BaseUrlHttp, "unpair", nullptr, true);
return PairState::FAILED;
}
@ -251,7 +251,7 @@ NvPairingManager::pair(QString appVersion, QString pin)
NvHTTP::verifyResponseStatus(respXml);
if (NvHTTP::getXmlString(respXml, "paired") != "1")
{
qDebug() << "Failed pairing at stage #3";
qCritical() << "Failed pairing at stage #3";
m_Http.openConnectionToString(m_Http.m_BaseUrlHttp, "unpair", nullptr, true);
return PairState::FAILED;
}
@ -264,7 +264,7 @@ NvPairingManager::pair(QString appVersion, QString pin)
serverSignature,
serverCert))
{
qDebug() << "MITM detected";
qCritical() << "MITM detected";
m_Http.openConnectionToString(m_Http.m_BaseUrlHttp, "unpair", nullptr, true);
return PairState::FAILED;
}
@ -275,7 +275,7 @@ NvPairingManager::pair(QString appVersion, QString pin)
expectedResponseData.append(serverSecret);
if (QCryptographicHash::hash(expectedResponseData, hashAlgo) != serverResponse)
{
qDebug() << "Incorrect PIN";
qCritical() << "Incorrect PIN";
m_Http.openConnectionToString(m_Http.m_BaseUrlHttp, "unpair", nullptr, true);
return PairState::PIN_WRONG;
}
@ -292,7 +292,7 @@ NvPairingManager::pair(QString appVersion, QString pin)
NvHTTP::verifyResponseStatus(secretRespXml);
if (NvHTTP::getXmlString(secretRespXml, "paired") != "1")
{
qDebug() << "Failed pairing at stage #4";
qCritical() << "Failed pairing at stage #4";
m_Http.openConnectionToString(m_Http.m_BaseUrlHttp, "unpair", nullptr, true);
return PairState::FAILED;
}
@ -304,7 +304,7 @@ NvPairingManager::pair(QString appVersion, QString pin)
NvHTTP::verifyResponseStatus(pairChallengeXml);
if (NvHTTP::getXmlString(pairChallengeXml, "paired") != "1")
{
qDebug() << "Failed pairing at stage #5";
qCritical() << "Failed pairing at stage #5";
m_Http.openConnectionToString(m_Http.m_BaseUrlHttp, "unpair", nullptr, true);
return PairState::FAILED;
}