Changed 3d_cache log reporting from stderr/stdout to wxLogTrace

This commit is contained in:
Cirilo Bernardo 2016-02-23 14:33:24 +11:00
parent c5984b207b
commit c98ebdb8f0
3 changed files with 209 additions and 100 deletions

View File

@ -24,13 +24,13 @@
#define GLM_FORCE_RADIANS #define GLM_FORCE_RADIANS
#include <iostream> #include <iostream>
#include <sstream>
#include <fstream> #include <fstream>
#include <string>
#include <utility> #include <utility>
#include <iterator> #include <iterator>
#include <cstdio>
#include <wx/filename.h> #include <wx/filename.h>
#include <wx/log.h>
#include <wx/utils.h> #include <wx/utils.h>
#include <wx/stdpaths.h> #include <wx/stdpaths.h>
@ -50,6 +50,7 @@
#define CACHE_CONFIG_NAME wxT( "cache.cfg" ) #define CACHE_CONFIG_NAME wxT( "cache.cfg" )
#define MASK_3D_CACHE "3D_CACHE"
static bool checkTag( const char* aTag, void* aPluginMgrPtr ) static bool checkTag( const char* aTag, void* aPluginMgrPtr )
{ {
@ -112,9 +113,14 @@ static bool isSHA1null( const unsigned char* aSHA1Sum )
if( NULL == aSHA1Sum ) if( NULL == aSHA1Sum )
{ {
#ifdef DEBUG #ifdef DEBUG
std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; do {
std::cerr << " * [BUG] NULL passed for aSHA1Sum\n"; 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 #endif
return false; return false;
} }
@ -174,9 +180,14 @@ void S3D_CACHE_ENTRY::SetSHA1( const unsigned char* aSHA1Sum )
if( NULL == aSHA1Sum ) if( NULL == aSHA1Sum )
{ {
#ifdef DEBUG #ifdef DEBUG
std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; do {
std::cerr << " * [BUG] NULL passed for aSHA1Sum\n"; 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 #endif
return; return;
} }
@ -227,8 +238,8 @@ SCENEGRAPH* S3D_CACHE::load( const wxString& aModelFile, S3D_CACHE_ENTRY** aCach
if( full3Dpath.empty() ) if( full3Dpath.empty() )
{ {
// the model cannot be found; we cannot proceed // the model cannot be found; we cannot proceed
std::cout << " * [3D model] could not find model '"; wxLogTrace( MASK_3D_CACHE, " * [3D model] could not find model '%s'\n",
std::cout << aModelFile.ToUTF8() << "'\n"; aModelFile.ToUTF8() );
return NULL; return NULL;
} }
@ -274,9 +285,13 @@ SCENEGRAPH* S3D_CACHE::checkCache( const wxString& aFileName, S3D_CACHE_ENTRY**
( aFileName, ep ) ).second == false ) ( aFileName, ep ) ).second == false )
{ {
#ifdef DEBUG #ifdef DEBUG
std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; do {
std::cerr << " * [BUG] duplicate entry in map file; key = "; std::ostringstream ostr;
std::cerr << aFileName.ToUTF8() << "\n"; 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 #endif
m_CacheList.pop_back(); m_CacheList.pop_back();
@ -299,9 +314,13 @@ SCENEGRAPH* S3D_CACHE::checkCache( const wxString& aFileName, S3D_CACHE_ENTRY**
( aFileName, ep ) ).second == false ) ( aFileName, ep ) ).second == false )
{ {
#ifdef DEBUG #ifdef DEBUG
std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; do {
std::cerr << " * [BUG] duplicate entry in map file; key = "; std::ostringstream ostr;
std::cerr << aFileName.ToUTF8() << "\n"; 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 #endif
m_CacheList.pop_back(); m_CacheList.pop_back();
@ -334,8 +353,12 @@ bool S3D_CACHE::getSHA1( const wxString& aFileName, unsigned char* aSHA1Sum )
if( aFileName.empty() ) if( aFileName.empty() )
{ {
#ifdef DEBUG #ifdef DEBUG
std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; do {
std::cerr << " * [BUG] empty filename\n"; 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 #endif
return false; return false;
@ -344,8 +367,12 @@ bool S3D_CACHE::getSHA1( const wxString& aFileName, unsigned char* aSHA1Sum )
if( NULL == aSHA1Sum ) if( NULL == aSHA1Sum )
{ {
#ifdef DEBUG #ifdef DEBUG
std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; do {
std::cerr << " * [BUG] NULL pointer passed for aMD5Sum\n"; 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 #endif
return false; return false;
@ -392,7 +419,7 @@ bool S3D_CACHE::loadCacheData( S3D_CACHE_ENTRY* aCacheItem )
if( bname.empty() ) if( bname.empty() )
{ {
#ifdef DEBUG #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 #endif
return false; return false;
@ -401,7 +428,7 @@ bool S3D_CACHE::loadCacheData( S3D_CACHE_ENTRY* aCacheItem )
if( m_CacheDir.empty() ) if( m_CacheDir.empty() )
{ {
wxString errmsg = _( "cannot load cached model; config directory unknown" ); 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; return false;
} }
@ -411,8 +438,8 @@ bool S3D_CACHE::loadCacheData( S3D_CACHE_ENTRY* aCacheItem )
if( !wxFileName::FileExists( fname ) ) if( !wxFileName::FileExists( fname ) )
{ {
wxString errmsg = _( "cannot open file" ); wxString errmsg = _( "cannot open file" );
std::cerr << " * [3D model] " << errmsg.ToUTF8() << " '"; wxLogTrace( MASK_3D_CACHE, " * [3D model] %s '%s'\n",
std::cerr << fname.ToUTF8() << "'\n"; errmsg.ToUTF8(), fname.ToUTF8() );
return false; return false;
} }
@ -433,8 +460,12 @@ bool S3D_CACHE::saveCacheData( S3D_CACHE_ENTRY* aCacheItem )
if( NULL == aCacheItem ) if( NULL == aCacheItem )
{ {
#ifdef DEBUG #ifdef DEBUG
std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; do {
std::cerr << " * NULL passed for aCacheItem\n"; 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 #endif
return false; return false;
@ -443,8 +474,12 @@ bool S3D_CACHE::saveCacheData( S3D_CACHE_ENTRY* aCacheItem )
if( NULL == aCacheItem->sceneData ) if( NULL == aCacheItem->sceneData )
{ {
#ifdef DEBUG #ifdef DEBUG
std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; do {
std::cerr << " * aCacheItem has no valid scene data\n"; 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 #endif
return false; return false;
@ -455,7 +490,7 @@ bool S3D_CACHE::saveCacheData( S3D_CACHE_ENTRY* aCacheItem )
if( bname.empty() ) if( bname.empty() )
{ {
#ifdef DEBUG #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 #endif
return false; return false;
@ -464,7 +499,7 @@ bool S3D_CACHE::saveCacheData( S3D_CACHE_ENTRY* aCacheItem )
if( m_CacheDir.empty() ) if( m_CacheDir.empty() )
{ {
wxString errmsg = _( "cannot load cached model; config directory unknown" ); 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; return false;
} }
@ -482,8 +517,8 @@ bool S3D_CACHE::saveCacheData( S3D_CACHE_ENTRY* aCacheItem )
if( !S_ISREG( info.st_mode ) ) if( !S_ISREG( info.st_mode ) )
{ {
wxString errmsg = _( "path exists but is not a regular file" ); wxString errmsg = _( "path exists but is not a regular file" );
std::cerr << " * [3D model] " << errmsg.ToUTF8() << " '"; wxLogTrace( MASK_3D_CACHE, " * [3D model] %s '%s'\n", errmsg.ToUTF8(),
std::cerr << fname.ToUTF8() << "'\n"; fname.ToUTF8() );
return false; return false;
} }
@ -508,12 +543,14 @@ bool S3D_CACHE::Set3DConfigDir( const wxString& aConfigDir )
if( !cfgdir.DirExists() ) 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" ); wxString errmsg = _( "failed to create 3D configuration directory" );
std::cerr << " * " << errmsg.ToUTF8() << "\n"; ostr << " * " << errmsg.ToUTF8() << "\n";
errmsg = _( "config directory" ); errmsg = _( "config directory" );
std::cerr << " * " << errmsg.ToUTF8() << " '"; ostr << " * " << errmsg.ToUTF8() << " '";
std::cerr << cfgdir.GetPath().ToUTF8() << "'\n"; ostr << cfgdir.GetPath().ToUTF8() << "'";
wxLogTrace( MASK_3D_CACHE, "%s\n", ostr.str().c_str() );
return false; return false;
} }
@ -525,9 +562,13 @@ bool S3D_CACHE::Set3DConfigDir( const wxString& aConfigDir )
if( !m_FNResolver->Set3DConfigDir( m_ConfigDir ) ) if( !m_FNResolver->Set3DConfigDir( m_ConfigDir ) )
{ {
#ifdef DEBUG #ifdef DEBUG
std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; do {
std::cerr << " * could not set 3D Config Directory on filename resolver\n"; std::ostringstream ostr;
std::cerr << " * config directory: '" << m_ConfigDir.ToUTF8() << "'\n"; 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 #endif
} }
@ -539,12 +580,14 @@ bool S3D_CACHE::Set3DConfigDir( const wxString& aConfigDir )
if( !cfgdir.DirExists() ) 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" ); wxString errmsg = _( "failed to create 3D cache directory" );
std::cerr << " * " << errmsg.ToUTF8() << "\n"; ostr << " * " << errmsg.ToUTF8() << "\n";
errmsg = _( "cache directory" ); errmsg = _( "cache directory" );
std::cerr << " * " << errmsg.ToUTF8() << " '"; ostr << " * " << errmsg.ToUTF8() << " '";
std::cerr << cfgdir.GetPath().ToUTF8() << "'\n"; ostr << cfgdir.GetPath().ToUTF8() << "'";
wxLogTrace( MASK_3D_CACHE, "%s\n", ostr.str().c_str() );
return false; return false;
} }
@ -597,9 +640,11 @@ wxString S3D_CACHE::Get3DConfigDir( bool createDefault )
if( !cfgpath.DirExists() ) if( !cfgpath.DirExists() )
{ {
std::ostringstream ostr;
wxString errmsg = _( "failed to create 3D configuration directory" ); wxString errmsg = _( "failed to create 3D configuration directory" );
std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
std::cerr << " * " << errmsg.ToUTF8() << "\n"; ostr << " * " << errmsg.ToUTF8();
wxLogTrace( MASK_3D_CACHE, "%s\n", ostr.str().c_str() );
return wxT( "" ); return wxT( "" );
} }
@ -696,8 +741,12 @@ S3DMODEL* S3D_CACHE::GetModel( const wxString& aModelFileName )
if( !cp ) if( !cp )
{ {
#ifdef DEBUG #ifdef DEBUG
std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; do {
std::cerr << " * [BUG] model loaded with no associated S3D_CACHE_ENTRY\n"; 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 #endif
return NULL; return NULL;

View File

@ -22,11 +22,13 @@
*/ */
#include <iostream> #include <iostream>
#include <sstream>
#include <cstdlib> #include <cstdlib>
#include <cstring> #include <cstring>
#include <fstream> #include <fstream>
#include <sstream> #include <sstream>
#include <wx/filename.h> #include <wx/filename.h>
#include <wx/log.h>
#include <wx/utils.h> #include <wx/utils.h>
#include <wx/msgdlg.h> #include <wx/msgdlg.h>
@ -41,6 +43,8 @@
#define ERRFLG_RELPATH (2) #define ERRFLG_RELPATH (2)
#define ERRFLG_ENVPATH (4) #define ERRFLG_ENVPATH (4)
#define MASK_3D_RESOLVER "3D_RESOLVER"
static bool getHollerith( const std::string& aString, size_t& aIndex, wxString& aResult ); 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 #ifdef DEBUG
std::cout << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; do {
std::cout << " * [INFO] changed project dir to "; std::ostringstream ostr;
std::cout << m_Paths.front().m_pathexp.ToUTF8() << "\n"; 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 #endif
return true; return true;
@ -165,13 +173,13 @@ bool S3D_FILENAME_RESOLVER::createPathList( void )
return false; return false;
#ifdef DEBUG #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 sPL = m_Paths.begin();
std::list< S3D_ALIAS >::const_iterator ePL = m_Paths.end(); std::list< S3D_ALIAS >::const_iterator ePL = m_Paths.end();
while( sPL != ePL ) while( sPL != ePL )
{ {
std::cout << " + '" << (*sPL).m_pathexp.ToUTF8() << "'\n"; wxLogTrace( MASK_3D_RESOLVER, " + '%s'\n", (*sPL).m_pathexp.ToUTF8() );
++sPL; ++sPL;
} }
#endif #endif
@ -518,9 +526,11 @@ bool S3D_FILENAME_RESOLVER::readPathList( void )
{ {
if( m_ConfigDir.empty() ) 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" ); 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; return false;
} }
@ -535,10 +545,12 @@ bool S3D_FILENAME_RESOLVER::readPathList( void )
if( !wxFileName::Exists( cfgname ) ) if( !wxFileName::Exists( cfgname ) )
{ {
std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
wxString errmsg = _( "no 3D configuration file" ); wxString errmsg = _( "no 3D configuration file" );
std::cerr << " * " << errmsg.ToUTF8() << " '"; ostr << " * " << errmsg.ToUTF8() << " '";
std::cerr << cfgname.ToUTF8() << "'\n"; ostr << cfgname.ToUTF8() << "'";
wxLogTrace( MASK_3D_RESOLVER, "%s\n", ostr.str().c_str() );
return false; return false;
} }
@ -546,9 +558,11 @@ bool S3D_FILENAME_RESOLVER::readPathList( void )
if( !cfgFile.is_open() ) 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" ); 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; return false;
} }
@ -618,9 +632,11 @@ bool S3D_FILENAME_RESOLVER::writePathList( void )
{ {
if( m_ConfigDir.empty() ) 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" ); 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" ) ); wxMessageBox( errmsg, _( "Write 3D search path list" ) );
return false; return false;
@ -660,9 +676,11 @@ bool S3D_FILENAME_RESOLVER::writePathList( void )
if( !cfgFile.is_open() ) 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 " ); 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" ), wxMessageBox( _( "Could not open configuration file" ),
_( "Write 3D search path list" ) ); _( "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() ) 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" ); 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; return false;
} }
@ -839,9 +859,11 @@ static bool getHollerith( const std::string& aString, size_t& aIndex, wxString&
if( std::string::npos == i2 ) 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" ); 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; return false;
} }
@ -850,9 +872,11 @@ static bool getHollerith( const std::string& aString, size_t& aIndex, wxString&
if( i2 >= aString.size() ) 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)" ); 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; return false;
} }
@ -864,9 +888,11 @@ static bool getHollerith( const std::string& aString, size_t& aIndex, wxString&
if( tnum.empty() || aString[i2++] != ':' ) 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" ); 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; return false;
} }
@ -878,9 +904,11 @@ static bool getHollerith( const std::string& aString, size_t& aIndex, wxString&
if( (i2 + nchars) >= aString.size() ) 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)" ); 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; return false;
} }
@ -893,9 +921,11 @@ static bool getHollerith( const std::string& aString, size_t& aIndex, wxString&
if( aString[i2] != '"' ) 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" ); 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; return false;
} }

View File

@ -24,16 +24,13 @@
#include <utility> #include <utility>
#include <iostream> #include <iostream>
#include <unistd.h>
#include <sys/types.h>
#include <string>
#include <sstream> #include <sstream>
#include <wx/log.h>
#include <wx/string.h> #include <wx/string.h>
#include <wx/dir.h> #include <wx/dir.h>
#include <wx/config.h> #include <wx/config.h>
#include <wx/stdpaths.h> #include <wx/stdpaths.h>
#include <wx/filename.h>
#include <wx/dynlib.h> #include <wx/dynlib.h>
#include "3d_plugin_manager.h" #include "3d_plugin_manager.h"
@ -41,6 +38,9 @@
#include "3d_cache/sg/scenegraph.h" #include "3d_cache/sg/scenegraph.h"
#include "plugins/ldr/3d/pluginldr3D.h" #include "plugins/ldr/3d/pluginldr3D.h"
#define MASK_3D_PLUGINMGR "3D_PLUGIN_MANAGER"
S3D_PLUGIN_MANAGER::S3D_PLUGIN_MANAGER() S3D_PLUGIN_MANAGER::S3D_PLUGIN_MANAGER()
{ {
// create the initial file filter list entry // 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 sM = m_ExtMap.begin();
std::multimap< const wxString, KICAD_PLUGIN_LDR_3D* >::const_iterator eM = m_ExtMap.end(); 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 ) while( sM != eM )
{ {
std::cout << " + '" << sM->first.ToUTF8() << "' ["; wxLogTrace( MASK_3D_PLUGINMGR, " + '%s' [%s]\n", sM->first.ToUTF8(),
std::cout << sM->second->GetKicadPluginName() << "]\n"; sM->second->GetKicadPluginName() );
++sM; ++sM;
} }
} }
else 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 /// list of file filters
std::list< wxString >::const_iterator sFF = m_FileFilters.begin(); std::list< wxString >::const_iterator sFF = m_FileFilters.begin();
std::list< wxString >::const_iterator eFF = m_FileFilters.end(); std::list< wxString >::const_iterator eFF = m_FileFilters.end();
std::cout << "* File filters:\n"; wxLogTrace( MASK_3D_PLUGINMGR, " * File filters:\n" );
while( sFF != eFF ) while( sFF != eFF )
{ {
std::cout << " + '" << *sFF << "'\n"; wxLogTrace( MASK_3D_PLUGINMGR, " + '%s'\n", (*sFF).ToUTF8() );
++sFF; ++sFF;
} }
} }
else else
{ {
std::cout << "* No file filters available\n"; wxLogTrace( MASK_3D_PLUGINMGR, " * No file filters available\n" );
} }
#endif // DEBUG #endif // DEBUG
@ -168,8 +168,12 @@ void S3D_PLUGIN_MANAGER::loadPlugins( void )
while( sPL != ePL ) while( sPL != ePL )
{ {
#ifdef DEBUG #ifdef DEBUG
std::cout << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << ":\n"; do {
std::cout << "* [DEBUG] searching path: '" << (*sPL).ToUTF8() << "'\n"; 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 #endif
listPlugins( *sPL, pluginlist ); listPlugins( *sPL, pluginlist );
++sPL; ++sPL;
@ -188,15 +192,23 @@ void S3D_PLUGIN_MANAGER::loadPlugins( void )
if( pp->Open( sPL->ToUTF8() ) ) if( pp->Open( sPL->ToUTF8() ) )
{ {
#ifdef DEBUG #ifdef DEBUG
std::cout << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << ":\n"; do {
std::cout << "* [DEBUG] adding plugin\n"; 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 #endif
m_Plugins.push_back( pp ); m_Plugins.push_back( pp );
int nf = pp->GetNFilters(); int nf = pp->GetNFilters();
#ifdef DEBUG #ifdef DEBUG
std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; do {
std::cerr << " * [INFO] adding " << nf << " filters\n"; 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 #endif
for( int i = 0; i < nf; ++i ) for( int i = 0; i < nf; ++i )
@ -215,8 +227,12 @@ void S3D_PLUGIN_MANAGER::loadPlugins( void )
else else
{ {
#ifdef DEBUG #ifdef DEBUG
std::cout << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << ":\n"; do {
std::cout << "* [DEBUG] deleting plugin\n"; 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 #endif
delete pp; delete pp;
} }
@ -225,8 +241,12 @@ void S3D_PLUGIN_MANAGER::loadPlugins( void )
} }
#ifdef DEBUG #ifdef DEBUG
std::cout << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << ":\n"; do {
std::cout << "* [DEBUG] plugins loaded\n"; 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 #endif
return; return;
@ -296,7 +316,8 @@ void S3D_PLUGIN_MANAGER::checkPluginName( const wxString& aPath,
aPluginList.push_back( wxpath ); aPluginList.push_back( wxpath );
#ifdef DEBUG #ifdef DEBUG
std::cerr << " * [INFO] found 3D plugin '" << wxpath.ToUTF8() << "'\n"; wxLogTrace( MASK_3D_PLUGINMGR, " * [INFO] found 3D plugin '%s'\n",
wxpath.ToUTF8() );
#endif #endif
return; return;
@ -311,7 +332,8 @@ void S3D_PLUGIN_MANAGER::checkPluginPath( const wxString& aPath,
return; return;
#ifdef DEBUG #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 #endif
wxFileName path( wxFileName::DirName( aPath ) ); wxFileName path( wxFileName::DirName( aPath ) );
@ -370,8 +392,12 @@ void S3D_PLUGIN_MANAGER::addExtensionMap( KICAD_PLUGIN_LDR_3D* aPlugin )
int nExt = aPlugin->GetNExtensions(); int nExt = aPlugin->GetNExtensions();
#ifdef DEBUG #ifdef DEBUG
std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; do {
std::cerr << " * [INFO] adding " << nExt << " extensions\n"; 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 #endif
for( int i = 0; i < nExt; ++i ) 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(); std::list< KICAD_PLUGIN_LDR_3D* >::iterator eP = m_Plugins.end();
#ifdef DEBUG #ifdef DEBUG
std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; do {
std::cerr << " * [INFO] closing " << m_Plugins.size() << " plugins\n"; 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 #endif
while( sP != eP ) while( sP != eP )