Merge pull request #2973 from Diapolo/qDebug

Bitcoin-Qt: Use qDebug() for printing to debug.log
This commit is contained in:
Wladimir J. van der Laan 2013-09-06 03:26:02 -07:00
commit 9d6b60cf50
7 changed files with 67 additions and 52 deletions

View File

@ -7,6 +7,7 @@
#include "base58.h"
#include <QFont>
#include <QDebug>
const QString AddressTableModel::Send = "S";
const QString AddressTableModel::Receive = "R";
@ -109,7 +110,7 @@ public:
case CT_NEW:
if(inModel)
{
OutputDebugStringF("Warning: AddressTablePriv::updateEntry: Got CT_NOW, but entry is already in model\n");
qDebug() << "AddressTablePriv::updateEntry : Warning: Got CT_NOW, but entry is already in model";
break;
}
parent->beginInsertRows(QModelIndex(), lowerIndex, lowerIndex);
@ -119,7 +120,7 @@ public:
case CT_UPDATED:
if(!inModel)
{
OutputDebugStringF("Warning: AddressTablePriv::updateEntry: Got CT_UPDATED, but entry is not in model\n");
qDebug() << "AddressTablePriv::updateEntry : Warning: Got CT_UPDATED, but entry is not in model";
break;
}
lower->type = newEntryType;
@ -129,7 +130,7 @@ public:
case CT_DELETED:
if(!inModel)
{
OutputDebugStringF("Warning: AddressTablePriv::updateEntry: Got CT_DELETED, but entry is not in model\n");
qDebug() << "AddressTablePriv::updateEntry : Warning: Got CT_DELETED, but entry is not in model";
break;
}
parent->beginRemoveRows(QModelIndex(), lowerIndex, upperIndex-1);

View File

