diff data/fileio/FileSource.cpp @ 687:06f13a3b9e9e debug-output

Convert many cerrs to DEBUGs
author Chris Cannam
date Mon, 16 May 2011 17:19:09 +0100
parents b4a8d8221eaf
children 1424aa29ae95
line wrap: on
line diff
--- a/data/fileio/FileSource.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/data/fileio/FileSource.cpp	Mon May 16 17:19:09 2011 +0100
@@ -88,12 +88,12 @@
     }
  
 #ifdef DEBUG_FILE_SOURCE
-    std::cerr << "FileSource::FileSource(" << fileOrUrl << "): url <" << m_url.toString() << ">" << std::endl;
+    DEBUG << "FileSource::FileSource(" << fileOrUrl << "): url <" << m_url.toString() << ">" << endl;
     incCount(m_url.toString());
 #endif
 
     if (!canHandleScheme(m_url)) {
-        std::cerr << "FileSource::FileSource: ERROR: Unsupported scheme in URL \"" << m_url.toString() << "\"" << std::endl;
+        DEBUG << "FileSource::FileSource: ERROR: Unsupported scheme in URL \"" << m_url.toString() << "\"" << endl;
         m_errorString = tr("Unsupported scheme in URL");
         return;
     }
@@ -148,7 +148,7 @@
     }
 
 #ifdef DEBUG_FILE_SOURCE
-    std::cerr << "FileSource::FileSource(string) exiting" << std::endl;
+    DEBUG << "FileSource::FileSource(string) exiting" << endl;
 #endif
 }
 
@@ -166,12 +166,12 @@
     m_refCounted(false)
 {
 #ifdef DEBUG_FILE_SOURCE
-    std::cerr << "FileSource::FileSource(" << url.toString() << ") [as url]" << std::endl;
+    DEBUG << "FileSource::FileSource(" << url.toString() << ") [as url]" << endl;
     incCount(m_url.toString());
 #endif
 
     if (!canHandleScheme(m_url)) {
-        std::cerr << "FileSource::FileSource: ERROR: Unsupported scheme in URL \"" << m_url.toString() << "\"" << std::endl;
+        DEBUG << "FileSource::FileSource: ERROR: Unsupported scheme in URL \"" << m_url.toString() << "\"" << endl;
         m_errorString = tr("Unsupported scheme in URL");
         return;
     }
@@ -179,7 +179,7 @@
     init();
 
 #ifdef DEBUG_FILE_SOURCE
-    std::cerr << "FileSource::FileSource(url) exiting" << std::endl;
+    DEBUG << "FileSource::FileSource(url) exiting" << endl;
 #endif
 }
 
