Fixed log formatting in DefaultLogger.cpp to work with AssimpView.

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@107 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
pull/1/head
aramis_acg 2008-08-11 20:57:18 +00:00
parent b5c54703d0
commit 0b1e8fefa5
4 changed files with 23 additions and 26 deletions

View File

@ -80,8 +80,9 @@ struct LogStreamInfo
// Creates the only singleton instance // Creates the only singleton instance
Logger *DefaultLogger::create(const std::string &name, LogSeverity severity) Logger *DefaultLogger::create(const std::string &name, LogSeverity severity)
{ {
if ( NULL == m_pLogger ) if (m_pLogger && !isNullLogger() )
m_pLogger = new DefaultLogger( name, severity ); delete m_pLogger;
m_pLogger = new DefaultLogger( name, severity );
return m_pLogger; return m_pLogger;
} }
@ -111,7 +112,7 @@ Logger *DefaultLogger::get()
// Kills the only instance // Kills the only instance
void DefaultLogger::kill() void DefaultLogger::kill()
{ {
ai_assert (NULL != m_pLogger); if (m_pLogger != &s_pNullLogger)return;
delete m_pLogger; delete m_pLogger;
m_pLogger = &s_pNullLogger; m_pLogger = &s_pNullLogger;
} }
@ -123,7 +124,7 @@ void DefaultLogger::debug( const std::string &message )
if ( m_Severity == Logger::NORMAL ) if ( m_Severity == Logger::NORMAL )
return; return;
const std::string msg( "Debug, thread " + getThreadID() + " :" + message ); const std::string msg( "Debug, T" + getThreadID() + ": " + message );
writeToStreams( msg, Logger::DEBUGGING ); writeToStreams( msg, Logger::DEBUGGING );
} }
@ -131,7 +132,7 @@ void DefaultLogger::debug( const std::string &message )
// Logs an info // Logs an info
void DefaultLogger::info( const std::string &message ) void DefaultLogger::info( const std::string &message )
{ {
const std::string msg( "Info: " + getThreadID() + " :" + message ); const std::string msg( "Info, T" + getThreadID() + ": " + message );
writeToStreams( msg , Logger::INFO ); writeToStreams( msg , Logger::INFO );
} }
@ -139,7 +140,7 @@ void DefaultLogger::info( const std::string &message )
// Logs a warning // Logs a warning
void DefaultLogger::warn( const std::string &message ) void DefaultLogger::warn( const std::string &message )
{ {
const std::string msg( "Warn: " + getThreadID() + " :"+ message ); const std::string msg( "Warn, T" + getThreadID() + ": "+ message );
writeToStreams( msg, Logger::WARN ); writeToStreams( msg, Logger::WARN );
} }
@ -147,7 +148,7 @@ void DefaultLogger::warn( const std::string &message )
// Logs an error // Logs an error
void DefaultLogger::error( const std::string &message ) void DefaultLogger::error( const std::string &message )
{ {
const std::string msg( "Error: "+ getThreadID() + " :" + message ); const std::string msg( "Error, T"+ getThreadID() + ": " + message );
writeToStreams( msg, Logger::ERR ); writeToStreams( msg, Logger::ERR );
} }
@ -232,10 +233,10 @@ DefaultLogger::DefaultLogger( const std::string &name, LogSeverity severity ) :
{ {
#ifdef WIN32 #ifdef WIN32
m_Streams.push_back( new Win32DebugLogStream() ); m_Streams.push_back( new Win32DebugLogStream() );
if (name.empty())
return;
#endif #endif
if (name.empty())
return;
m_Streams.push_back( new FileLogStream( name ) ); m_Streams.push_back( new FileLogStream( name ) );
} }
@ -293,7 +294,7 @@ std::string DefaultLogger::getThreadID()
if ( hThread ) if ( hThread )
{ {
std::stringstream thread_msg; std::stringstream thread_msg;
thread_msg << ::GetCurrentThreadId() << " "; thread_msg << ::GetCurrentThreadId() /*<< " "*/;
return thread_msg.str(); return thread_msg.str();
} }
else else

View File

