瀏覽代碼

Other LogAux functions

Malcolm Tyrrell 4 年之前
父節點
當前提交
ad6f300b1d

+ 3 - 3
code/AssetLib/Blender/BlenderLoader.cpp

@@ -235,9 +235,9 @@ void BlenderImporter::InternReadFile(const std::string &pFile,
     stream->Read(magic, 3, 1);
     stream->Read(magic, 3, 1);
     magic[3] = '\0';
     magic[3] = '\0';
 
 
-    LogInfo((format(), "Blender version is ", magic[0], ".", magic + 1,
+    LogInfo("Blender version is ", magic[0], ".", magic + 1,
             " (64bit: ", file.i64bit ? "true" : "false",
             " (64bit: ", file.i64bit ? "true" : "false",
-            ", little endian: ", file.little ? "true" : "false", ")"));
+            ", little endian: ", file.little ? "true" : "false", ")");
 
 
     ParseBlendFile(file, stream);
     ParseBlendFile(file, stream);
 
 
@@ -434,7 +434,7 @@ void BlenderImporter::ResolveImage(aiMaterial *out, const Material *mat, const M
 
 
         curTex->pcData = reinterpret_cast<aiTexel *>(ch);
         curTex->pcData = reinterpret_cast<aiTexel *>(ch);
 
 
-        LogInfo("Reading embedded texture, original file was " + std::string(img->name));
+        LogInfo("Reading embedded texture, original file was ", img->name);
     } else {
     } else {
         name = aiString(img->name);
         name = aiString(img->name);
     }
     }

+ 21 - 21
code/AssetLib/FBX/FBXMeshGeometry.cpp

@@ -307,8 +307,8 @@ void MeshGeometry::ReadLayerElement(const Scope& layerElement)
         }
         }
     }
     }
 
 
-    FBXImporter::LogError(Formatter::format("failed to resolve vertex layer element: ")
-        << type << ", index: " << typedIndex);
+    FBXImporter::LogError("failed to resolve vertex layer element: ",
+        type, ", index: ", typedIndex);
 }
 }
 
 
 // ------------------------------------------------------------------------------------------------
 // ------------------------------------------------------------------------------------------------