@ -13,6 +13,7 @@
#include <QDateTime>
#include <QTimer>
#include <QDebug>
static const int64 nClientStartupTime = GetTime();
@ -180,14 +181,14 @@ static void NotifyBlocksChanged(ClientModel *clientmodel)
static void NotifyNumConnectionsChanged(ClientModel *clientmodel, int newNumConnections)
{
// Too noisy: OutputDebugStringF("NotifyNumConnectionsChanged %i\n", newNumConnections);
// Too noisy: qDebug() << "NotifyNumConnectionsChanged : " + QString::number(newNumConnections);
QMetaObject::invokeMethod(clientmodel, "updateNumConnections", Qt::QueuedConnection,
Q_ARG(int, newNumConnections));
}
static void NotifyAlertChanged(ClientModel *clientmodel, const uint256 &hash, ChangeType status)
{
OutputDebugStringF("NotifyAlertChanged %s status=%i\n", hash.GetHex().c_str(), status);
qDebug() << "NotifyAlertChanged : " + QString::fromStdString(hash.GetHex()) + " status=" + QString::number(status);
QMetaObject::invokeMethod(clientmodel, "updateAlert", Qt::QueuedConnection,
Q_ARG(QString, QString::fromStdString(hash.GetHex())),
Q_ARG(int, status));

View File

@ -60,8 +60,8 @@ private:
int cachedNumBlocks;
int cachedNumBlocksOfPeers;
bool cachedReindexing;
bool cachedImporting;
bool cachedReindexing;
bool cachedImporting;
int numBlocksAtStartup;

View File

@ -24,18 +24,18 @@ bool PaymentRequestPlus::parse(const QByteArray& data)
{
bool parseOK = paymentRequest.ParseFromArray(data.data(), data.size());
if (!parseOK) {
qDebug() << "Error parsing payment request";
qDebug() << "PaymentRequestPlus::parse : Error parsing payment request";
return false;
}
if (paymentRequest.payment_details_version() > 1) {
qDebug() << "Received up-version payment details, version=" << paymentRequest.payment_details_version();
qDebug() << "PaymentRequestPlus::parse : Received up-version payment details, version=" << paymentRequest.payment_details_version();
return false;
}
parseOK = details.ParseFromString(paymentRequest.serialized_payment_details());
if (!parseOK)
{
qDebug() << "Error parsing payment details";
qDebug() << "PaymentRequestPlus::parse : Error parsing payment details";
paymentRequest.Clear();
return false;
}
@ -75,17 +75,18 @@ bool PaymentRequestPlus::getMerchant(X509_STORE* certStore, QString& merchant) c
digestAlgorithm = EVP_sha1();
}
else if (paymentRequest.pki_type() == "none") {
if (fDebug) qDebug() << "PaymentRequest: pki_type == none";
if (fDebug)
qDebug() << "PaymentRequestPlus::getMerchant : Payment request: pki_type == none";
return false;
}
else {
qDebug() << "PaymentRequest: unknown pki_type " << paymentRequest.pki_type().c_str();
qDebug() << "PaymentRequestPlus::getMerchant : Payment request: unknown pki_type " << paymentRequest.pki_type().c_str();
return false;
}
payments::X509Certificates certChain;
if (!certChain.ParseFromString(paymentRequest.pki_data())) {
qDebug() << "PaymentRequest: error parsing pki_data";
qDebug() << "PaymentRequestPlus::getMerchant : Payment request: error parsing pki_data";
return false;
}
@ -95,12 +96,12 @@ bool PaymentRequestPlus::getMerchant(X509_STORE* certStore, QString& merchant) c
QByteArray certData(certChain.certificate(i).data(), certChain.certificate(i).size());
QSslCertificate qCert(certData, QSsl::Der);
if (currentTime < qCert.effectiveDate() || currentTime > qCert.expiryDate()) {
qDebug() << "PaymentRequest: certificate expired or not yet active: " << qCert;
qDebug() << "PaymentRequestPlus::getMerchant : Payment request: certificate expired or not yet active: " << qCert;
return false;
}
#if QT_VERSION >= 0x050000
if (qCert.isBlacklisted()) {
qDebug() << "PaymentRequest: certificate blacklisted: " << qCert;
qDebug() << "PaymentRequestPlus::getMerchant : Payment request: certificate blacklisted: " << qCert;
return false;
}
#endif
@ -110,7 +111,7 @@ bool PaymentRequestPlus::getMerchant(X509_STORE* certStore, QString& merchant) c
certs.push_back(cert);
}
if (certs.empty()) {
qDebug() << "PaymentRequest: empty certificate chain";
qDebug() << "PaymentRequestPlus::getMerchant : Payment request: empty certificate chain";
return false;
}
@ -126,7 +127,7 @@ bool PaymentRequestPlus::getMerchant(X509_STORE* certStore, QString& merchant) c
// load the signing cert into it and verify.
X509_STORE_CTX *store_ctx = X509_STORE_CTX_new();
if (!store_ctx) {
qDebug() << "PaymentRequest: error creating X509_STORE_CTX";
qDebug() << "PaymentRequestPlus::getMerchant : Payment request: error creating X509_STORE_CTX";
return false;
}
@ -171,14 +172,14 @@ bool PaymentRequestPlus::getMerchant(X509_STORE* certStore, QString& merchant) c
merchant = website;
}
else {
throw SSLVerifyError("Bad certificate, missing common name");
throw SSLVerifyError("Bad certificate, missing common name.");
}
// TODO: detect EV certificates and set merchant = business name instead of unfriendly NID_commonName ?
}
catch (SSLVerifyError& err)
{
fResult = false;
qDebug() << "PaymentRequestPlus::getMerchant SSL err: " << err.what();
qDebug() << "PaymentRequestPlus::getMerchant : SSL error: " << err.what();
}
if (website)

View File

