Log error

pull/3905/head
Malcolm Tyrrell 2021-05-13 09:36:42 +01:00
parent 58bc4bcb63
commit ca698c3e49
3 changed files with 19 additions and 15 deletions

View File

@ -176,7 +176,6 @@ void Logger::debug(const char *message) {
// ----------------------------------------------------------------------------------
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.
@ -209,12 +208,14 @@ void Logger::warnInternal(Assimp::Formatter::format f) {
}
// ----------------------------------------------------------------------------------
void Logger::error(const char *message) {
void Logger::errorInternal(Assimp::Formatter::format f) {
std::string message = f;
// TODO: Should limit sizes in the formatter.
// SECURITY FIX: see above
if (strlen(message) > MAX_LOG_MESSAGE_LENGTH) {
if (message.length() > MAX_LOG_MESSAGE_LENGTH) {
return;
}
return OnError(message);
return OnError(message.c_str());
}
// ----------------------------------------------------------------------------------

View File

@ -129,7 +129,7 @@ bool CalcTangentsProcess::ProcessMesh(aiMesh *pMesh, unsigned int meshIndex) {
return false;
}
if (configSourceUV >= AI_MAX_NUMBER_OF_TEXTURECOORDS || !pMesh->mTextureCoords[configSourceUV]) {
ASSIMP_LOG_ERROR((Formatter::format("Failed to compute tangents; need UV data in channel"), configSourceUV));
ASSIMP_LOG_ERROR_F("Failed to compute tangents; need UV data in channel", configSourceUV);
return false;
}

View File

@ -128,9 +128,11 @@ public:
// ----------------------------------------------------------------------
/** @brief Writes an error message
* @param message Error message*/
void error(const char* message);
void error(const std::string &message);
* @param message Info message*/
template<typename... T>
void error(T&&... args) {
errorInternal(Assimp::Formatter::format(), std::forward<T>(args)...);
}
// ----------------------------------------------------------------------
/** @brief Set a new log severity.
@ -244,6 +246,13 @@ protected:
infoInternal(std::move(f << std::forward<U>(u)), std::forward<T>(args)...);
}
void errorInternal(Assimp::Formatter::format f);
template<typename... T, typename U>
void errorInternal(Assimp::Formatter::format f, U&& u, T&&... args) {
errorInternal(std::move(f << std::forward<U>(u)), std::forward<T>(args)...);
}
protected:
LogSeverity m_Severity;
};
@ -296,12 +305,6 @@ inline void Logger::verboseDebug(const std::string &message) {
return verboseDebug(message.c_str());
}
// ----------------------------------------------------------------------------------
inline
void Logger::error(const std::string &message) {
return error(message.c_str());
}
} // Namespace Assimp
// ------------------------------------------------------------------------------------------------
@ -309,7 +312,7 @@ void Logger::error(const std::string &message) {
Assimp::DefaultLogger::get()->warn((string, __VA_ARGS__))
#define ASSIMP_LOG_ERROR_F(string, ...) \
Assimp::DefaultLogger::get()->error((Assimp::Formatter::format(string), __VA_ARGS__))
Assimp::DefaultLogger::get()->error((string, __VA_ARGS__))
#define ASSIMP_LOG_DEBUG_F(string, ...) \
Assimp::DefaultLogger::get()->debug((Assimp::Formatter::format(string), __VA_ARGS__))