@ -299,7 +299,7 @@ aiReturn Importer::RegisterLoader(BaseImporter* pImp)
pImp->GetExtensionList(st); pImp->GetExtensionList(st);
#ifdef _DEBUG #ifdef _DEBUG
const char* sz = ::strtok(st.c_str(),";"); const char* sz = ::strtok(const_cast<char*>(st.c_str()),";");
while (sz) while (sz)
{ {
if (IsExtensionSupported(std::string(sz))) if (IsExtensionSupported(std::string(sz)))

View File

@ -242,14 +242,14 @@ void LWOImporter::CountVertsAndFaces(unsigned int& verts, unsigned int& faces,
{ {
while (cursor < end && max--) while (cursor < end && max--)
{ {
uint16_t numIndices = *((uint16_t*)cursor);cursor+=2; uint16_t numIndices = *((LE_NCONST uint16_t*)cursor);cursor+=2;
verts += numIndices;faces++; verts += numIndices;faces++;
cursor += numIndices*2; cursor += numIndices*2;
int16_t surface = *((uint16_t*)cursor);cursor+=2; int16_t surface = *((LE_NCONST uint16_t*)cursor);cursor+=2;
if (surface < 0) if (surface < 0)
{ {
// there are detail polygons // there are detail polygons
numIndices = *((uint16_t*)cursor);cursor+=2; numIndices = *((LE_NCONST uint16_t*)cursor);cursor+=2;
CountVertsAndFaces(verts,faces,cursor,end,numIndices); CountVertsAndFaces(verts,faces,cursor,end,numIndices);
} }
} }
@ -263,13 +263,13 @@ void LWOImporter::CopyFaceIndices(LWOImporter::FaceList::iterator& it,
while (cursor < end && max--) while (cursor < end && max--)
{ {
LWO::Face& face = *it;++it; LWO::Face& face = *it;++it;
if(face.mNumIndices = *((uint16_t*)cursor)) if(face.mNumIndices = *((LE_NCONST uint16_t*)cursor))
{ {
if (cursor + face.mNumIndices*2 + 4 >= end)break; if (cursor + face.mNumIndices*2 + 4 >= end)break;
face.mIndices = new unsigned int[face.mNumIndices]; face.mIndices = new unsigned int[face.mNumIndices];
for (unsigned int i = 0; i < face.mNumIndices;++i) for (unsigned int i = 0; i < face.mNumIndices;++i)
{ {
face.mIndices[i] = *((uint16_t*)(cursor+=2)); face.mIndices[i] = *((LE_NCONST uint16_t*)(cursor+=2));
if (face.mIndices[i] >= mTempPoints->size()) if (face.mIndices[i] >= mTempPoints->size())
{ {
face.mIndices[i] = mTempPoints->size()-1; face.mIndices[i] = mTempPoints->size()-1;
@ -279,13 +279,13 @@ void LWOImporter::CopyFaceIndices(LWOImporter::FaceList::iterator& it,
} }
else DefaultLogger::get()->warn("LWO: Face has 0 indices"); else DefaultLogger::get()->warn("LWO: Face has 0 indices");
cursor+=2; cursor+=2;
int16_t surface = *((uint16_t*)cursor);cursor+=2; int16_t surface = *((LE_NCONST uint16_t*)cursor);cursor+=2;
if (surface < 0) if (surface < 0)
{ {
surface = -surface; surface = -surface;
// there are detail polygons // there are detail polygons
uint16_t numPolygons = *((uint16_t*)cursor);cursor+=2; uint16_t numPolygons = *((LE_NCONST uint16_t*)cursor);cursor+=2;
if (cursor < end)CopyFaceIndices(it,cursor,end,numPolygons); if (cursor < end)CopyFaceIndices(it,cursor,end,numPolygons);
} }
face.surfaceIndex = surface-1; face.surfaceIndex = surface-1;

View File

@ -1094,6 +1094,10 @@
RelativePath="..\..\code\DefaultIOSystem.cpp" RelativePath="..\..\code\DefaultIOSystem.cpp"
> >
</File> </File>
<File
RelativePath="..\..\code\DefaultLogger.cpp"
>
</File>
<File <File
RelativePath="..\..\code\FixNormalsStep.cpp" RelativePath="..\..\code\FixNormalsStep.cpp"
> >
@ -1270,14 +1274,6 @@
> >
</File> </File>
</Filter> </Filter>
<Filter
Name="Logger"
>
<File
RelativePath="..\..\code\DefaultLogger.cpp"
>
</File>
</Filter>
<Filter <Filter
Name="extra" Name="extra"
> >