From: prascle Date: Sat, 7 Feb 2004 16:09:12 +0000 (+0000) Subject: PR: Garbage text in local trace or crash, in optimized mode : KERNEL 5125 X-Git-Tag: V1_4_0~13 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=124a9f72e22da437850980a199ec5474e66555db;p=modules%2Fkernel.git PR: Garbage text in local trace or crash, in optimized mode : KERNEL 5125 --- diff --git a/src/SALOMELocalTrace/SALOME_Log.cxx b/src/SALOMELocalTrace/SALOME_Log.cxx index 476d987f4..ef4f85ded 100644 --- a/src/SALOMELocalTrace/SALOME_Log.cxx +++ b/src/SALOMELocalTrace/SALOME_Log.cxx @@ -33,7 +33,12 @@ using namespace std; #include "SALOME_Log.hxx" -SALOME_Log::SALOME_Log() +SALOME_Log* SALOME_Log::_singleton = 0; + +// log line size: if too short, log line is truncated, without crash... +char SALOME_LogStr[1024]; + +SALOME_Log::SALOME_Log(): ostrstream(SALOME_LogStr,sizeof(SALOME_LogStr)) { } @@ -41,17 +46,16 @@ SALOME_Log::~SALOME_Log() { } -SALOME_Log& SALOME_Log::Instance() +SALOME_Log* SALOME_Log::Instance() { - static SALOME_Log instance; - return instance; + if (_singleton == 0) _singleton = new SALOME_Log(); + return _singleton; } void SALOME_Log::putMessage(std::ostream& msg) { cout << std::flush; cerr <freeze(false); - seekp(0); } + diff --git a/src/SALOMELocalTrace/SALOME_Log.hxx b/src/SALOMELocalTrace/SALOME_Log.hxx index 043d1e1c2..af4f565da 100644 --- a/src/SALOMELocalTrace/SALOME_Log.hxx +++ b/src/SALOMELocalTrace/SALOME_Log.hxx @@ -69,17 +69,17 @@ using namespace std; class SALOME_Log : public ostrstream { -public: - virtual ~SALOME_Log(); - static Standard_EXPORT SALOME_Log& Instance(); - Standard_EXPORT void putMessage(std::ostream& msg); - +private: + static SALOME_Log* _singleton; protected: //disable creation of instances: force use static SALOME_Log& Instance() SALOME_Log(); +public: + virtual ~SALOME_Log(); + static Standard_EXPORT SALOME_Log* Instance(); + Standard_EXPORT void putMessage(std::ostream& msg); }; - #define SLog SALOME_Log::Instance() #endif diff --git a/src/SALOMELogger/SALOME_LoggerClient.cxx b/src/SALOMELogger/SALOME_LoggerClient.cxx index 70f765038..6abf46da9 100644 --- a/src/SALOMELogger/SALOME_LoggerClient.cxx +++ b/src/SALOMELogger/SALOME_LoggerClient.cxx @@ -36,15 +36,14 @@ using namespace std; #include #include CORBA_CLIENT_HEADER(Logger) -// class SALOME_LoggerClient : public SALOME_Log -// { -// protected: -// SALOME_Logger::Logger_var m_pInterfaceLogger; // object reference on Logger server -// }; - SALOME_Logger::Logger_ptr m_pInterfaceLogger; // object reference on Logger server -SALOME_Log::SALOME_Log() +SALOME_Log* SALOME_Log::_singleton = 0; + +// log line size: if too short, log line is truncated, without crash... +char SALOME_LogStr[1024]; + +SALOME_Log::SALOME_Log(): ostrstream(SALOME_LogStr,sizeof(SALOME_LogStr)) { cout << "SALOME_LoggerClient: constructor" << endl; //get reference on object reference from NS @@ -131,10 +130,10 @@ SALOME_Log::~SALOME_Log() { } -SALOME_Log& SALOME_Log::Instance() +SALOME_Log* SALOME_Log::Instance() { - static SALOME_Log instance; - return instance; + if (_singleton == 0) _singleton = new SALOME_Log(); + return _singleton; } void SALOME_Log::putMessage(std::ostream& msg) @@ -143,8 +142,8 @@ void SALOME_Log::putMessage(std::ostream& msg) char* adt = str(); CORBA::String_var LogMsg = CORBA::string_dup(adt); - rdbuf()->freeze(false); - seekp(0); +// rdbuf()->freeze(false); +// seekp(0); if (CORBA::is_nil(m_pInterfaceLogger)) cout << LogMsg << std::flush; diff --git a/src/Utils/utilities.h b/src/Utils/utilities.h index 015e84e58..f396321e8 100644 --- a/src/Utils/utilities.h +++ b/src/Utils/utilities.h @@ -37,8 +37,8 @@ /* --- INFOS is always defined (without _DEBUG_): to be used for warnings, with release version --- */ -#define INFOS(msg) {SLog.putMessage(SLog<<__FILE__<<" ["<<__LINE__<<"] : "<putMessage(*SLog<<__FILE__<<" ["<<__LINE__<<"] : "<putMessage(*SLog<<"---PYSCRIPT--- "<putMessage(\ + *SLog<<__FILE__<<" ["<< __LINE__<<"] : "\ << "COMPILED with " << COMPILER \ << ", " << __DATE__ \ << " at " << __TIME__ <