@@ -198,12 +198,12 @@
     m_refCounted(false)
 {
 #ifdef DEBUG_FILE_SOURCE
-    std::cerr << "FileSource::FileSource(" << m_url.toString() << ") [copy ctor]" << std::endl;
+    DEBUG << "FileSource::FileSource(" << m_url.toString() << ") [copy ctor]" << endl;
     incCount(m_url.toString());
 #endif
 
     if (!canHandleScheme(m_url)) {
-        std::cerr << "FileSource::FileSource: ERROR: Unsupported scheme in URL \"" << m_url.toString() << "\"" << std::endl;
+        DEBUG << "FileSource::FileSource: ERROR: Unsupported scheme in URL \"" << m_url.toString() << "\"" << endl;
         m_errorString = tr("Unsupported scheme in URL");
         return;
     }
@@ -213,8 +213,8 @@
     } else {
         QMutexLocker locker(&m_mapMutex);
 #ifdef DEBUG_FILE_SOURCE
-        std::cerr << "FileSource::FileSource(copy ctor): ref count is "
-                  << m_refCountMap[m_url] << std::endl;
+        DEBUG << "FileSource::FileSource(copy ctor): ref count is "
+                  << m_refCountMap[m_url] << endl;
 #endif
         if (m_refCountMap[m_url] > 0) {
             m_refCountMap[m_url]++;
@@ -232,11 +232,11 @@
     m_done = true;
 
 #ifdef DEBUG_FILE_SOURCE
-    std::cerr << "FileSource::FileSource(" << m_url.toString() << ") [copy ctor]: note: local filename is \"" << m_localFilename << "\"" << std::endl;
+    DEBUG << "FileSource::FileSource(" << m_url.toString() << ") [copy ctor]: note: local filename is \"" << m_localFilename << "\"" << endl;
 #endif
 
 #ifdef DEBUG_FILE_SOURCE
-    std::cerr << "FileSource::FileSource(copy ctor) exiting" << std::endl;
+    DEBUG << "FileSource::FileSource(copy ctor) exiting" << endl;
 #endif
 }
 
@@ -257,7 +257,7 @@
 {
     if (!isRemote()) {
 #ifdef DEBUG_FILE_SOURCE
-        std::cerr << "FileSource::init: Not a remote URL" << std::endl;
+        DEBUG << "FileSource::init: Not a remote URL" << endl;
 #endif
         bool literal = false;
         m_localFilename = m_url.toLocalFile();
@@ -269,8 +269,8 @@
         m_localFilename = QFileInfo(m_localFilename).absoluteFilePath();
 
 #ifdef DEBUG_FILE_SOURCE
-        std::cerr << "FileSource::init: URL translates to local filename \""
-                  << m_localFilename << "\" (with literal=" << literal << ")" << std::endl;
+        DEBUG << "FileSource::init: URL translates to local filename \""
+                  << m_localFilename << "\" (with literal=" << literal << ")" << endl;
 #endif
         m_ok = true;
         m_lastStatus = 200;
@@ -280,7 +280,7 @@
                 m_lastStatus = 404;
             } else {
 #ifdef DEBUG_FILE_SOURCE
-                std::cerr << "FileSource::init: Local file of this name does not exist, trying URL as a literal filename" << std::endl;
+                DEBUG << "FileSource::init: Local file of this name does not exist, trying URL as a literal filename" << endl;
 #endif
                 // Again, QUrl may have been mistreating us --
                 // e.g. dropping a part that looks like query data
@@ -298,7 +298,7 @@
 
     if (createCacheFile()) {
 #ifdef DEBUG_FILE_SOURCE
-        std::cerr << "FileSource::init: Already have this one" << std::endl;
+        DEBUG << "FileSource::init: Already have this one" << endl;
 #endif
         m_ok = true;
         if (!QFileInfo(m_localFilename).exists()) {
@@ -317,8 +317,8 @@
     QString scheme = m_url.scheme().toLower();
 
 #ifdef DEBUG_FILE_SOURCE
-    std::cerr << "FileSource::init: Don't have local copy of \""
-              << m_url.toString() << "\", retrieving" << std::endl;
+    DEBUG << "FileSource::init: Don't have local copy of \""
+              << m_url.toString() << "\", retrieving" << endl;
 #endif
 
     if (scheme == "http") {
@@ -343,7 +343,7 @@
             cleanup();
             m_refCountMap[m_url]++;
 #ifdef DEBUG_FILE_SOURCE
-            std::cerr << "FileSource::init: Another FileSource has got there first, abandoning our download and using theirs" << std::endl;
+            DEBUG << "FileSource::init: Another FileSource has got there first, abandoning our download and using theirs" << endl;
 #endif
             m_localFilename = m_remoteLocalMap[m_url];
             m_refCounted = true;
@@ -426,8 +426,8 @@
     QString path = "/" + QString(m_url.toEncoded()).section('/', 3);
 
 #ifdef DEBUG_FILE_SOURCE
-    std::cerr << "FileSource: path is \""
-              << path << "\"" << std::endl;
+    DEBUG << "FileSource: path is \""
+              << path << "\"" << endl;
 #endif
         
     if (m_preferredContentType == "") {
@@ -528,8 +528,8 @@
     if (!m_ok) available = false;
     else available = (m_lastStatus / 100 == 2);
 #ifdef DEBUG_FILE_SOURCE
-    std::cerr << "FileSource::isAvailable: " << (available ? "yes" : "no")
-              << std::endl;
+    DEBUG << "FileSource::isAvailable: " << (available ? "yes" : "no")
+              << endl;
 #endif
     return available;
 }
@@ -547,7 +547,7 @@
 FileSource::waitForData()
 {
     while (m_ok && !m_done) {
-//        std::cerr << "FileSource::waitForData: calling QApplication::processEvents" << std::endl;
+//        DEBUG << "FileSource::waitForData: calling QApplication::processEvents" << endl;
         QCoreApplication::processEvents();
         usleep(10000);
     }
@@ -627,14 +627,14 @@
 FileSource::httpResponseHeaderReceived(const QHttpResponseHeader &resp)
 {
 #ifdef DEBUG_FILE_SOURCE
-    std::cerr << "FileSource::httpResponseHeaderReceived" << std::endl;
+    DEBUG << "FileSource::httpResponseHeaderReceived" << endl;
 #endif
 
     if (resp.statusCode() / 100 == 3) {
         QString location = resp.value("Location");
 #ifdef DEBUG_FILE_SOURCE
-        std::cerr << "FileSource::responseHeaderReceived: redirect to \""
-                  << location << "\" received" << std::endl;
+        DEBUG << "FileSource::responseHeaderReceived: redirect to \""
+                  << location << "\" received" << endl;
 #endif
         if (location != "") {
             QUrl newUrl(location);
@@ -661,13 +661,13 @@
         m_errorString = QString("%1 %2")
             .arg(resp.statusCode()).arg(resp.reasonPhrase());
 #ifdef DEBUG_FILE_SOURCE
-        std::cerr << "FileSource::responseHeaderReceived: "
-                  << m_errorString << std::endl;
+        DEBUG << "FileSource::responseHeaderReceived: "
+                  << m_errorString << endl;
 #endif
     } else {
 #ifdef DEBUG_FILE_SOURCE
-        std::cerr << "FileSource::responseHeaderReceived: "
-                  << m_lastStatus << std::endl;
+        DEBUG << "FileSource::responseHeaderReceived: "
+                  << m_lastStatus << endl;
 #endif
         if (resp.hasContentType()) m_contentType = resp.contentType();
     }
@@ -687,8 +687,8 @@
 
     if (!error) {
 #ifdef DEBUG_FILE_SOURCE
-        std::cerr << "FileSource::ftpCommandFinished: success for command "
-                  << command << std::endl;
+        DEBUG << "FileSource::ftpCommandFinished: success for command "
+                  << command << endl;
 #endif
         return;
     }
@@ -776,7 +776,7 @@
 FileSource::deleteCacheFile()
 {
 #ifdef DEBUG_FILE_SOURCE
-    std::cerr << "FileSource::deleteCacheFile(\"" << m_localFilename << "\")" << std::endl;
+    DEBUG << "FileSource::deleteCacheFile(\"" << m_localFilename << "\")" << endl;
 #endif
 
     cleanup();
@@ -817,7 +817,7 @@
 #endif
     } else {
 #ifdef DEBUG_FILE_SOURCE
-        std::cerr << "FileSource::deleteCacheFile: Deleted cache file \"" << m_localFilename << "\"" << std::endl;
+        DEBUG << "FileSource::deleteCacheFile: Deleted cache file \"" << m_localFilename << "\"" << endl;
 #endif
         m_localFilename = "";
     }
@@ -834,7 +834,7 @@
         QMutexLocker locker(&m_mapMutex);
 
 #ifdef DEBUG_FILE_SOURCE
-        std::cerr << "FileSource::createCacheFile: refcount is " << m_refCountMap[m_url] << std::endl;
+        DEBUG << "FileSource::createCacheFile: refcount is " << m_refCountMap[m_url] << endl;
 #endif
 
         if (m_refCountMap[m_url] > 0) {
@@ -881,7 +881,7 @@
     QString filepath(dir.filePath(filename));
 
 #ifdef DEBUG_FILE_SOURCE
-    std::cerr << "FileSource::createCacheFile: URL is \"" << m_url.toString() << "\", dir is \"" << dir.path() << "\", base \"" << base << "\", extension \"" << extension << "\", filebase \"" << filename << "\", filename \"" << filepath << "\"" << std::endl;
+    DEBUG << "FileSource::createCacheFile: URL is \"" << m_url.toString() << "\", dir is \"" << dir.path() << "\", base \"" << base << "\", extension \"" << extension << "\", filebase \"" << filename << "\", filename \"" << filepath << "\"" << endl;
 #endif
 
     QMutexLocker fcLocker(&m_fileCreationMutex);
@@ -918,9 +918,9 @@
     }
 
 #ifdef DEBUG_FILE_SOURCE
-    std::cerr << "FileSource::createCacheFile: url "
+    DEBUG << "FileSource::createCacheFile: url "
               << m_url.toString() << " -> local filename "
-              << filepath << std::endl;
+              << filepath << endl;
 #endif
     
     m_localFilename = filepath;