Add ThreadID to default log stream output.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@106 67173fc5-114c-0410-ac8e-9d2fd5bffc1fpull/1/head
parent
cefecc1fe7
commit
b5c54703d0
|
@ -47,6 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "FileLogStream.h"
|
#include "FileLogStream.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
namespace Assimp
|
namespace Assimp
|
||||||
{
|
{
|
||||||
|
@ -68,17 +69,24 @@ struct LogStreamInfo
|
||||||
{
|
{
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Destructor
|
||||||
|
~LogStreamInfo()
|
||||||
|
{
|
||||||
|
// empty
|
||||||
|
}
|
||||||
};
|
};
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// 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)
|
||||||
{
|
{
|
||||||
m_pLogger = new DefaultLogger( name, severity );
|
if ( NULL == m_pLogger )
|
||||||
|
m_pLogger = new DefaultLogger( name, severity );
|
||||||
|
|
||||||
return m_pLogger;
|
return m_pLogger;
|
||||||
}
|
}
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
void DefaultLogger::set (Logger *logger)
|
void DefaultLogger::set( Logger *logger )
|
||||||
{
|
{
|
||||||
if (!logger)
|
if (!logger)
|
||||||
{
|
{
|
||||||
|
@ -110,20 +118,20 @@ void DefaultLogger::kill()
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// Debug message
|
// Debug message
|
||||||
void DefaultLogger::debug(const std::string &message)
|
void DefaultLogger::debug( const std::string &message )
|
||||||
{
|
{
|
||||||
if ( m_Severity == Logger::NORMAL )
|
if ( m_Severity == Logger::NORMAL )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const std::string msg( "Debug: " + message );
|
const std::string msg( "Debug, thread " + getThreadID() + " :" + message );
|
||||||
writeToStreams( msg, Logger::DEBUGGING );
|
writeToStreams( msg, Logger::DEBUGGING );
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// 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: " + message );
|
const std::string msg( "Info: " + getThreadID() + " :" + message );
|
||||||
writeToStreams( msg , Logger::INFO );
|
writeToStreams( msg , Logger::INFO );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,7 +139,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: " + message );
|
const std::string msg( "Warn: " + getThreadID() + " :"+ message );
|
||||||
writeToStreams( msg, Logger::WARN );
|
writeToStreams( msg, Logger::WARN );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,7 +147,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: " + message );
|
const std::string msg( "Error: "+ getThreadID() + " :" + message );
|
||||||
writeToStreams( msg, Logger::ERR );
|
writeToStreams( msg, Logger::ERR );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,8 +266,7 @@ void DefaultLogger::writeToStreams(const std::string &message,
|
||||||
{
|
{
|
||||||
if ( message.empty() )
|
if ( message.empty() )
|
||||||
return;
|
return;
|
||||||
|
for ( ConstStreamIt it = m_StreamArray.begin();
|
||||||
for ( ConstStreamIt it = this->m_StreamArray.begin();
|
|
||||||
it != m_StreamArray.end();
|
it != m_StreamArray.end();
|
||||||
++it)
|
++it)
|
||||||
{
|
{
|
||||||
|
@ -276,6 +283,26 @@ void DefaultLogger::writeToStreams(const std::string &message,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// Returns thread id, if not supported only a zero will be returned.
|
||||||
|
std::string DefaultLogger::getThreadID()
|
||||||
|
{
|
||||||
|
std::string thread_id( "0" );
|
||||||
|
#ifdef WIN32
|
||||||
|
HANDLE hThread = GetCurrentThread();
|
||||||
|
if ( hThread )
|
||||||
|
{
|
||||||
|
std::stringstream thread_msg;
|
||||||
|
thread_msg << ::GetCurrentThreadId() << " ";
|
||||||
|
return thread_msg.str();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return thread_id;
|
||||||
|
#else
|
||||||
|
return thread_id;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
} // Namespace Assimp
|
} // Namespace Assimp
|
||||||
|
|
|
@ -653,11 +653,11 @@
|
||||||
</FileConfiguration>
|
</FileConfiguration>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\include\cppunit\ui\text\TextTestRunner.h"
|
RelativePath="..\..\include\cppunit\TextTestRunner.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\include\cppunit\TextTestRunner.h"
|
RelativePath="..\..\include\cppunit\ui\text\TextTestRunner.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
@ -2694,11 +2694,11 @@
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="Makefile.am"
|
RelativePath="..\..\include\cppunit\Makefile.am"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\include\cppunit\Makefile.am"
|
RelativePath="Makefile.am"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
</Files>
|
</Files>
|
||||||
|
|
|
@ -131,6 +131,11 @@ private:
|
||||||
/** @brief Writes message into a file */
|
/** @brief Writes message into a file */
|
||||||
void writeToStreams(const std::string &message, ErrorSeverity ErrorSev );
|
void writeToStreams(const std::string &message, ErrorSeverity ErrorSev );
|
||||||
|
|
||||||
|
/** @brief Returns the thread id.
|
||||||
|
* @remark This is an OS specific feature, if not supported, a zero will be returned.
|
||||||
|
*/
|
||||||
|
std::string getThreadID();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Aliases for stream container
|
// Aliases for stream container
|
||||||
typedef std::vector<LogStreamInfo*> StreamArray;
|
typedef std::vector<LogStreamInfo*> StreamArray;
|
||||||
|
|
|
@ -7,7 +7,7 @@ namespace Assimp
|
||||||
{
|
{
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** @class LogStream
|
/** @class LogStream
|
||||||
* @brief Abstract interface for log stream implementations.
|
* @brief Abstract interface for log stream implementations.
|
||||||
*/
|
*/
|
||||||
class ASSIMP_API LogStream
|
class ASSIMP_API LogStream
|
||||||
{
|
{
|
||||||
|
|
|
@ -99,6 +99,87 @@
|
||||||
Name="VCPostBuildEventTool"
|
Name="VCPostBuildEventTool"
|
||||||
/>
|
/>
|
||||||
</Configuration>
|
</Configuration>
|
||||||
|
<Configuration
|
||||||
|
Name="Release|Win32"
|
||||||
|
OutputDirectory="$(SolutionDir)..\..\tools\build\$(ConfigurationName)_$(PlatformName)"
|
||||||
|
IntermediateDirectory="$(SolutionDir)..\..\tools\build\$(ConfigurationName)_$(PlatformName)\obj"
|
||||||
|
ConfigurationType="1"
|
||||||
|
CharacterSet="2"
|
||||||
|
WholeProgramOptimization="1"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
AdditionalIncludeDirectories=""$(DXSDK_DIR)include";..\..\include;..\..\code"
|
||||||
|
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS"
|
||||||
|
RuntimeLibrary="0"
|
||||||
|
UsePrecompiledHeader="2"
|
||||||
|
WarningLevel="3"
|
||||||
|
Detect64BitPortabilityProblems="true"
|
||||||
|
DebugInformationFormat="3"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
AdditionalDependencies="d3d9.lib d3dx9.lib comdlg32.lib assimp.lib winmm.lib comctl32.lib user32.lib advapi32.lib shell32.lib Gdi32.lib"
|
||||||
|
OutputFile="$(OutDir)\assimpview32.exe"
|
||||||
|
LinkIncremental="1"
|
||||||
|
AdditionalLibraryDirectories="..\..\lib\assimp_release_win32;"$(DXSDK_DIR)lib\x86""
|
||||||
|
IgnoreAllDefaultLibraries="false"
|
||||||
|
IgnoreDefaultLibraryNames=""
|
||||||
|
GenerateDebugInformation="true"
|
||||||
|
SubSystem="2"
|
||||||
|
OptimizeReferences="2"
|
||||||
|
EnableCOMDATFolding="2"
|
||||||
|
TargetMachine="1"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCALinkTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManifestTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXDCMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCBscMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCFxCopTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAppVerifierTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebDeploymentTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"
|
||||||
|
/>
|
||||||
|
</Configuration>
|
||||||
<Configuration
|
<Configuration
|
||||||
Name="Debug|x64"
|
Name="Debug|x64"
|
||||||
OutputDirectory="$(SolutionDir)..\..\tools\build\$(ConfigurationName)_$(PlatformName)"
|
OutputDirectory="$(SolutionDir)..\..\tools\build\$(ConfigurationName)_$(PlatformName)"
|
||||||
|
@ -181,87 +262,6 @@
|
||||||
Name="VCPostBuildEventTool"
|
Name="VCPostBuildEventTool"
|
||||||
/>
|
/>
|
||||||
</Configuration>
|
</Configuration>
|
||||||
<Configuration
|
|
||||||
Name="Release|Win32"
|
|
||||||
OutputDirectory="$(SolutionDir)..\..\tools\build\$(ConfigurationName)_$(PlatformName)"
|
|
||||||
IntermediateDirectory="$(SolutionDir)..\..\tools\build\$(ConfigurationName)_$(PlatformName)\obj"
|
|
||||||
ConfigurationType="1"
|
|
||||||
CharacterSet="2"
|
|
||||||
WholeProgramOptimization="1"
|
|
||||||
>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreBuildEventTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCCustomBuildTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCXMLDataGeneratorTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCWebServiceProxyGeneratorTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCMIDLTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
AdditionalIncludeDirectories=""$(DXSDK_DIR)include";..\..\include;..\..\code"
|
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS"
|
|
||||||
RuntimeLibrary="0"
|
|
||||||
UsePrecompiledHeader="2"
|
|
||||||
WarningLevel="3"
|
|
||||||
Detect64BitPortabilityProblems="true"
|
|
||||||
DebugInformationFormat="3"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCManagedResourceCompilerTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCResourceCompilerTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreLinkEventTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCLinkerTool"
|
|
||||||
AdditionalDependencies="d3d9.lib d3dx9.lib comdlg32.lib assimp.lib winmm.lib comctl32.lib user32.lib advapi32.lib shell32.lib Gdi32.lib"
|
|
||||||
OutputFile="$(OutDir)\assimpview32.exe"
|
|
||||||
LinkIncremental="1"
|
|
||||||
AdditionalLibraryDirectories="..\..\lib\assimp_release_win32;"$(DXSDK_DIR)lib\x86""
|
|
||||||
IgnoreAllDefaultLibraries="false"
|
|
||||||
IgnoreDefaultLibraryNames=""
|
|
||||||
GenerateDebugInformation="true"
|
|
||||||
SubSystem="2"
|
|
||||||
OptimizeReferences="2"
|
|
||||||
EnableCOMDATFolding="2"
|
|
||||||
TargetMachine="1"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCALinkTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCManifestTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCXDCMakeTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCBscMakeTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCFxCopTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCAppVerifierTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCWebDeploymentTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPostBuildEventTool"
|
|
||||||
/>
|
|
||||||
</Configuration>
|
|
||||||
<Configuration
|
<Configuration
|
||||||
Name="Release|x64"
|
Name="Release|x64"
|
||||||
OutputDirectory="$(SolutionDir)..\..\tools\build\$(ConfigurationName)_$(PlatformName)"
|
OutputDirectory="$(SolutionDir)..\..\tools\build\$(ConfigurationName)_$(PlatformName)"
|
||||||
|
@ -417,7 +417,7 @@
|
||||||
/>
|
/>
|
||||||
</FileConfiguration>
|
</FileConfiguration>
|
||||||
<FileConfiguration
|
<FileConfiguration
|
||||||
Name="Debug|x64"
|
Name="Release|Win32"
|
||||||
>
|
>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
|
@ -425,7 +425,7 @@
|
||||||
/>
|
/>
|
||||||
</FileConfiguration>
|
</FileConfiguration>
|
||||||
<FileConfiguration
|
<FileConfiguration
|
||||||
Name="Release|Win32"
|
Name="Debug|x64"
|
||||||
>
|
>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
|
|
Loading…
Reference in New Issue