Bladeren bron

log verboseDebug

Malcolm Tyrrell 4 jaren geleden
bovenliggende
commit
78145f1425

+ 1 - 1
code/AssetLib/ASE/ASELoader.cpp

@@ -614,7 +614,7 @@ void ASEImporter::AddNodes(const std::vector<BaseNode *> &nodes,
             node->mNumChildren++;
             node->mNumChildren++;
 
 
             // What we did is so great, it is at least worth a debug message
             // What we did is so great, it is at least worth a debug message
-            ASSIMP_LOG_VERBOSE_DEBUG("ASE: Generating separate target node (" + snode->mName + ")");
+            ASSIMP_LOG_VERBOSE_DEBUG_F("ASE: Generating separate target node (", snode->mName, ")");
         }
         }
     }
     }
 
 

+ 1 - 2
code/AssetLib/COB/COBLoader.cpp

@@ -301,8 +301,7 @@ aiNode *COBImporter::BuildNodes(const Node &root, const Scene &scin, aiScene *fi
                     }
                     }
                     std::unique_ptr<const Material> defmat;
                     std::unique_ptr<const Material> defmat;
                     if (!min) {
                     if (!min) {
-                        ASSIMP_LOG_VERBOSE_DEBUG(format() << "Could not resolve material index "
-                                                  << reflist.first << " - creating default material for this slot");
+                        ASSIMP_LOG_VERBOSE_DEBUG_F("Could not resolve material index ", reflist.first, " - creating default material for this slot");
 
 
                         defmat.reset(min = new Material());
                         defmat.reset(min = new Material());
                     }
                     }

+ 1 - 1
code/AssetLib/DXF/DXFHelper.h

@@ -135,7 +135,7 @@ public:
                 for(;splitter->length() && splitter->at(0) != '}'; splitter++, cnt++);
                 for(;splitter->length() && splitter->at(0) != '}'; splitter++, cnt++);
 
 
                 splitter++;
                 splitter++;
-                ASSIMP_LOG_VERBOSE_DEBUG((Formatter::format("DXF: skipped over control group ("),cnt," lines)"));
+                ASSIMP_LOG_VERBOSE_DEBUG_F("DXF: skipped over control group (",cnt," lines)");
             }
             }
         } catch(std::logic_error&) {
         } catch(std::logic_error&) {
             ai_assert(!splitter);
             ai_assert(!splitter);

+ 6 - 6
code/Common/DefaultLogger.cpp

@@ -174,14 +174,14 @@ void Logger::debugInternal(Assimp::Formatter::format f) {
 }
 }
 
 
 // ----------------------------------------------------------------------------------
 // ----------------------------------------------------------------------------------
-void Logger::verboseDebug(const char *message) {
-    // SECURITY FIX: otherwise it's easy to produce overruns since
-    // sometimes importers will include data from the input file
-    // (i.e. node names) in their messages.
-    if (strlen(message) > MAX_LOG_MESSAGE_LENGTH) {
+void Logger::verboseDebugInternal(Assimp::Formatter::format f) {
+    std::string message = f;
+    // TODO: Should limit sizes in the formatter.
+    // SECURITY FIX: see above
+    if (message.length() > MAX_LOG_MESSAGE_LENGTH) {
         return;
         return;
     }
     }
-    return OnVerboseDebug(message);
+    return OnVerboseDebug(message.c_str());
 }
 }
 
 
 // ----------------------------------------------------------------------------------
 // ----------------------------------------------------------------------------------

+ 12 - 9
include/assimp/Logger.hpp

@@ -109,8 +109,10 @@ public:
     // ----------------------------------------------------------------------
     // ----------------------------------------------------------------------
 	/** @brief  Writes a debug message
 	/** @brief  Writes a debug message
      *   @param message Debug message*/
      *   @param message Debug message*/
-	void verboseDebug(const char *message);
-	void verboseDebug(const std::string &message);
+    template<typename... T>
+    void verboseDebug(T&&... args) {
+        verboseDebugInternal(Assimp::Formatter::format(), std::forward<T>(args)...);
+    }
 
 
     // ----------------------------------------------------------------------
     // ----------------------------------------------------------------------
     /** @brief  Writes a info message
     /** @brief  Writes a info message
@@ -236,13 +238,19 @@ protected:
 protected:
 protected:
 
 
     void debugInternal(Assimp::Formatter::format f);
     void debugInternal(Assimp::Formatter::format f);
+    void verboseDebugInternal(Assimp::Formatter::format f);
     void warnInternal(Assimp::Formatter::format f);
     void warnInternal(Assimp::Formatter::format f);
     void infoInternal(Assimp::Formatter::format f);
     void infoInternal(Assimp::Formatter::format f);
     void errorInternal(Assimp::Formatter::format f);
     void errorInternal(Assimp::Formatter::format f);
 
 
     template<typename... T, typename U>
     template<typename... T, typename U>
     void debugInternal(Assimp::Formatter::format f, U&& u, T&&... args) {
     void debugInternal(Assimp::Formatter::format f, U&& u, T&&... args) {
-        warnInternal(std::move(f << std::forward<U>(u)), std::forward<T>(args)...);
+        debugInternal(std::move(f << std::forward<U>(u)), std::forward<T>(args)...);
+    }
+
+    template<typename... T, typename U>
+    void verboseDebugInternal(Assimp::Formatter::format f, U&& u, T&&... args) {
+        verboseDebugInternal(std::move(f << std::forward<U>(u)), std::forward<T>(args)...);
     }
     }
 
 
     template<typename... T, typename U>
     template<typename... T, typename U>
@@ -301,11 +309,6 @@ Logger::LogSeverity Logger::getLogSeverity() const {
     return m_Severity;
     return m_Severity;
 }
 }
 
 
-// ----------------------------------------------------------------------------------
-inline void Logger::verboseDebug(const std::string &message) {
-	return verboseDebug(message.c_str());
-}
-
 } // Namespace Assimp
 } // Namespace Assimp
 
 
 // ------------------------------------------------------------------------------------------------
 // ------------------------------------------------------------------------------------------------
@@ -319,7 +322,7 @@ inline void Logger::verboseDebug(const std::string &message) {
 	Assimp::DefaultLogger::get()->debug((string, __VA_ARGS__))
 	Assimp::DefaultLogger::get()->debug((string, __VA_ARGS__))
 
 
 #define ASSIMP_LOG_VERBOSE_DEBUG_F(string, ...) \
 #define ASSIMP_LOG_VERBOSE_DEBUG_F(string, ...) \
-	Assimp::DefaultLogger::get()->verboseDebug((Assimp::Formatter::format(string), __VA_ARGS__))
+	Assimp::DefaultLogger::get()->verboseDebug((string, __VA_ARGS__))
 
 
 #define ASSIMP_LOG_INFO_F(string, ...) \
 #define ASSIMP_LOG_INFO_F(string, ...) \
 	Assimp::DefaultLogger::get()->info((string, __VA_ARGS__))
 	Assimp::DefaultLogger::get()->info((string, __VA_ARGS__))