From c98ebdb8f0c439893ebc984dde7c84e90e32de6d Mon Sep 17 00:00:00 2001 From: Cirilo Bernardo Date: Tue, 23 Feb 2016 14:33:24 +1100 Subject: [PATCH] Changed 3d_cache log reporting from stderr/stdout to wxLogTrace --- 3d-viewer/3d_cache/3d_cache.cpp | 139 +++++++++++++------- 3d-viewer/3d_cache/3d_filename_resolver.cpp | 86 ++++++++---- 3d-viewer/3d_cache/3d_plugin_manager.cpp | 84 ++++++++---- 3 files changed, 209 insertions(+), 100 deletions(-) diff --git a/3d-viewer/3d_cache/3d_cache.cpp b/3d-viewer/3d_cache/3d_cache.cpp index dae09dfe3e..e4e01a1411 100644 --- a/3d-viewer/3d_cache/3d_cache.cpp +++ b/3d-viewer/3d_cache/3d_cache.cpp @@ -24,13 +24,13 @@ #define GLM_FORCE_RADIANS #include +#include #include -#include #include #include -#include #include +#include #include #include @@ -50,6 +50,7 @@ #define CACHE_CONFIG_NAME wxT( "cache.cfg" ) +#define MASK_3D_CACHE "3D_CACHE" static bool checkTag( const char* aTag, void* aPluginMgrPtr ) { @@ -112,9 +113,14 @@ static bool isSHA1null( const unsigned char* aSHA1Sum ) if( NULL == aSHA1Sum ) { #ifdef DEBUG - std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; - std::cerr << " * [BUG] NULL passed for aSHA1Sum\n"; + do { + std::ostringstream ostr; + ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; + ostr << " * [BUG] NULL passed for aSHA1Sum"; + wxLogTrace( MASK_3D_CACHE, "%s\n", ostr.str().c_str() ); + } while( 0 ); #endif + return false; } @@ -174,9 +180,14 @@ void S3D_CACHE_ENTRY::SetSHA1( const unsigned char* aSHA1Sum ) if( NULL == aSHA1Sum ) { #ifdef DEBUG - std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; - std::cerr << " * [BUG] NULL passed for aSHA1Sum\n"; + do { + std::ostringstream ostr; + ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; + ostr << " * [BUG] NULL passed for aSHA1Sum"; + wxLogTrace( MASK_3D_CACHE, "%s\n", ostr.str().c_str() ); + } while( 0 ); #endif + return; } @@ -227,8 +238,8 @@ SCENEGRAPH* S3D_CACHE::load( const wxString& aModelFile, S3D_CACHE_ENTRY** aCach if( full3Dpath.empty() ) { // the model cannot be found; we cannot proceed - std::cout << " * [3D model] could not find model '"; - std::cout << aModelFile.ToUTF8() << "'\n"; + wxLogTrace( MASK_3D_CACHE, " * [3D model] could not find model '%s'\n", + aModelFile.ToUTF8() ); return NULL; } @@ -274,9 +285,13 @@ SCENEGRAPH* S3D_CACHE::checkCache( const wxString& aFileName, S3D_CACHE_ENTRY** ( aFileName, ep ) ).second == false ) { #ifdef DEBUG - std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; - std::cerr << " * [BUG] duplicate entry in map file; key = "; - std::cerr << aFileName.ToUTF8() << "\n"; + do { + std::ostringstream ostr; + ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; + ostr << " * [BUG] duplicate entry in map file; key = '"; + ostr << aFileName.ToUTF8() << "'"; + wxLogTrace( MASK_3D_CACHE, "%s\n", ostr.str().c_str() ); + } while( 0 ); #endif m_CacheList.pop_back(); @@ -299,9 +314,13 @@ SCENEGRAPH* S3D_CACHE::checkCache( const wxString& aFileName, S3D_CACHE_ENTRY** ( aFileName, ep ) ).second == false ) { #ifdef DEBUG - std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; - std::cerr << " * [BUG] duplicate entry in map file; key = "; - std::cerr << aFileName.ToUTF8() << "\n"; + do { + std::ostringstream ostr; + ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; + ostr << " * [BUG] duplicate entry in map file; key = '"; + ostr << aFileName.ToUTF8() << "'"; + wxLogTrace( MASK_3D_CACHE, "%s\n", ostr.str().c_str() ); + } while( 0 ); #endif m_CacheList.pop_back(); @@ -334,8 +353,12 @@ bool S3D_CACHE::getSHA1( const wxString& aFileName, unsigned char* aSHA1Sum ) if( aFileName.empty() ) { #ifdef DEBUG - std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; - std::cerr << " * [BUG] empty filename\n"; + do { + std::ostringstream ostr; + ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; + ostr << " * [BUG] empty filename"; + wxLogTrace( MASK_3D_CACHE, "%s\n", ostr.str().c_str() ); + } while( 0 ); #endif return false; @@ -344,8 +367,12 @@ bool S3D_CACHE::getSHA1( const wxString& aFileName, unsigned char* aSHA1Sum ) if( NULL == aSHA1Sum ) { #ifdef DEBUG - std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; - std::cerr << " * [BUG] NULL pointer passed for aMD5Sum\n"; + do { + std::ostringstream ostr; + ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; + ostr << " * [BUG] NULL pointer passed for aMD5Sum"; + wxLogTrace( MASK_3D_CACHE, "%s\n", ostr.str().c_str() ); + } while( 0 ); #endif return false; @@ -392,7 +419,7 @@ bool S3D_CACHE::loadCacheData( S3D_CACHE_ENTRY* aCacheItem ) if( bname.empty() ) { #ifdef DEBUG - std::cerr << " * [3D model] cannot load cached model; no md5 hash available\n"; + wxLogTrace( MASK_3D_CACHE, " * [3D model] cannot load cached model; no file hash available\n" ); #endif return false; @@ -401,7 +428,7 @@ bool S3D_CACHE::loadCacheData( S3D_CACHE_ENTRY* aCacheItem ) if( m_CacheDir.empty() ) { wxString errmsg = _( "cannot load cached model; config directory unknown" ); - std::cerr << " * [3D model] " << errmsg.ToUTF8() << "\n"; + wxLogTrace( MASK_3D_CACHE, " * [3D model] %s\n", errmsg.ToUTF8() ); return false; } @@ -411,8 +438,8 @@ bool S3D_CACHE::loadCacheData( S3D_CACHE_ENTRY* aCacheItem ) if( !wxFileName::FileExists( fname ) ) { wxString errmsg = _( "cannot open file" ); - std::cerr << " * [3D model] " << errmsg.ToUTF8() << " '"; - std::cerr << fname.ToUTF8() << "'\n"; + wxLogTrace( MASK_3D_CACHE, " * [3D model] %s '%s'\n", + errmsg.ToUTF8(), fname.ToUTF8() ); return false; } @@ -433,8 +460,12 @@ bool S3D_CACHE::saveCacheData( S3D_CACHE_ENTRY* aCacheItem ) if( NULL == aCacheItem ) { #ifdef DEBUG - std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; - std::cerr << " * NULL passed for aCacheItem\n"; + do { + std::ostringstream ostr; + ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; + ostr << " * NULL passed for aCacheItem"; + wxLogTrace( MASK_3D_CACHE, "%s\n", ostr.str().c_str() ); + } while( 0 ); #endif return false; @@ -443,8 +474,12 @@ bool S3D_CACHE::saveCacheData( S3D_CACHE_ENTRY* aCacheItem ) if( NULL == aCacheItem->sceneData ) { #ifdef DEBUG - std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; - std::cerr << " * aCacheItem has no valid scene data\n"; + do { + std::ostringstream ostr; + ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; + ostr << " * aCacheItem has no valid scene data"; + wxLogTrace( MASK_3D_CACHE, "%s\n", ostr.str().c_str() ); + } while( 0 ); #endif return false; @@ -455,7 +490,7 @@ bool S3D_CACHE::saveCacheData( S3D_CACHE_ENTRY* aCacheItem ) if( bname.empty() ) { #ifdef DEBUG - std::cerr << " * [3D model] cannot load cached model; no hash available\n"; + wxLogTrace( MASK_3D_CACHE, " * [3D model] cannot load cached model; no file hash available\n" ); #endif return false; @@ -464,7 +499,7 @@ bool S3D_CACHE::saveCacheData( S3D_CACHE_ENTRY* aCacheItem ) if( m_CacheDir.empty() ) { wxString errmsg = _( "cannot load cached model; config directory unknown" ); - std::cerr << " * [3D model] " << errmsg.ToUTF8() << "\n"; + wxLogTrace( MASK_3D_CACHE, " * [3D model] %s\n", errmsg.ToUTF8() ); return false; } @@ -482,8 +517,8 @@ bool S3D_CACHE::saveCacheData( S3D_CACHE_ENTRY* aCacheItem ) if( !S_ISREG( info.st_mode ) ) { wxString errmsg = _( "path exists but is not a regular file" ); - std::cerr << " * [3D model] " << errmsg.ToUTF8() << " '"; - std::cerr << fname.ToUTF8() << "'\n"; + wxLogTrace( MASK_3D_CACHE, " * [3D model] %s '%s'\n", errmsg.ToUTF8(), + fname.ToUTF8() ); return false; } @@ -508,12 +543,14 @@ bool S3D_CACHE::Set3DConfigDir( const wxString& aConfigDir ) if( !cfgdir.DirExists() ) { - std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; + std::ostringstream ostr; + ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; wxString errmsg = _( "failed to create 3D configuration directory" ); - std::cerr << " * " << errmsg.ToUTF8() << "\n"; + ostr << " * " << errmsg.ToUTF8() << "\n"; errmsg = _( "config directory" ); - std::cerr << " * " << errmsg.ToUTF8() << " '"; - std::cerr << cfgdir.GetPath().ToUTF8() << "'\n"; + ostr << " * " << errmsg.ToUTF8() << " '"; + ostr << cfgdir.GetPath().ToUTF8() << "'"; + wxLogTrace( MASK_3D_CACHE, "%s\n", ostr.str().c_str() ); return false; } @@ -525,9 +562,13 @@ bool S3D_CACHE::Set3DConfigDir( const wxString& aConfigDir ) if( !m_FNResolver->Set3DConfigDir( m_ConfigDir ) ) { #ifdef DEBUG - std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; - std::cerr << " * could not set 3D Config Directory on filename resolver\n"; - std::cerr << " * config directory: '" << m_ConfigDir.ToUTF8() << "'\n"; + do { + std::ostringstream ostr; + ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; + ostr << " * could not set 3D Config Directory on filename resolver\n"; + ostr << " * config directory: '" << m_ConfigDir.ToUTF8() << "'"; + wxLogTrace( MASK_3D_CACHE, "%s\n", ostr.str().c_str() ); + } while( 0 ); #endif } @@ -539,12 +580,14 @@ bool S3D_CACHE::Set3DConfigDir( const wxString& aConfigDir ) if( !cfgdir.DirExists() ) { - std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; + std::ostringstream ostr; + ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; wxString errmsg = _( "failed to create 3D cache directory" ); - std::cerr << " * " << errmsg.ToUTF8() << "\n"; + ostr << " * " << errmsg.ToUTF8() << "\n"; errmsg = _( "cache directory" ); - std::cerr << " * " << errmsg.ToUTF8() << " '"; - std::cerr << cfgdir.GetPath().ToUTF8() << "'\n"; + ostr << " * " << errmsg.ToUTF8() << " '"; + ostr << cfgdir.GetPath().ToUTF8() << "'"; + wxLogTrace( MASK_3D_CACHE, "%s\n", ostr.str().c_str() ); return false; } @@ -597,9 +640,11 @@ wxString S3D_CACHE::Get3DConfigDir( bool createDefault ) if( !cfgpath.DirExists() ) { + std::ostringstream ostr; wxString errmsg = _( "failed to create 3D configuration directory" ); - std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; - std::cerr << " * " << errmsg.ToUTF8() << "\n"; + ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; + ostr << " * " << errmsg.ToUTF8(); + wxLogTrace( MASK_3D_CACHE, "%s\n", ostr.str().c_str() ); return wxT( "" ); } @@ -696,8 +741,12 @@ S3DMODEL* S3D_CACHE::GetModel( const wxString& aModelFileName ) if( !cp ) { #ifdef DEBUG - std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; - std::cerr << " * [BUG] model loaded with no associated S3D_CACHE_ENTRY\n"; + do { + std::ostringstream ostr; + ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; + ostr << " * [BUG] model loaded with no associated S3D_CACHE_ENTRY"; + wxLogTrace( MASK_3D_CACHE, "%s\n", ostr.str().c_str() ); + } while( 0 ); #endif return NULL; diff --git a/3d-viewer/3d_cache/3d_filename_resolver.cpp b/3d-viewer/3d_cache/3d_filename_resolver.cpp index bd53a70480..9282055f30 100644 --- a/3d-viewer/3d_cache/3d_filename_resolver.cpp +++ b/3d-viewer/3d_cache/3d_filename_resolver.cpp @@ -22,11 +22,13 @@ */ #include +#include #include #include #include #include #include +#include #include #include @@ -41,6 +43,8 @@ #define ERRFLG_RELPATH (2) #define ERRFLG_ENVPATH (4) +#define MASK_3D_RESOLVER "3D_RESOLVER" + static bool getHollerith( const std::string& aString, size_t& aIndex, wxString& aResult ); @@ -117,9 +121,13 @@ bool S3D_FILENAME_RESOLVER::SetProjectDir( const wxString& aProjDir, bool* flgCh } #ifdef DEBUG - std::cout << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; - std::cout << " * [INFO] changed project dir to "; - std::cout << m_Paths.front().m_pathexp.ToUTF8() << "\n"; + do { + std::ostringstream ostr; + ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; + ostr << " * [INFO] changed project dir to "; + ostr << m_Paths.front().m_pathexp.ToUTF8(); + wxLogTrace( MASK_3D_RESOLVER, "%s\n", ostr.str().c_str() ); + } while( 0 ); #endif return true; @@ -165,13 +173,13 @@ bool S3D_FILENAME_RESOLVER::createPathList( void ) return false; #ifdef DEBUG - std::cout << " * [3D model] search paths:\n"; + wxLogTrace( MASK_3D_RESOLVER, " * [3D model] search paths:\n" ); std::list< S3D_ALIAS >::const_iterator sPL = m_Paths.begin(); std::list< S3D_ALIAS >::const_iterator ePL = m_Paths.end(); while( sPL != ePL ) { - std::cout << " + '" << (*sPL).m_pathexp.ToUTF8() << "'\n"; + wxLogTrace( MASK_3D_RESOLVER, " + '%s'\n", (*sPL).m_pathexp.ToUTF8() ); ++sPL; } #endif @@ -518,9 +526,11 @@ bool S3D_FILENAME_RESOLVER::readPathList( void ) { if( m_ConfigDir.empty() ) { - std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; + std::ostringstream ostr; + ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; wxString errmsg = _( "3D configuration directory is unknown" ); - std::cerr << " * " << errmsg.ToUTF8() << "\n"; + ostr << " * " << errmsg.ToUTF8(); + wxLogTrace( MASK_3D_RESOLVER, "%s\n", ostr.str().c_str() ); return false; } @@ -535,10 +545,12 @@ bool S3D_FILENAME_RESOLVER::readPathList( void ) if( !wxFileName::Exists( cfgname ) ) { - std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; + std::ostringstream ostr; + ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; wxString errmsg = _( "no 3D configuration file" ); - std::cerr << " * " << errmsg.ToUTF8() << " '"; - std::cerr << cfgname.ToUTF8() << "'\n"; + ostr << " * " << errmsg.ToUTF8() << " '"; + ostr << cfgname.ToUTF8() << "'"; + wxLogTrace( MASK_3D_RESOLVER, "%s\n", ostr.str().c_str() ); return false; } @@ -546,9 +558,11 @@ bool S3D_FILENAME_RESOLVER::readPathList( void ) if( !cfgFile.is_open() ) { - std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; + std::ostringstream ostr; + ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; wxString errmsg = _( "could not open configuration file" ); - std::cerr << " * " << errmsg.ToUTF8() << " '" << cfgname.ToUTF8() << "'\n"; + ostr << " * " << errmsg.ToUTF8() << " '" << cfgname.ToUTF8() << "'"; + wxLogTrace( MASK_3D_RESOLVER, "%s\n", ostr.str().c_str() ); return false; } @@ -618,9 +632,11 @@ bool S3D_FILENAME_RESOLVER::writePathList( void ) { if( m_ConfigDir.empty() ) { - std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; + std::ostringstream ostr; + ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; wxString errmsg = _( "3D configuration directory is unknown" ); - std::cerr << " * " << errmsg.ToUTF8() << "\n"; + ostr << " * " << errmsg.ToUTF8(); + wxLogTrace( MASK_3D_RESOLVER, "%s\n", ostr.str().c_str() ); wxMessageBox( errmsg, _( "Write 3D search path list" ) ); return false; @@ -660,9 +676,11 @@ bool S3D_FILENAME_RESOLVER::writePathList( void ) if( !cfgFile.is_open() ) { - std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; + std::ostringstream ostr; + ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; wxString errmsg = _( "could not open configuration file " ); - std::cerr << " * " << errmsg.ToUTF8() << " '" << cfgname.ToUTF8() << "'\n"; + ostr << " * " << errmsg.ToUTF8() << " '" << cfgname.ToUTF8() << "'"; + wxLogTrace( MASK_3D_RESOLVER, "%s\n", ostr.str().c_str() ); wxMessageBox( _( "Could not open configuration file" ), _( "Write 3D search path list" ) ); @@ -828,9 +846,11 @@ static bool getHollerith( const std::string& aString, size_t& aIndex, wxString& if( aIndex < 0 || aIndex >= aString.size() ) { - std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; + std::ostringstream ostr; + ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; wxString errmsg = _( "bad Hollerith string on line" ); - std::cerr << " * " << errmsg.ToUTF8() << "\n'" << aString << "'\n"; + ostr << " * " << errmsg.ToUTF8() << "\n'" << aString << "'"; + wxLogTrace( MASK_3D_RESOLVER, "%s\n", ostr.str().c_str() ); return false; } @@ -839,9 +859,11 @@ static bool getHollerith( const std::string& aString, size_t& aIndex, wxString& if( std::string::npos == i2 ) { - std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; + std::ostringstream ostr; + ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; wxString errmsg = _( "missing opening quote mark in config file" ); - std::cerr << " * " << errmsg.ToUTF8() << "\n'" << aString << "'\n"; + ostr << " * " << errmsg.ToUTF8() << "\n'" << aString << "'"; + wxLogTrace( MASK_3D_RESOLVER, "%s\n", ostr.str().c_str() ); return false; } @@ -850,9 +872,11 @@ static bool getHollerith( const std::string& aString, size_t& aIndex, wxString& if( i2 >= aString.size() ) { - std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; + std::ostringstream ostr; + ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; wxString errmsg = _( "invalid entry (unexpected end of line)" ); - std::cerr << " * " << errmsg.ToUTF8() << "\n'" << aString << "'\n"; + ostr << " * " << errmsg.ToUTF8() << "\n'" << aString << "'"; + wxLogTrace( MASK_3D_RESOLVER, "%s\n", ostr.str().c_str() ); return false; } @@ -864,9 +888,11 @@ static bool getHollerith( const std::string& aString, size_t& aIndex, wxString& if( tnum.empty() || aString[i2++] != ':' ) { - std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; + std::ostringstream ostr; + ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; wxString errmsg = _( "bad Hollerith string on line" ); - std::cerr << " * " << errmsg.ToUTF8() << "\n'" << aString << "'\n"; + ostr << " * " << errmsg.ToUTF8() << "\n'" << aString << "'"; + wxLogTrace( MASK_3D_RESOLVER, "%s\n", ostr.str().c_str() ); return false; } @@ -878,9 +904,11 @@ static bool getHollerith( const std::string& aString, size_t& aIndex, wxString& if( (i2 + nchars) >= aString.size() ) { - std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; + std::ostringstream ostr; + ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; wxString errmsg = _( "invalid entry (unexpected end of line)" ); - std::cerr << " * " << errmsg.ToUTF8() << "\n'" << aString << "'\n"; + ostr << " * " << errmsg.ToUTF8() << "\n'" << aString << "'"; + wxLogTrace( MASK_3D_RESOLVER, "%s\n", ostr.str().c_str() ); return false; } @@ -893,9 +921,11 @@ static bool getHollerith( const std::string& aString, size_t& aIndex, wxString& if( aString[i2] != '"' ) { - std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; + std::ostringstream ostr; + ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; wxString errmsg = _( "missing closing quote mark in config file" ); - std::cerr << " * " << errmsg.ToUTF8() << "\n'" << aString << "'\n"; + ostr << " * " << errmsg.ToUTF8() << "\n'" << aString << "'"; + wxLogTrace( MASK_3D_RESOLVER, "%s\n", ostr.str().c_str() ); return false; } diff --git a/3d-viewer/3d_cache/3d_plugin_manager.cpp b/3d-viewer/3d_cache/3d_plugin_manager.cpp index db58705664..c687b312b6 100644 --- a/3d-viewer/3d_cache/3d_plugin_manager.cpp +++ b/3d-viewer/3d_cache/3d_plugin_manager.cpp @@ -24,16 +24,13 @@ #include #include -#include -#include -#include #include +#include #include #include #include #include -#include #include #include "3d_plugin_manager.h" @@ -41,6 +38,9 @@ #include "3d_cache/sg/scenegraph.h" #include "plugins/ldr/3d/pluginldr3D.h" +#define MASK_3D_PLUGINMGR "3D_PLUGIN_MANAGER" + + S3D_PLUGIN_MANAGER::S3D_PLUGIN_MANAGER() { // create the initial file filter list entry @@ -54,19 +54,19 @@ S3D_PLUGIN_MANAGER::S3D_PLUGIN_MANAGER() { std::multimap< const wxString, KICAD_PLUGIN_LDR_3D* >::const_iterator sM = m_ExtMap.begin(); std::multimap< const wxString, KICAD_PLUGIN_LDR_3D* >::const_iterator eM = m_ExtMap.end(); - std::cout << "* Extension [plugin name]:\n"; + wxLogTrace( MASK_3D_PLUGINMGR, " * Extension [plugin name]:\n" ); while( sM != eM ) { - std::cout << " + '" << sM->first.ToUTF8() << "' ["; - std::cout << sM->second->GetKicadPluginName() << "]\n"; + wxLogTrace( MASK_3D_PLUGINMGR, " + '%s' [%s]\n", sM->first.ToUTF8(), + sM->second->GetKicadPluginName() ); ++sM; } } else { - std::cout << "* No plugins available\n"; + wxLogTrace( MASK_3D_PLUGINMGR, " * No plugins available\n" ); } @@ -75,17 +75,17 @@ S3D_PLUGIN_MANAGER::S3D_PLUGIN_MANAGER() /// list of file filters std::list< wxString >::const_iterator sFF = m_FileFilters.begin(); std::list< wxString >::const_iterator eFF = m_FileFilters.end(); - std::cout << "* File filters:\n"; + wxLogTrace( MASK_3D_PLUGINMGR, " * File filters:\n" ); while( sFF != eFF ) { - std::cout << " + '" << *sFF << "'\n"; + wxLogTrace( MASK_3D_PLUGINMGR, " + '%s'\n", (*sFF).ToUTF8() ); ++sFF; } } else { - std::cout << "* No file filters available\n"; + wxLogTrace( MASK_3D_PLUGINMGR, " * No file filters available\n" ); } #endif // DEBUG @@ -168,8 +168,12 @@ void S3D_PLUGIN_MANAGER::loadPlugins( void ) while( sPL != ePL ) { #ifdef DEBUG - std::cout << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << ":\n"; - std::cout << "* [DEBUG] searching path: '" << (*sPL).ToUTF8() << "'\n"; + do { + std::ostringstream ostr; + ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << ":\n"; + ostr << " * [DEBUG] searching path: '" << (*sPL).ToUTF8() << "'"; + wxLogTrace( MASK_3D_PLUGINMGR, "%s\n", ostr.str().c_str() ); + } while( 0 ); #endif listPlugins( *sPL, pluginlist ); ++sPL; @@ -188,15 +192,23 @@ void S3D_PLUGIN_MANAGER::loadPlugins( void ) if( pp->Open( sPL->ToUTF8() ) ) { #ifdef DEBUG - std::cout << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << ":\n"; - std::cout << "* [DEBUG] adding plugin\n"; + do { + std::ostringstream ostr; + ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << ":\n"; + ostr << "* [DEBUG] adding plugin"; + wxLogTrace( MASK_3D_PLUGINMGR, "%s\n", ostr.str().c_str() ); + } while( 0 ); #endif m_Plugins.push_back( pp ); int nf = pp->GetNFilters(); #ifdef DEBUG - std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; - std::cerr << " * [INFO] adding " << nf << " filters\n"; + do { + std::ostringstream ostr; + ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; + ostr << " * [INFO] adding " << nf << " filters"; + wxLogTrace( MASK_3D_PLUGINMGR, "%s\n", ostr.str().c_str() ); + } while( 0 ); #endif for( int i = 0; i < nf; ++i ) @@ -215,8 +227,12 @@ void S3D_PLUGIN_MANAGER::loadPlugins( void ) else { #ifdef DEBUG - std::cout << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << ":\n"; - std::cout << "* [DEBUG] deleting plugin\n"; + do { + std::ostringstream ostr; + ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << ":\n"; + ostr << "* [DEBUG] deleting plugin"; + wxLogTrace( MASK_3D_PLUGINMGR, "%s\n", ostr.str().c_str() ); + } while( 0 ); #endif delete pp; } @@ -225,8 +241,12 @@ void S3D_PLUGIN_MANAGER::loadPlugins( void ) } #ifdef DEBUG - std::cout << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << ":\n"; - std::cout << "* [DEBUG] plugins loaded\n"; + do { + std::ostringstream ostr; + ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << ":\n"; + ostr << "* [DEBUG] plugins loaded"; + wxLogTrace( MASK_3D_PLUGINMGR, "%s\n", ostr.str().c_str() ); + } while( 0 ); #endif return; @@ -296,7 +316,8 @@ void S3D_PLUGIN_MANAGER::checkPluginName( const wxString& aPath, aPluginList.push_back( wxpath ); #ifdef DEBUG - std::cerr << " * [INFO] found 3D plugin '" << wxpath.ToUTF8() << "'\n"; + wxLogTrace( MASK_3D_PLUGINMGR, " * [INFO] found 3D plugin '%s'\n", + wxpath.ToUTF8() ); #endif return; @@ -311,7 +332,8 @@ void S3D_PLUGIN_MANAGER::checkPluginPath( const wxString& aPath, return; #ifdef DEBUG - std::cerr << " * [INFO] checking for 3D plugins in '" << aPath << "'\n"; + wxLogTrace( MASK_3D_PLUGINMGR, " * [INFO] checking for 3D plugins in '%s'\n", + aPath.ToUTF8() ); #endif wxFileName path( wxFileName::DirName( aPath ) ); @@ -370,8 +392,12 @@ void S3D_PLUGIN_MANAGER::addExtensionMap( KICAD_PLUGIN_LDR_3D* aPlugin ) int nExt = aPlugin->GetNExtensions(); #ifdef DEBUG - std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; - std::cerr << " * [INFO] adding " << nExt << " extensions\n"; + do { + std::ostringstream ostr; + ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; + ostr << " * [INFO] adding " << nExt << " extensions"; + wxLogTrace( MASK_3D_PLUGINMGR, "%s\n", ostr.str().c_str() ); + } while( 0 ); #endif for( int i = 0; i < nExt; ++i ) @@ -436,8 +462,12 @@ void S3D_PLUGIN_MANAGER::ClosePlugins( void ) std::list< KICAD_PLUGIN_LDR_3D* >::iterator eP = m_Plugins.end(); #ifdef DEBUG - std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; - std::cerr << " * [INFO] closing " << m_Plugins.size() << " plugins\n"; + do { + std::ostringstream ostr; + ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; + ostr << " * [INFO] closing " << m_Plugins.size() << " plugins"; + wxLogTrace( MASK_3D_PLUGINMGR, "%s\n", ostr.str().c_str() ); + } while( 0 ); #endif while( sP != eP )