Преглед на файлове

Add ThreadID to default log stream output.

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@106 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
kimmi преди 17 години
родител
ревизия
b5c54703d0
променени са 5 файла, в които са добавени 76 реда и са изтрити 44 реда
  1. 37 10
      code/DefaultLogger.cpp
  2. 4 4
      contrib/cppunit-1.12.1/src/cppunit/cppunit.vcproj
  3. 5 0
      include/DefaultLogger.h
  4. 1 1
      include/LogStream.h
  5. 29 29
      workspaces/vc8/assimp_view.vcproj

+ 37 - 10
code/DefaultLogger.cpp

@@ -47,6 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include "FileLogStream.h"
 
 #include <iostream>
+#include <sstream>
 
 namespace Assimp
 {
@@ -68,17 +69,24 @@ struct LogStreamInfo
 	{
 		// empty
 	}
+	
+	// Destructor
+	~LogStreamInfo()
+	{
+		// empty
+	}
 };
 // ---------------------------------------------------------------------------
 //	Creates the only singleton instance
 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;
 }
 // ---------------------------------------------------------------------------
-void DefaultLogger::set (Logger *logger)
+void DefaultLogger::set( Logger *logger )
 {
 	if (!logger)
 	{
@@ -110,20 +118,20 @@ void DefaultLogger::kill()
 
 // ---------------------------------------------------------------------------
 //	Debug message
-void DefaultLogger::debug(const std::string &message)
+void DefaultLogger::debug( const std::string &message )
 {
 	if ( m_Severity == Logger::NORMAL )
 		return;
 
-	const std::string msg( "Debug: " + message );
+	const std::string msg( "Debug, thread " + getThreadID() + " :" + message );
 	writeToStreams( msg, Logger::DEBUGGING );
 }
 
 // ---------------------------------------------------------------------------
 //	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 );
 }
 
@@ -131,7 +139,7 @@ void DefaultLogger::info(const std::string &message)
 //	Logs a warning
 void DefaultLogger::warn( const std::string &message )
 {
-	const std::string msg( "Warn:  " + message );
+	const std::string msg( "Warn:  " + getThreadID() + " :"+ message );
 	writeToStreams( msg, Logger::WARN );
 }
 
@@ -139,7 +147,7 @@ void DefaultLogger::warn( const std::string &message )
 //	Logs an error
 void DefaultLogger::error( const std::string &message )
 {
-	const std::string msg( "Error:  " + message );
+	const std::string msg( "Error:  "+ getThreadID() + " :" + message );
 	writeToStreams( msg, Logger::ERR );
 }
 
@@ -258,8 +266,7 @@ void DefaultLogger::writeToStreams(const std::string &message,
 {
 	if ( message.empty() )
 		return;
-
-	for ( ConstStreamIt it = this->m_StreamArray.begin();
+	for ( ConstStreamIt it = m_StreamArray.begin();
 		it != m_StreamArray.end();
 		++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

+ 4 - 4
contrib/cppunit-1.12.1/src/cppunit/cppunit.vcproj

@@ -653,11 +653,11 @@
 				</FileConfiguration>
 			</File>
 			<File
-				RelativePath="..\..\include\cppunit\ui\text\TextTestRunner.h"
+				RelativePath="..\..\include\cppunit\TextTestRunner.h"
 				>
 			</File>
 			<File
-				RelativePath="..\..\include\cppunit\TextTestRunner.h"
+				RelativePath="..\..\include\cppunit\ui\text\TextTestRunner.h"
 				>
 			</File>
 		</Filter>
@@ -2694,11 +2694,11 @@
 			>
 		</File>
 		<File
-			RelativePath="Makefile.am"
+			RelativePath="..\..\include\cppunit\Makefile.am"
 			>
 		</File>
 		<File
-			RelativePath="..\..\include\cppunit\Makefile.am"
+			RelativePath="Makefile.am"
 			>
 		</File>
 	</Files>

+ 5 - 0
include/DefaultLogger.h

@@ -131,6 +131,11 @@ private:
 	/**	@brief	Writes message into a file	*/
 	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:
 	//	Aliases for stream container
 	typedef std::vector<LogStreamInfo*>	StreamArray;

+ 1 - 1
include/LogStream.h

@@ -7,7 +7,7 @@ namespace Assimp
 {
 // ---------------------------------------------------------------------------
 /**	@class	LogStream
-	 *	@brief	Abstract interface for log stream implementations.
+ *	@brief	Abstract interface for log stream implementations.
  */
 class ASSIMP_API LogStream
 {

+ 29 - 29
workspaces/vc8/assimp_view.vcproj

@@ -100,11 +100,12 @@
 			/>
 		</Configuration>
 		<Configuration
-			Name="Debug|x64"
+			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"
@@ -120,21 +121,15 @@
 			/>
 			<Tool
 				Name="VCMIDLTool"
-				TargetEnvironment="3"
 			/>
 			<Tool
 				Name="VCCLCompilerTool"
-				Optimization="0"
 				AdditionalIncludeDirectories="&quot;$(DXSDK_DIR)include&quot;;..\..\include;..\..\code"
-				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS"
-				MinimalRebuild="true"
-				BasicRuntimeChecks="3"
-				SmallerTypeCheck="true"
-				RuntimeLibrary="1"
-				EnableFunctionLevelLinking="true"
+				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS"
+				RuntimeLibrary="0"
 				UsePrecompiledHeader="2"
 				WarningLevel="3"
-				Detect64BitPortabilityProblems="false"
+				Detect64BitPortabilityProblems="true"
 				DebugInformationFormat="3"
 			/>
 			<Tool
@@ -149,12 +144,16 @@
 			<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)\assimpview64d.exe"
-				LinkIncremental="2"
-				AdditionalLibraryDirectories="..\..\lib\assimp_debug_x64;&quot;$(DXSDK_DIR)lib\x64&quot;"
+				OutputFile="$(OutDir)\assimpview32.exe"
+				LinkIncremental="1"
+				AdditionalLibraryDirectories="..\..\lib\assimp_release_win32;&quot;$(DXSDK_DIR)lib\x86&quot;"
+				IgnoreAllDefaultLibraries="false"
+				IgnoreDefaultLibraryNames=""
 				GenerateDebugInformation="true"
 				SubSystem="2"
-				TargetMachine="17"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				TargetMachine="1"
 			/>
 			<Tool
 				Name="VCALinkTool"
@@ -182,12 +181,11 @@
 			/>
 		</Configuration>
 		<Configuration
-			Name="Release|Win32"
+			Name="Debug|x64"
 			OutputDirectory="$(SolutionDir)..\..\tools\build\$(ConfigurationName)_$(PlatformName)"
 			IntermediateDirectory="$(SolutionDir)..\..\tools\build\$(ConfigurationName)_$(PlatformName)\obj"
 			ConfigurationType="1"
 			CharacterSet="2"
-			WholeProgramOptimization="1"
 			>
 			<Tool
 				Name="VCPreBuildEventTool"
@@ -203,15 +201,21 @@
 			/>
 			<Tool
 				Name="VCMIDLTool"
+				TargetEnvironment="3"
 			/>
 			<Tool
 				Name="VCCLCompilerTool"
+				Optimization="0"
 				AdditionalIncludeDirectories="&quot;$(DXSDK_DIR)include&quot;;..\..\include;..\..\code"
-				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS"
-				RuntimeLibrary="0"
+				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				SmallerTypeCheck="true"
+				RuntimeLibrary="1"
+				EnableFunctionLevelLinking="true"
 				UsePrecompiledHeader="2"
 				WarningLevel="3"
-				Detect64BitPortabilityProblems="true"
+				Detect64BitPortabilityProblems="false"
 				DebugInformationFormat="3"
 			/>
 			<Tool
@@ -226,16 +230,12 @@
 			<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;&quot;$(DXSDK_DIR)lib\x86&quot;"
-				IgnoreAllDefaultLibraries="false"
-				IgnoreDefaultLibraryNames=""
+				OutputFile="$(OutDir)\assimpview64d.exe"
+				LinkIncremental="2"
+				AdditionalLibraryDirectories="..\..\lib\assimp_debug_x64;&quot;$(DXSDK_DIR)lib\x64&quot;"
 				GenerateDebugInformation="true"
 				SubSystem="2"
-				OptimizeReferences="2"
-				EnableCOMDATFolding="2"
-				TargetMachine="1"
+				TargetMachine="17"
 			/>
 			<Tool
 				Name="VCALinkTool"
@@ -417,7 +417,7 @@
 					/>
 				</FileConfiguration>
 				<FileConfiguration
-					Name="Debug|x64"
+					Name="Release|Win32"
 					>
 					<Tool
 						Name="VCCLCompilerTool"
@@ -425,7 +425,7 @@
 					/>
 				</FileConfiguration>
 				<FileConfiguration
-					Name="Release|Win32"
+					Name="Debug|x64"
 					>
 					<Tool
 						Name="VCCLCompilerTool"