diff --git a/src/core/FileFormatSpi3D.cpp b/src/core/FileFormatSpi3D.cpp index 1aa584789..1b5f6833f 100644 --- a/src/core/FileFormatSpi3D.cpp +++ b/src/core/FileFormatSpi3D.cpp @@ -111,7 +111,10 @@ OCIO_NAMESPACE_ENTER istream.getline(lineBuffer, MAX_LINE_SIZE); if(!pystring::startswith(pystring::lower(lineBuffer), "spilut")) { - throw Exception("Lut does not appear to be valid spilut format."); + std::ostringstream os; + os << "Lut does not appear to be valid spilut format. "; + os << "Expected 'SPILUT'. Found, '" << lineBuffer << "'."; + throw Exception(os.str().c_str()); } // TODO: Assert 2nd line is 3 3 diff --git a/src/core/FileTransform.cpp b/src/core/FileTransform.cpp index 410fcabdd..111a980a1 100644 --- a/src/core/FileTransform.cpp +++ b/src/core/FileTransform.cpp @@ -368,6 +368,18 @@ OCIO_NAMESPACE_ENTER } + std::string FileFormat::getName() const + { + FormatInfoVec infoVec; + GetFormatInfo(infoVec); + if(infoVec.size()>0) + { + return infoVec[0].name; + } + return "Unknown Format"; + } + + void FileFormat::Write(const Baker & /*baker*/, const std::string & formatName, @@ -439,12 +451,30 @@ OCIO_NAMESPACE_ENTER FileCachePair pair = std::make_pair(primaryFormat, cachedFile); g_fileCache[filepath] = pair; + if(IsDebugLoggingEnabled()) + { + std::ostringstream os; + os << " Loaded primary format "; + os << primaryFormat->getName(); + LogDebug(os.str()); + } + return pair; } catch(std::exception & e) { primaryErrorText = e.what(); + filestream.clear(); filestream.seekg( std::ifstream::beg ); + + if(IsDebugLoggingEnabled()) + { + std::ostringstream os; + os << " Failed primary format "; + os << primaryFormat->getName(); + os << ": " << e.what(); + LogDebug(os.str()); + } } } @@ -452,23 +482,42 @@ OCIO_NAMESPACE_ENTER FormatRegistry & formats = FormatRegistry::GetInstance(); for(int findex = 0; findexRead(filestream); + CachedFileRcPtr cachedFile = altFormat->Read(filestream); // Add the result to our cache, return it. - FileCachePair pair = std::make_pair(localFormat, cachedFile); + FileCachePair pair = std::make_pair(altFormat, cachedFile); g_fileCache[filepath] = pair; + + if(IsDebugLoggingEnabled()) + { + std::ostringstream os; + os << " Loaded alt format "; + os << altFormat->getName(); + LogDebug(os.str()); + } + return pair; } catch(std::exception & e) { + filestream.clear(); filestream.seekg( std::ifstream::beg ); + + if(IsDebugLoggingEnabled()) + { + std::ostringstream os; + os << " Failed alt format "; + os << altFormat->getName(); + os << ": " << e.what(); + LogDebug(os.str()); + } } } diff --git a/src/core/FileTransform.h b/src/core/FileTransform.h index 4bb35c7d2..4b167a79c 100644 --- a/src/core/FileTransform.h +++ b/src/core/FileTransform.h @@ -87,6 +87,9 @@ OCIO_NAMESPACE_ENTER CachedFileRcPtr cachedFile, const FileTransform & fileTransform, TransformDirection dir) const = 0; + + // For logging purposes + std::string getName() const; private: FileFormat& operator= (const FileFormat &); }; diff --git a/src/core/Logging.cpp b/src/core/Logging.cpp index 122647556..0f1ba60c2 100644 --- a/src/core/Logging.cpp +++ b/src/core/Logging.cpp @@ -120,5 +120,10 @@ OCIO_NAMESPACE_ENTER } } + bool IsDebugLoggingEnabled() + { + return (GetLoggingLevel()>=LOGGING_LEVEL_DEBUG); + } + } OCIO_NAMESPACE_EXIT diff --git a/src/core/Logging.h b/src/core/Logging.h index a797bf825..173e6422c 100644 --- a/src/core/Logging.h +++ b/src/core/Logging.h @@ -39,6 +39,8 @@ OCIO_NAMESPACE_ENTER void LogWarning(const std::string & text); void LogInfo(const std::string & text); void LogDebug(const std::string & text); + + bool IsDebugLoggingEnabled(); } OCIO_NAMESPACE_EXIT