#include <SALOMEconfig.h>
#include CORBA_CLIENT_HEADER(Logger)
-SALOME_Logger::Logger_ptr m_pInterfaceLogger; // object reference on Logger server
+#include "utilities.h"
-SALOME_Log* SALOME_Log::_singleton = 0;
+// class SALOME_LoggerClient : public SALOME_Log
+// {
+// protected:
+// SALOME_Logger::Logger_var m_pInterfaceLogger; // object reference on Logger server
+// };
-// log line size: if too short, log line is truncated, without crash...
-char SALOME_LogStr[1024];
+SALOME_Logger::Logger_ptr m_pInterfaceLogger; // object reference on Logger server
-SALOME_Log::SALOME_Log(): ostrstream(SALOME_LogStr,sizeof(SALOME_LogStr))
+SALOME_Log::SALOME_Log()
{
- cout << "SALOME_LoggerClient: constructor" << endl;
+ MESSAGE("SALOME_LoggerClient: constructor");
//get reference on object reference from NS
//and initialize m_pInterfaceLogger
}
catch( CORBA::COMM_FAILURE& )
{
- cout<<"SALOME_LoggerClient: CORBA::COMM_FAILURE: Unable to contact the Naming Service"<<endl;
+ MESSAGE("SALOME_LoggerClient: CORBA::COMM_FAILURE: Unable to contact the Naming Service");
}
catch(...)
{
- cout<<"SALOME_LoggerClient: Unknown exception dealing with Naming Service"<<endl;
+ MESSAGE("SALOME_LoggerClient: Unknown exception dealing with Naming Service");
}
if(!CORBA::is_nil(inc))
obj = inc->resolve(name);
m_pInterfaceLogger = SALOME_Logger::Logger::_narrow(obj);
if (!CORBA::is_nil(m_pInterfaceLogger))
- cout<<"SALOME_LoggerClient: Logger Server was found"<<endl;
+ MESSAGE("SALOME_LoggerClient: Logger Server was found");
break;
}
}
}
catch (const CosNaming::NamingContext::NotFound&)
{
- // cout << "Caught exception: Naming Service can't found Logger";
+ // MESSAGE("Caught exception: Naming Service can't found Logger");
}
catch (CORBA::COMM_FAILURE&)
{
- // cout << "Caught CORBA::SystemException CommFailure.";
+ // MESSAGE("Caught CORBA::SystemException CommFailure.");
}
catch (CORBA::SystemException&)
{
- // cout << "Caught CORBA::SystemException.";
+ // MESSAGE("Caught CORBA::SystemException.");
}
catch (CORBA::Exception&)
{
- // cout << "Caught CORBA::Exception.";
+ // MESSAGE("Caught CORBA::Exception.");
}
catch (...)
{
- // cout << "Caught unknown exception.";
+ // MESSAGE("Caught unknown exception.");
}
//cerr << "-----SALOME_Trace::SALOME_Trace----"<<endl;
}
{
}
-SALOME_Log* SALOME_Log::Instance()
+SALOME_Log& SALOME_Log::Instance()
{
- if (_singleton == 0) _singleton = new SALOME_Log();
- return _singleton;
+ static SALOME_Log instance;
+ return instance;
}
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;