log verboseDebug

pull/3905/head
Malcolm Tyrrell 2021-05-13 10:08:59 +01:00
parent 89584c167a
commit 78145f1425
5 changed files with 21 additions and 19 deletions

View File

@ -614,7 +614,7 @@ void ASEImporter::AddNodes(const std::vector<BaseNode *> &nodes,
node->mNumChildren++;
// 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, ")");
}
}

View File

@ -301,8 +301,7 @@ aiNode *COBImporter::BuildNodes(const Node &root, const Scene &scin, aiScene *fi
}
std::unique_ptr<const Material> defmat;
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());
}

View File

@ -135,7 +135,7 @@ public:
for(;splitter->length() && splitter->at(0) != '}'; splitter++, cnt++);
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&) {
ai_assert(!splitter);

View File

@ -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 OnVerboseDebug(message);
return OnVerboseDebug(message.c_str());
}
// ----------------------------------------------------------------------------------

View File

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