@@ -324,8 +324,8 @@ void MeshGeometry::ReadVertexData(const std::string& type, int index, const Scop
 
 
     if (type == "LayerElementUV") {
     if (type == "LayerElementUV") {
         if(index >= AI_MAX_NUMBER_OF_TEXTURECOORDS) {
         if(index >= AI_MAX_NUMBER_OF_TEXTURECOORDS) {
-            FBXImporter::LogError(Formatter::format("ignoring UV layer, maximum number of UV channels exceeded: ")
-                << index << " (limit is " << AI_MAX_NUMBER_OF_TEXTURECOORDS << ")" );
+            FBXImporter::LogError("ignoring UV layer, maximum number of UV channels exceeded: ",
+                index, " (limit is ", AI_MAX_NUMBER_OF_TEXTURECOORDS, ")" );
             return;
             return;
         }
         }
 
 
@@ -402,8 +402,8 @@ void MeshGeometry::ReadVertexData(const std::string& type, int index, const Scop
     }
     }
     else if (type == "LayerElementColor") {
     else if (type == "LayerElementColor") {
         if(index >= AI_MAX_NUMBER_OF_COLOR_SETS) {
         if(index >= AI_MAX_NUMBER_OF_COLOR_SETS) {
-            FBXImporter::LogError(Formatter::format("ignoring vertex color layer, maximum number of color sets exceeded: ")
-                << index << " (limit is " << AI_MAX_NUMBER_OF_COLOR_SETS << ")" );
+            FBXImporter::LogError("ignoring vertex color layer, maximum number of color sets exceeded: ",
+                index, " (limit is ", AI_MAX_NUMBER_OF_COLOR_SETS, ")" );
             return;
             return;
         }
         }
 
 
@@ -449,8 +449,8 @@ void ResolveVertexDataArray(std::vector<T>& data_out, const Scope& source,
         ParseVectorDataArray(tempData, GetRequiredElement(source, dataElementName));
         ParseVectorDataArray(tempData, GetRequiredElement(source, dataElementName));
 
 
         if (tempData.size() != mapping_offsets.size()) {
         if (tempData.size() != mapping_offsets.size()) {
-            FBXImporter::LogError(Formatter::format("length of input data unexpected for ByVertice mapping: ")
-                                  << tempData.size() << ", expected " << mapping_offsets.size());
+            FBXImporter::LogError("length of input data unexpected for ByVertice mapping: ",
+                                  tempData.size(), ", expected ", mapping_offsets.size());
             return;
             return;
         }
         }
 
 
@@ -470,8 +470,8 @@ void ResolveVertexDataArray(std::vector<T>& data_out, const Scope& source,
         ParseVectorDataArray(uvIndices,GetRequiredElement(source,indexDataElementName));
         ParseVectorDataArray(uvIndices,GetRequiredElement(source,indexDataElementName));
 
 
         if (uvIndices.size() != vertex_count) {
         if (uvIndices.size() != vertex_count) {
-            FBXImporter::LogError(Formatter::format("length of input data unexpected for ByVertice mapping: ")
-                                  << uvIndices.size() << ", expected " << vertex_count);
+            FBXImporter::LogError("length of input data unexpected for ByVertice mapping: ",
+                                  uvIndices.size(), ", expected ", vertex_count);
             return;
             return;
         }
         }
 
 
@@ -493,8 +493,8 @@ void ResolveVertexDataArray(std::vector<T>& data_out, const Scope& source,
 		ParseVectorDataArray(tempData, GetRequiredElement(source, dataElementName));
 		ParseVectorDataArray(tempData, GetRequiredElement(source, dataElementName));
 
 
 		if (tempData.size() != vertex_count) {
 		if (tempData.size() != vertex_count) {
-            FBXImporter::LogError(Formatter::format("length of input data unexpected for ByPolygon mapping: ")
-				<< tempData.size() << ", expected " << vertex_count
+            FBXImporter::LogError("length of input data unexpected for ByPolygon mapping: ",
+				tempData.size(), ", expected ", vertex_count
             );
             );
             return;
             return;
         }
         }
@@ -515,8 +515,8 @@ void ResolveVertexDataArray(std::vector<T>& data_out, const Scope& source,
         }
         }
 
 
         if (uvIndices.size() != vertex_count) {
         if (uvIndices.size() != vertex_count) {
-            FBXImporter::LogError(Formatter::format("length of input data unexpected for ByPolygonVertex mapping: ")
-                                  << uvIndices.size() << ", expected " << vertex_count);
+            FBXImporter::LogError("length of input data unexpected for ByPolygonVertex mapping: ",
+                                  uvIndices.size(), ", expected ", vertex_count);
             return;
             return;
         }
         }
 
 
@@ -537,8 +537,8 @@ void ResolveVertexDataArray(std::vector<T>& data_out, const Scope& source,
         }
         }
     }
     }
     else {
     else {
-        FBXImporter::LogError(Formatter::format("ignoring vertex data channel, access type not implemented: ")
-            << MappingInformationType << "," << ReferenceInformationType);
+        FBXImporter::LogError("ignoring vertex data channel, access type not implemented: ",
+            MappingInformationType, ",", ReferenceInformationType);
     }
     }
 }
 }
 
 
@@ -642,7 +642,7 @@ void MeshGeometry::ReadVertexDataMaterials(std::vector<int>& materials_out, cons
     if (MappingInformationType == "AllSame") {
     if (MappingInformationType == "AllSame") {
         // easy - same material for all faces
         // easy - same material for all faces
         if (materials_out.empty()) {
         if (materials_out.empty()) {
-            FBXImporter::LogError(Formatter::format("expected material index, ignoring"));
+            FBXImporter::LogError("expected material index, ignoring");
             return;
             return;
         } else if (materials_out.size() > 1) {
         } else if (materials_out.size() > 1) {
             FBXImporter::LogWarn("expected only a single material index, ignoring all except the first one");
             FBXImporter::LogWarn("expected only a single material index, ignoring all except the first one");
@@ -655,14 +655,14 @@ void MeshGeometry::ReadVertexDataMaterials(std::vector<int>& materials_out, cons
         materials_out.resize(face_count);
         materials_out.resize(face_count);
 
 
         if(materials_out.size() != face_count) {
         if(materials_out.size() != face_count) {
-            FBXImporter::LogError(Formatter::format("length of input data unexpected for ByPolygon mapping: ")
-                << materials_out.size() << ", expected " << face_count
+            FBXImporter::LogError("length of input data unexpected for ByPolygon mapping: ",
+                materials_out.size(), ", expected ", face_count
             );
             );
             return;
             return;
         }
         }
     } else {
     } else {
-        FBXImporter::LogError(Formatter::format("ignoring material assignments, access type not implemented: ")
-            << MappingInformationType << "," << ReferenceInformationType);
+        FBXImporter::LogError("ignoring material assignments, access type not implemented: ",
+            MappingInformationType, ",", ReferenceInformationType);
     }
     }
 }
 }
 // ------------------------------------------------------------------------------------------------
 // ------------------------------------------------------------------------------------------------

+ 3 - 3
code/AssetLib/IFC/IFCLoader.cpp

@@ -315,7 +315,7 @@ void IFCImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
 
 
     // this must be last because objects are evaluated lazily as we process them
     // this must be last because objects are evaluated lazily as we process them
     if (!DefaultLogger::isNullLogger()) {
     if (!DefaultLogger::isNullLogger()) {
-        LogDebug((Formatter::format(), "STEP: evaluated ", db->GetEvaluatedObjectCount(), " object records"));
+        LogDebug("STEP: evaluated ", db->GetEvaluatedObjectCount(), " object records");
     }
     }
 }
 }
 
 
@@ -438,7 +438,7 @@ bool ProcessMappedItem(const Schema_2x3::IfcMappedItem &mapped, aiNode *nd_src,
     bool got = false;
     bool got = false;
     for (const Schema_2x3::IfcRepresentationItem &item : repr.Items) {
     for (const Schema_2x3::IfcRepresentationItem &item : repr.Items) {
         if (!ProcessRepresentationItem(item, localmatid, meshes, conv)) {
         if (!ProcessRepresentationItem(item, localmatid, meshes, conv)) {
-            IFCImporter::LogWarn("skipping mapped entity of type " + item.GetClassName() + ", no representations could be generated");
+            IFCImporter::LogWarn("skipping mapped entity of type ", item.GetClassName(), ", no representations could be generated");
         } else
         } else
             got = true;
             got = true;
     }
     }
@@ -856,7 +856,7 @@ void ProcessSpatialStructures(ConversionData &conv) {
         if (!prod) {
         if (!prod) {
             continue;
             continue;
         }
         }
-        IFCImporter::LogVerboseDebug("looking at spatial structure `" + (prod->Name ? prod->Name.Get() : "unnamed") + "`" + (prod->ObjectType ? " which is of type " + prod->ObjectType.Get() : ""));
+        IFCImporter::LogVerboseDebug("looking at spatial structure `", (prod->Name ? prod->Name.Get() : "unnamed"), "`", (prod->ObjectType ? " which is of type " + prod->ObjectType.Get() : ""));
 
 
         // the primary sites are referenced by an IFCRELAGGREGATES element which assigns them to the IFCPRODUCT
         // the primary sites are referenced by an IFCRELAGGREGATES element which assigns them to the IFCPRODUCT
         const STEP::DB::RefMap &refs = conv.db.GetRefs();
         const STEP::DB::RefMap &refs = conv.db.GetRefs();

+ 12 - 39
include/assimp/LogAux.h

@@ -76,63 +76,36 @@ public:
     }
     }
 
 
     // ------------------------------------------------------------------------------------------------
     // ------------------------------------------------------------------------------------------------
-    static void LogError(const Formatter::format& message)  {
-        if (!DefaultLogger::isNullLogger()) {
-            ASSIMP_LOG_ERROR(Prefix()+(std::string)message);
-        }
-    }
-
-    // ------------------------------------------------------------------------------------------------
-    static void LogInfo(const Formatter::format& message)   {
-        if (!DefaultLogger::isNullLogger()) {
-            ASSIMP_LOG_INFO(Prefix()+(std::string)message);
-        }
-    }
-
-    // ------------------------------------------------------------------------------------------------
-    static void LogDebug(const Formatter::format& message)  {
-        if (!DefaultLogger::isNullLogger()) {
-            ASSIMP_LOG_DEBUG(Prefix()+(std::string)message);
-        }
-    }
-
-    static void LogVerboseDebug(const Formatter::format& message)  {
-        if (!DefaultLogger::isNullLogger()) {
-            ASSIMP_LOG_VERBOSE_DEBUG(Prefix()+(std::string)message);
-        }
-    }
-
-    // https://sourceforge.net/tracker/?func=detail&atid=1067632&aid=3358562&group_id=226462
-#if !defined(__GNUC__) || !defined(__APPLE__) || __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
-
-    // ------------------------------------------------------------------------------------------------
-    static void LogError  (const char* message) {
+    template<typename... T>
+    static void LogError(T&&... args)  {
         if (!DefaultLogger::isNullLogger()) {
         if (!DefaultLogger::isNullLogger()) {
-            LogError(Formatter::format(message));
+            ASSIMP_LOG_ERROR(Prefix(), std::forward<T>(args)...);
         }
         }
     }
     }
 
 
     // ------------------------------------------------------------------------------------------------
     // ------------------------------------------------------------------------------------------------
-    static void LogInfo  (const char* message) {
+    template<typename... T>
+    static void LogInfo(T&&... args)  {
         if (!DefaultLogger::isNullLogger()) {
         if (!DefaultLogger::isNullLogger()) {
-            LogInfo(Formatter::format(message));
+            ASSIMP_LOG_INFO(Prefix(), std::forward<T>(args)...);
         }
         }
     }
     }
 
 
     // ------------------------------------------------------------------------------------------------
     // ------------------------------------------------------------------------------------------------
-    static void LogDebug  (const char* message) {
+    template<typename... T>
+    static void LogDebug(T&&... args)  {
         if (!DefaultLogger::isNullLogger()) {
         if (!DefaultLogger::isNullLogger()) {
-            LogDebug(Formatter::format(message));
+            ASSIMP_LOG_DEBUG(Prefix(), std::forward<T>(args)...);
         }
         }
     }
     }
 
 
     // ------------------------------------------------------------------------------------------------
     // ------------------------------------------------------------------------------------------------
-    static void LogVerboseDebug  (const char* message) {
+    template<typename... T>
+    static void LogVerboseDebug(T&&... args)  {
         if (!DefaultLogger::isNullLogger()) {
         if (!DefaultLogger::isNullLogger()) {
-            LogVerboseDebug(Formatter::format(message));
+            ASSIMP_LOG_VERBOSE_DEBUG(Prefix(), std::forward<T>(args)...);
         }
         }
     }
     }
-#endif
 
 
 private:
 private:
     static const char* Prefix();
     static const char* Prefix();