pull/3905/head
Malcolm Tyrrell 2021-05-12 12:55:21 +01:00
parent 813d0aecdd
commit 58bc4bcb63
4 changed files with 20 additions and 16 deletions

View File

@ -305,7 +305,7 @@ void Discreet3DSImporter::ParseEditorChunk() {
// print the version number // print the version number
char buff[10]; char buff[10];
ASSIMP_itoa10(buff, stream->GetI2()); ASSIMP_itoa10(buff, stream->GetI2());
ASSIMP_LOG_INFO_F(std::string("3DS file format version: "), buff); ASSIMP_LOG_INFO_F("3DS file format version: ", buff);
} break; } break;
}; };
ASSIMP_3DS_END_CHUNK(); ASSIMP_3DS_END_CHUNK();

View File

@ -690,7 +690,7 @@ aiNode *AC3DImporter::ConvertObjectSection(Object &object,
if (object.subDiv) { if (object.subDiv) {
if (configEvalSubdivision) { if (configEvalSubdivision) {
std::unique_ptr<Subdivider> div(Subdivider::Create(Subdivider::CATMULL_CLARKE)); std::unique_ptr<Subdivider> div(Subdivider::Create(Subdivider::CATMULL_CLARKE));
ASSIMP_LOG_INFO("AC3D: Evaluating subdivision surface: " + object.name); ASSIMP_LOG_INFO_F("AC3D: Evaluating subdivision surface: ", object.name);
std::vector<aiMesh *> cpy(meshes.size() - oldm, nullptr); std::vector<aiMesh *> cpy(meshes.size() - oldm, nullptr);
div->Subdivide(&meshes[oldm], cpy.size(), &cpy.front(), object.subDiv, true); div->Subdivide(&meshes[oldm], cpy.size(), &cpy.front(), object.subDiv, true);
@ -698,7 +698,7 @@ aiNode *AC3DImporter::ConvertObjectSection(Object &object,
// previous meshes are deleted vy Subdivide(). // previous meshes are deleted vy Subdivide().
} else { } else {
ASSIMP_LOG_INFO("AC3D: Letting the subdivision surface untouched due to my configuration: " + object.name); ASSIMP_LOG_INFO_F("AC3D: Letting the subdivision surface untouched due to my configuration: ", object.name);
} }
} }
} }

View File

@ -187,13 +187,14 @@ void Logger::verboseDebug(const char *message) {
} }
// ---------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------
void Logger::info(const char *message) { void Logger::infoInternal(Assimp::Formatter::format f) {
std::string message = f;
// TODO: Should limit sizes in the formatter.
// SECURITY FIX: see above // SECURITY FIX: see above
if (strlen(message) > MAX_LOG_MESSAGE_LENGTH) { if (message.length() > MAX_LOG_MESSAGE_LENGTH) {
return; return;
} }
return OnInfo(message); return OnInfo(message.c_str());
} }
// ---------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------

View File

@ -113,8 +113,10 @@ public:
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
/** @brief Writes a info message /** @brief Writes a info message
* @param message Info message*/ * @param message Info message*/
void info(const char* message); template<typename... T>
void info(const std::string &message); void info(T&&... args) {
infoInternal(Assimp::Formatter::format(), std::forward<T>(args)...);
}
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
/** @brief Writes a warning message /** @brief Writes a warning message
@ -235,6 +237,13 @@ protected:
warnInternal(std::move(f << std::forward<U>(u)), std::forward<T>(args)...); warnInternal(std::move(f << std::forward<U>(u)), std::forward<T>(args)...);
} }
void infoInternal(Assimp::Formatter::format f);
template<typename... T, typename U>
void infoInternal(Assimp::Formatter::format f, U&& u, T&&... args) {
infoInternal(std::move(f << std::forward<U>(u)), std::forward<T>(args)...);
}
protected: protected:
LogSeverity m_Severity; LogSeverity m_Severity;
}; };
@ -293,12 +302,6 @@ void Logger::error(const std::string &message) {
return error(message.c_str()); return error(message.c_str());
} }
// ----------------------------------------------------------------------------------
inline
void Logger::info(const std::string &message) {
return info(message.c_str());
}
} // Namespace Assimp } // Namespace Assimp
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -315,7 +318,7 @@ void Logger::info(const std::string &message) {
Assimp::DefaultLogger::get()->verboseDebug((Assimp::Formatter::format(string), __VA_ARGS__)) Assimp::DefaultLogger::get()->verboseDebug((Assimp::Formatter::format(string), __VA_ARGS__))
#define ASSIMP_LOG_INFO_F(string, ...) \ #define ASSIMP_LOG_INFO_F(string, ...) \
Assimp::DefaultLogger::get()->info((Assimp::Formatter::format(string), __VA_ARGS__)) Assimp::DefaultLogger::get()->info((string, __VA_ARGS__))
#define ASSIMP_LOG_WARN(string) \ #define ASSIMP_LOG_WARN(string) \
Assimp::DefaultLogger::get()->warn(string) Assimp::DefaultLogger::get()->warn(string)