@ -89,7 +89,7 @@ static QList<QString> savedPaymentRequests;
static void ReportInvalidCertificate(const QSslCertificate& cert)
{
if (fDebug) {
qDebug() << "Invalid certificate: " << cert.subjectInfo(QSslCertificate::CommonName);
qDebug() << "ReportInvalidCertificate : Payment server found an invalid certificate: " << cert.subjectInfo(QSslCertificate::CommonName);
}
}
@ -162,7 +162,7 @@ void PaymentServer::LoadRootCAs(X509_STORE* _store)
}
}
if (fDebug)
qDebug() << "PaymentServer: loaded " << nRootCerts << " root certificates";
qDebug() << "PaymentServer::LoadRootCAs : Loaded " << nRootCerts << " root certificates";
// Project for another day:
// Fetch certificate revocation lists, and add them to certStore.
@ -221,7 +221,7 @@ bool PaymentServer::ipcSendCommandLine(int argc, char* argv[])
}
else
{
qDebug() << "Payment request file does not exist: " << argv[i];
qDebug() << "PaymentServer::ipcSendCommandLine : Payment request file does not exist: " << argv[i];
// Printing to debug.log is about the best we can do here, the
// GUI hasn't started yet so we can't pop up a message box.
}
@ -271,7 +271,7 @@ PaymentServer::PaymentServer(QObject* parent,
uriServer = new QLocalServer(this);
if (!uriServer->listen(name))
qDebug() << "Cannot start bitcoin: click-to-pay handler";
qDebug() << "PaymentServer::PaymentServer : Cannot start bitcoin: click-to-pay handler";
else
connect(uriServer, SIGNAL(newConnection()), this, SLOT(handleURIConnection()));
}
@ -366,12 +366,13 @@ void PaymentServer::handleURIOrFile(const QString& s)
QString decoded = QUrl::fromPercentEncoding(temp);
QUrl fetchUrl(decoded, QUrl::StrictMode);
if (fDebug) qDebug() << "PaymentServer::fetchRequest " << fetchUrl;
if (fDebug)
qDebug() << "PaymentServer::handleURIOrFile : fetchRequest(" << fetchUrl << ")";
if (fetchUrl.isValid())
fetchRequest(fetchUrl);
else
qDebug() << "PaymentServer: invalid url: " << fetchUrl;
qDebug() << "PaymentServer::handleURIOrFile : Invalid url: " << fetchUrl;
return;
}
@ -420,13 +421,13 @@ bool PaymentServer::readPaymentRequest(const QString& filename, PaymentRequestPl
QFile f(filename);
if (!f.open(QIODevice::ReadOnly))
{
qDebug() << "PaymentServer::readPaymentRequest fail to open " << filename;
qDebug() << "PaymentServer::readPaymentRequest : Failed to open " << filename;
return false;
}
if (f.size() > MAX_PAYMENT_REQUEST_SIZE)
{
qDebug() << "PaymentServer::readPaymentRequest " << filename << " too large";
qDebug() << "PaymentServer::readPaymentRequest : " << filename << " too large";
return false;
}
@ -449,7 +450,8 @@ PaymentServer::processPaymentRequest(PaymentRequestPlus& request,
if (txOut.IsDust(CTransaction::nMinRelayTxFee)) {
QString message = QObject::tr("Requested payment amount (%1) too small")
.arg(BitcoinUnits::formatWithUnit(optionsModel->getDisplayUnit(), sendingTo.second));
qDebug() << message;
qDebug() << "PaymentServer::processPaymentRequest : " << message;
emit reportError(tr("Payment request error"), message, CClientUIInterface::MODAL);
return false;
}
@ -462,7 +464,8 @@ PaymentServer::processPaymentRequest(PaymentRequestPlus& request,
if (request.getMerchant(PaymentServer::certStore, recipients[0].authenticatedMerchant)) {
recipients[0].paymentRequest = request;
recipients[0].amount = totalAmount;
if (fDebug) qDebug() << "PaymentRequest from " << recipients[0].authenticatedMerchant;
if (fDebug)
qDebug() << "PaymentServer::processPaymentRequest : Payment request from " << recipients[0].authenticatedMerchant;
}
else {
recipients.clear();
@ -483,7 +486,8 @@ PaymentServer::processPaymentRequest(PaymentRequestPlus& request,
if (i == 0) // Tie request to first pay-to, we don't want multiple ACKs
recipients[i].paymentRequest = request;
recipients[i].address = QString::fromStdString(CBitcoinAddress(dest).ToString());
if (fDebug) qDebug() << "PaymentRequest, insecure " << recipients[i].address;
if (fDebug)
qDebug() << "PaymentServer::processPaymentRequest : Payment request, insecure " << recipients[i].address;
}
else {
// Insecure payments to custom bitcoin addresses are not supported
@ -551,7 +555,7 @@ PaymentServer::fetchPaymentACK(CWallet* wallet, SendCoinsRecipient recipient, QB
else {
// This should never happen, because sending coins should have just unlocked the wallet
// and refilled the keypool
qDebug() << "Error getting refund key, refund_to not set";
qDebug() << "PaymentServer::fetchPaymentACK : Error getting refund key, refund_to not set";
}
}
@ -563,7 +567,7 @@ PaymentServer::fetchPaymentACK(CWallet* wallet, SendCoinsRecipient recipient, QB
}
else {
// This should never happen, either:
qDebug() << "Error serializing payment message";
qDebug() << "PaymentServer::fetchPaymentACK : Error serializing payment message";
}
}
@ -576,7 +580,7 @@ PaymentServer::netRequestFinished(QNetworkReply* reply)
QString message = QObject::tr("Error communicating with %1: %2")
.arg(reply->request().url().toString())
.arg(reply->errorString());
qDebug() << message;
qDebug() << "PaymentServer::netRequestFinished : " << message;
emit reportError(tr("Network request error"), message, CClientUIInterface::MODAL);
return;
}
@ -594,7 +598,7 @@ PaymentServer::netRequestFinished(QNetworkReply* reply)
}
}
else
qDebug() << "PaymentServer::netRequestFinished: error processing PaymentRequest";
qDebug() << "PaymentServer::netRequestFinished : Error processing payment request";
return;
}
else if (requestType == "PaymentACK")
@ -604,7 +608,7 @@ PaymentServer::netRequestFinished(QNetworkReply* reply)
{
QString message = QObject::tr("Bad response from server %1")
.arg(reply->request().url().toString());
qDebug() << message;
qDebug() << "PaymentServer::netRequestFinished : " << message;
emit reportError(tr("Network request error"), message, CClientUIInterface::MODAL);
}
else {
@ -618,7 +622,7 @@ PaymentServer::reportSslErrors(QNetworkReply* reply, const QList<QSslError> &err
{
QString errString;
foreach (const QSslError& err, errs) {
qDebug() << err;
qDebug() << "PaymentServer::reportSslErrors : " << err;
errString += err.errorString() + "\n";
}
emit reportError(tr("Network request error"), errString, CClientUIInterface::MODAL);

View File

@ -17,6 +17,7 @@
#include <QTimer>
#include <QIcon>
#include <QDateTime>
#include <QDebug>
// Amount column is right-aligned it contains numbers
static int column_alignments[] = {
@ -67,7 +68,7 @@ public:
*/
void refreshWallet()
{
OutputDebugStringF("refreshWallet\n");
qDebug() << "TransactionTablePriv::refreshWallet";
cachedWallet.clear();
{
LOCK(wallet->cs_wallet);
@ -86,7 +87,7 @@ public:
*/
void updateWallet(const uint256 &hash, int status)
{
OutputDebugStringF("updateWallet %s %i\n", hash.ToString().c_str(), status);
qDebug() << "TransactionTablePriv::updateWallet : " + QString::fromStdString(hash.ToString()) + " " + QString::number(status);
{
LOCK(wallet->cs_wallet);
@ -114,20 +115,21 @@ public:
status = CT_DELETED; /* In model, but want to hide, treat as deleted */
}
OutputDebugStringF(" inWallet=%i inModel=%i Index=%i-%i showTransaction=%i derivedStatus=%i\n",
inWallet, inModel, lowerIndex, upperIndex, showTransaction, status);
qDebug() << " inWallet=" + QString::number(inWallet) + " inModel=" + QString::number(inModel) +
" Index=" + QString::number(lowerIndex) + "-" + QString::number(upperIndex) +
" showTransaction=" + QString::number(showTransaction) + " derivedStatus=" + QString::number(status);
switch(status)
{
case CT_NEW:
if(inModel)
{
OutputDebugStringF("Warning: updateWallet: Got CT_NEW, but transaction is already in model\n");
qDebug() << "TransactionTablePriv::updateWallet : Warning: Got CT_NEW, but transaction is already in model";
break;
}
if(!inWallet)
{
OutputDebugStringF("Warning: updateWallet: Got CT_NEW, but transaction is not in wallet\n");
qDebug() << "TransactionTablePriv::updateWallet : Warning: Got CT_NEW, but transaction is not in wallet";
break;
}
if(showTransaction)
@ -151,7 +153,7 @@ public:
case CT_DELETED:
if(!inModel)
{
OutputDebugStringF("Warning: updateWallet: Got CT_DELETED, but transaction is not in model\n");
qDebug() << "TransactionTablePriv::updateWallet : Warning: Got CT_DELETED, but transaction is not in model";
break;
}
// Removed -- remove entire transaction from table

View File

@ -10,6 +10,7 @@
#include <QSet>
#include <QTimer>
#include <QDebug>
WalletModel::WalletModel(CWallet *wallet, OptionsModel *optionsModel, QObject *parent) :
QObject(parent), wallet(wallet), optionsModel(optionsModel), addressTableModel(0),
@ -111,7 +112,7 @@ void WalletModel::updateTransaction(const QString &hash, int status)
}
}
void WalletModel::updateAddressBook(const QString &address, const QString &label,
void WalletModel::updateAddressBook(const QString &address, const QString &label,
bool isMine, const QString &purpose, int status)
{
if(addressTableModel)
@ -359,7 +360,7 @@ bool WalletModel::backupWallet(const QString &filename)
// Handlers for core signals
static void NotifyKeyStoreStatusChanged(WalletModel *walletmodel, CCryptoKeyStore *wallet)
{
OutputDebugStringF("NotifyKeyStoreStatusChanged\n");
qDebug() << "NotifyKeyStoreStatusChanged";
QMetaObject::invokeMethod(walletmodel, "updateStatus", Qt::QueuedConnection);
}
@ -367,21 +368,26 @@ static void NotifyAddressBookChanged(WalletModel *walletmodel, CWallet *wallet,
const CTxDestination &address, const std::string &label, bool isMine,
const std::string &purpose, ChangeType status)
{
OutputDebugStringF("NotifyAddressBookChanged %s %s isMine=%i purpose=%s status=%i\n",
CBitcoinAddress(address).ToString().c_str(), label.c_str(), isMine, purpose.c_str(), status);
QString strAddress = QString::fromStdString(CBitcoinAddress(address).ToString());
QString strLabel = QString::fromStdString(label);
QString strPurpose = QString::fromStdString(purpose);
qDebug() << "NotifyAddressBookChanged : " + strAddress + " " + strLabel + " isMine=" + QString::number(isMine) + " purpose=" + strPurpose + " status=" + QString::number(status);
QMetaObject::invokeMethod(walletmodel, "updateAddressBook", Qt::QueuedConnection,
Q_ARG(QString, QString::fromStdString(CBitcoinAddress(address).ToString())),
Q_ARG(QString, QString::fromStdString(label)),
Q_ARG(QString, strAddress),
Q_ARG(QString, strLabel),
Q_ARG(bool, isMine),
Q_ARG(QString, QString::fromStdString(purpose)),
Q_ARG(QString, strPurpose),
Q_ARG(int, status));
}
static void NotifyTransactionChanged(WalletModel *walletmodel, CWallet *wallet, const uint256 &hash, ChangeType status)
{
OutputDebugStringF("NotifyTransactionChanged %s status=%i\n", hash.GetHex().c_str(), status);
QString strHash = QString::fromStdString(hash.GetHex());
qDebug() << "NotifyTransactionChanged : " + strHash + " status= " + QString::number(status);
QMetaObject::invokeMethod(walletmodel, "updateTransaction", Qt::QueuedConnection,
Q_ARG(QString, QString::fromStdString(hash.GetHex())),
Q_ARG(QString, strHash),
Q_ARG(int, status));
}