mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-03 06:02:29 -06:00
Use qUtf8Printable() for logging strings
qDebug(), qInfo(), qWarning(), qCritical(), qFatal() expect %s arguments to be UTF-8 encoded, while qPrintable() converts to local 8-bit encoding. Therefore qUtf8Printable() should be used for logging strings instead of qPrintable().
This commit is contained in:
@@ -1658,7 +1658,7 @@ bool Session::deleteTorrent(const QString &hash, bool deleteLocalFiles)
|
||||
TorrentHandle *const torrent = m_torrents.take(hash);
|
||||
if (!torrent) return false;
|
||||
|
||||
qDebug("Deleting torrent with hash: %s", qPrintable(torrent->hash()));
|
||||
qDebug("Deleting torrent with hash: %s", qUtf8Printable(torrent->hash()));
|
||||
emit torrentAboutToBeRemoved(torrent);
|
||||
|
||||
// Remove it from session
|
||||
@@ -1683,10 +1683,10 @@ bool Session::deleteTorrent(const QString &hash, bool deleteLocalFiles)
|
||||
#endif
|
||||
// Remove unwanted and incomplete files
|
||||
foreach (const QString &unwantedFile, unwantedFiles) {
|
||||
qDebug("Removing unwanted file: %s", qPrintable(unwantedFile));
|
||||
qDebug("Removing unwanted file: %s", qUtf8Printable(unwantedFile));
|
||||
Utils::Fs::forceRemove(unwantedFile);
|
||||
const QString parentFolder = Utils::Fs::branchPath(unwantedFile);
|
||||
qDebug("Attempt to remove parent folder (if empty): %s", qPrintable(parentFolder));
|
||||
qDebug("Attempt to remove parent folder (if empty): %s", qUtf8Printable(parentFolder));
|
||||
QDir().rmpath(parentFolder);
|
||||
}
|
||||
}
|
||||
@@ -1954,7 +1954,7 @@ bool Session::addTorrent_impl(AddTorrentData addData, const MagnetUri &magnetUri
|
||||
}
|
||||
|
||||
qDebug("Adding torrent...");
|
||||
qDebug(" -> Hash: %s", qPrintable(hash));
|
||||
qDebug(" -> Hash: %s", qUtf8Printable(hash));
|
||||
|
||||
// Preallocation mode
|
||||
if (isPreallocationEnabled())
|
||||
@@ -2031,8 +2031,8 @@ bool Session::loadMetadata(const MagnetUri &magnetUri)
|
||||
if (m_loadedMetadata.contains(hash)) return false;
|
||||
|
||||
qDebug("Adding torrent to preload metadata...");
|
||||
qDebug(" -> Hash: %s", qPrintable(hash));
|
||||
qDebug(" -> Name: %s", qPrintable(name));
|
||||
qDebug(" -> Hash: %s", qUtf8Printable(hash));
|
||||
qDebug(" -> Name: %s", qUtf8Printable(name));
|
||||
|
||||
libt::add_torrent_params p = magnetUri.addTorrentParams();
|
||||
|
||||
@@ -2114,7 +2114,7 @@ void Session::generateResumeData(bool final)
|
||||
if (!final && !torrent->needSaveResumeData()) continue;
|
||||
|
||||
saveTorrentResumeData(torrent, final);
|
||||
qDebug("Saving fastresume data for %s", qPrintable(torrent->name()));
|
||||
qDebug("Saving fastresume data for %s", qUtf8Printable(torrent->name()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2237,7 +2237,7 @@ const QStringList Session::getListeningIPs()
|
||||
// Attempt to listen on provided interface
|
||||
const QNetworkInterface networkIFace = QNetworkInterface::interfaceFromName(ifaceName);
|
||||
if (!networkIFace.isValid()) {
|
||||
qDebug("Invalid network interface: %s", qPrintable(ifaceName));
|
||||
qDebug("Invalid network interface: %s", qUtf8Printable(ifaceName));
|
||||
logger->addMessage(tr("The network interface defined is invalid: %1").arg(ifaceName), Log::CRITICAL);
|
||||
IPs.append("127.0.0.1"); // Force listening to localhost and avoid accidental connection that will expose user data.
|
||||
return IPs;
|
||||
@@ -3189,7 +3189,7 @@ void Session::handleTorrentFinished(TorrentHandle *const torrent)
|
||||
if (torrentRelpath.endsWith(".torrent", Qt::CaseInsensitive)) {
|
||||
qDebug("Found possible recursive torrent download.");
|
||||
const QString torrentFullpath = torrent->savePath(true) + "/" + torrentRelpath;
|
||||
qDebug("Full subtorrent path is %s", qPrintable(torrentFullpath));
|
||||
qDebug("Full subtorrent path is %s", qUtf8Printable(torrentFullpath));
|
||||
TorrentInfo torrentInfo = TorrentInfo::loadFromFile(torrentFullpath);
|
||||
if (torrentInfo.isValid()) {
|
||||
qDebug("emitting recursiveTorrentDownloadPossible()");
|
||||
@@ -3996,7 +3996,7 @@ namespace
|
||||
{
|
||||
QFile file(path);
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
qDebug("Cannot read file %s: %s", qPrintable(path), qPrintable(file.errorString()));
|
||||
qDebug("Cannot read file %s: %s", qUtf8Printable(path), qUtf8Printable(file.errorString()));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ void TorrentCreatorThread::run()
|
||||
if (isInterruptionRequested()) return;
|
||||
|
||||
// create the torrent and print it to out
|
||||
qDebug("Saving to %s", qPrintable(m_savePath));
|
||||
qDebug("Saving to %s", qUtf8Printable(m_savePath));
|
||||
#ifdef _MSC_VER
|
||||
wchar_t *savePathW = new wchar_t[m_savePath.length() + 1];
|
||||
int len = Utils::Fs::toNativePath(m_savePath).toWCharArray(savePathW);
|
||||
|
||||
@@ -1426,7 +1426,7 @@ void TorrentHandle::resume(bool forced)
|
||||
void TorrentHandle::moveStorage(const QString &newPath, bool overwrite)
|
||||
{
|
||||
if (isMoveInProgress()) {
|
||||
qDebug("enqueue move storage to %s", qPrintable(newPath));
|
||||
qDebug("enqueue move storage to %s", qUtf8Printable(newPath));
|
||||
m_moveStorageInfo.queuedPath = newPath;
|
||||
m_moveStorageInfo.queuedOverwrite = overwrite;
|
||||
}
|
||||
@@ -1434,7 +1434,7 @@ void TorrentHandle::moveStorage(const QString &newPath, bool overwrite)
|
||||
const QString oldPath = nativeActualSavePath();
|
||||
if (QDir(oldPath) == QDir(newPath)) return;
|
||||
|
||||
qDebug("move storage: %s to %s", qPrintable(oldPath), qPrintable(newPath));
|
||||
qDebug("move storage: %s to %s", qUtf8Printable(oldPath), qUtf8Printable(newPath));
|
||||
// Actually move the storage
|
||||
m_nativeHandle.move_storage(newPath.toUtf8().constData()
|
||||
, (overwrite ? libt::always_replace_files : libt::dont_replace));
|
||||
@@ -1506,7 +1506,8 @@ void TorrentHandle::handleStorageMovedAlert(libtorrent::storage_moved_alert *p)
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug("Torrent is successfully moved from %s to %s", qPrintable(m_moveStorageInfo.oldPath), qPrintable(m_moveStorageInfo.newPath));
|
||||
qDebug("Torrent is successfully moved from %s to %s"
|
||||
, qUtf8Printable(m_moveStorageInfo.oldPath), qUtf8Printable(m_moveStorageInfo.newPath));
|
||||
const QDir oldDir {m_moveStorageInfo.oldPath};
|
||||
if ((oldDir == QDir(m_session->torrentTempPath(info())))
|
||||
&& (oldDir != QDir(m_session->tempPath()))) {
|
||||
@@ -1559,7 +1560,7 @@ void TorrentHandle::handleTrackerReplyAlert(libtorrent::tracker_reply_alert *p)
|
||||
#else
|
||||
QString trackerUrl(p->tracker_url());
|
||||
#endif
|
||||
qDebug("Received a tracker reply from %s (Num_peers = %d)", qPrintable(trackerUrl), p->num_peers);
|
||||
qDebug("Received a tracker reply from %s (Num_peers = %d)", qUtf8Printable(trackerUrl), p->num_peers);
|
||||
// Connection was successful now. Remove possible old errors
|
||||
m_trackerInfos[trackerUrl].lastMessage.clear(); // Reset error/warning message
|
||||
m_trackerInfos[trackerUrl].numPeers = p->num_peers;
|
||||
@@ -1576,7 +1577,7 @@ void TorrentHandle::handleTrackerWarningAlert(libtorrent::tracker_warning_alert
|
||||
QString trackerUrl(p->tracker_url());
|
||||
QString message = QString::fromStdString(p->message());
|
||||
#endif
|
||||
qDebug("Received a tracker warning for %s: %s", qPrintable(trackerUrl), qPrintable(message));
|
||||
qDebug("Received a tracker warning for %s: %s", qUtf8Printable(trackerUrl), qUtf8Printable(message));
|
||||
// Connection was successful now but there is a warning message
|
||||
m_trackerInfos[trackerUrl].lastMessage = message; // Store warning message
|
||||
|
||||
@@ -1592,7 +1593,7 @@ void TorrentHandle::handleTrackerErrorAlert(libtorrent::tracker_error_alert *p)
|
||||
QString trackerUrl(p->tracker_url());
|
||||
QString message = QString::fromStdString(p->message());
|
||||
#endif
|
||||
qDebug("Received a tracker error for %s: %s", qPrintable(trackerUrl), qPrintable(message));
|
||||
qDebug("Received a tracker error for %s: %s", qUtf8Printable(trackerUrl), qUtf8Printable(message));
|
||||
m_trackerInfos[trackerUrl].lastMessage = message;
|
||||
|
||||
if (p->status_code == 401)
|
||||
@@ -1604,7 +1605,7 @@ void TorrentHandle::handleTrackerErrorAlert(libtorrent::tracker_error_alert *p)
|
||||
void TorrentHandle::handleTorrentCheckedAlert(libtorrent::torrent_checked_alert *p)
|
||||
{
|
||||
Q_UNUSED(p);
|
||||
qDebug("%s have just finished checking", qPrintable(hash()));
|
||||
qDebug("%s have just finished checking", qUtf8Printable(hash()));
|
||||
|
||||
updateStatus();
|
||||
|
||||
@@ -1627,7 +1628,7 @@ void TorrentHandle::handleTorrentCheckedAlert(libtorrent::torrent_checked_alert
|
||||
void TorrentHandle::handleTorrentFinishedAlert(libtorrent::torrent_finished_alert *p)
|
||||
{
|
||||
Q_UNUSED(p);
|
||||
qDebug("Got a torrent finished alert for %s", qPrintable(name()));
|
||||
qDebug("Got a torrent finished alert for %s", qUtf8Printable(name()));
|
||||
qDebug("Torrent has seed status: %s", m_hasSeedStatus ? "yes" : "no");
|
||||
if (m_hasSeedStatus) return;
|
||||
|
||||
@@ -1711,7 +1712,7 @@ void TorrentHandle::handleSaveResumeDataFailedAlert(libtorrent::save_resume_data
|
||||
|
||||
void TorrentHandle::handleFastResumeRejectedAlert(libtorrent::fastresume_rejected_alert *p)
|
||||
{
|
||||
qDebug("/!\\ Fast resume failed for %s, reason: %s", qPrintable(name()), p->message().c_str());
|
||||
qDebug("/!\\ Fast resume failed for %s, reason: %s", qUtf8Printable(name()), p->message().c_str());
|
||||
Logger *const logger = Logger::instance();
|
||||
|
||||
updateStatus();
|
||||
@@ -1746,9 +1747,9 @@ void TorrentHandle::handleFileRenamedAlert(libtorrent::file_renamed_alert *p)
|
||||
newPathParts.removeLast();
|
||||
QString newPath = newPathParts.join("/");
|
||||
if (!newPathParts.isEmpty() && (oldPath != newPath)) {
|
||||
qDebug("oldPath(%s) != newPath(%s)", qPrintable(oldPath), qPrintable(newPath));
|
||||
qDebug("oldPath(%s) != newPath(%s)", qUtf8Printable(oldPath), qUtf8Printable(newPath));
|
||||
oldPath = QString("%1/%2").arg(savePath(true)).arg(oldPath);
|
||||
qDebug("Detected folder renaming, attempt to delete old folder: %s", qPrintable(oldPath));
|
||||
qDebug("Detected folder renaming, attempt to delete old folder: %s", qUtf8Printable(oldPath));
|
||||
QDir().rmpath(oldPath);
|
||||
}
|
||||
}
|
||||
@@ -1773,13 +1774,13 @@ void TorrentHandle::handleFileCompletedAlert(libtorrent::file_completed_alert *p
|
||||
{
|
||||
updateStatus();
|
||||
|
||||
qDebug("A file completed download in torrent \"%s\"", qPrintable(name()));
|
||||
qDebug("A file completed download in torrent \"%s\"", qUtf8Printable(name()));
|
||||
if (m_session->isAppendExtensionEnabled()) {
|
||||
QString name = filePath(p->index);
|
||||
if (name.endsWith(QB_EXT)) {
|
||||
const QString oldName = name;
|
||||
name.chop(QB_EXT.size());
|
||||
qDebug("Renaming %s to %s", qPrintable(oldName), qPrintable(name));
|
||||
qDebug("Renaming %s to %s", qUtf8Printable(oldName), qUtf8Printable(name));
|
||||
renameFile(p->index, name);
|
||||
}
|
||||
}
|
||||
@@ -1796,7 +1797,7 @@ void TorrentHandle::handleStatsAlert(libtorrent::stats_alert *p)
|
||||
void TorrentHandle::handleMetadataReceivedAlert(libt::metadata_received_alert *p)
|
||||
{
|
||||
Q_UNUSED(p);
|
||||
qDebug("Metadata received for torrent %s.", qPrintable(name()));
|
||||
qDebug("Metadata received for torrent %s.", qUtf8Printable(name()));
|
||||
updateStatus();
|
||||
if (m_session->isAppendExtensionEnabled())
|
||||
manageIncompleteFiles();
|
||||
|
||||
@@ -67,7 +67,7 @@ TorrentInfo TorrentInfo::loadFromFile(const QString &path, QString &error)
|
||||
TorrentInfo info(NativePtr(new libt::torrent_info(Utils::Fs::toNativePath(path).toStdString(), ec)));
|
||||
if (ec) {
|
||||
error = QString::fromUtf8(ec.message().c_str());
|
||||
qDebug("Cannot load .torrent file: %s", qPrintable(error));
|
||||
qDebug("Cannot load .torrent file: %s", qUtf8Printable(error));
|
||||
}
|
||||
|
||||
return info;
|
||||
|
||||
@@ -109,14 +109,14 @@ Http::Response Tracker::processRequest(const Http::Request &request, const Http:
|
||||
{
|
||||
clear(); // clear response
|
||||
|
||||
//qDebug("Tracker received the following request:\n%s", qPrintable(parser.toString()));
|
||||
//qDebug("Tracker received the following request:\n%s", qUtf8Printable(parser.toString()));
|
||||
// Is request a GET request?
|
||||
if (request.method != "GET") {
|
||||
qDebug("Tracker: Unsupported HTTP request: %s", qPrintable(request.method));
|
||||
qDebug("Tracker: Unsupported HTTP request: %s", qUtf8Printable(request.method));
|
||||
status(100, "Invalid request type");
|
||||
}
|
||||
else if (!request.path.startsWith("/announce", Qt::CaseInsensitive)) {
|
||||
qDebug("Tracker: Unrecognized path: %s", qPrintable(request.path));
|
||||
qDebug("Tracker: Unrecognized path: %s", qUtf8Printable(request.path));
|
||||
status(100, "Invalid request type");
|
||||
}
|
||||
else {
|
||||
@@ -146,7 +146,7 @@ void Tracker::respondToAnnounceRequest()
|
||||
annonceReq.infoHash = gets.value("info_hash");
|
||||
// info_hash cannot be longer than 20 bytes
|
||||
/*if (annonce_req.info_hash.toLatin1().length() > 20) {
|
||||
qDebug("Tracker: Info_hash is not 20 byte long: %s (%d)", qPrintable(annonce_req.info_hash), annonce_req.info_hash.toLatin1().length());
|
||||
qDebug("Tracker: Info_hash is not 20 byte long: %s (%d)", qUtf8Printable(annonce_req.info_hash), annonce_req.info_hash.toLatin1().length());
|
||||
status(150, "Invalid infohash");
|
||||
return;
|
||||
}*/
|
||||
@@ -160,7 +160,7 @@ void Tracker::respondToAnnounceRequest()
|
||||
annonceReq.peer.peerId = gets.value("peer_id");
|
||||
// peer_id cannot be longer than 20 bytes
|
||||
/*if (annonce_req.peer.peer_id.length() > 20) {
|
||||
qDebug("Tracker: peer_id is not 20 byte long: %s", qPrintable(annonce_req.peer.peer_id));
|
||||
qDebug("Tracker: peer_id is not 20 byte long: %s", qUtf8Printable(annonce_req.peer.peer_id));
|
||||
status(151, "Invalid peerid");
|
||||
return;
|
||||
}*/
|
||||
@@ -183,7 +183,7 @@ void Tracker::respondToAnnounceRequest()
|
||||
annonceReq.event = "";
|
||||
if (gets.contains("event")) {
|
||||
annonceReq.event = gets.value("event");
|
||||
qDebug("Tracker: event is %s", qPrintable(annonceReq.event));
|
||||
qDebug("Tracker: event is %s", qUtf8Printable(annonceReq.event));
|
||||
}
|
||||
|
||||
// 5. Get numwant
|
||||
|
||||
Reference in New Issue
Block a user