void SetVerbosityActivated(bool flag);
+bool IsDebugLevel();
+
+bool IsInfoLevel();
+
+bool IsWarningLevel();
+
+bool IsErrorLevel();
+
void WriteInStdout(const std::string& msg);
void WriteInStderr(const std::string& msg);
static constexpr char ERROR_LEVEL_VALUE = 0;
static constexpr char ERROR_LEVEL_VALUE_STR[] = "ERROR";
static constexpr char WARNING_LEVEL_VALUE = 1;
- static constexpr char WARNING_LEVEL_VALUE_STR[] = "wARNING";
+ static constexpr char WARNING_LEVEL_VALUE_STR[] = "WARNING";
static constexpr char INFO_LEVEL_VALUE = 2;
static constexpr char INFO_LEVEL_VALUE_STR[] = "INFO";
static constexpr char DEBUG_LEVEL_VALUE = 7;
{
return FromVerbosityLevelToStr( VerbosityLevel() );
}
+
+ bool IsDebugLevel()
+ {
+ return VerbosityLevel() >= VerbosityLevelType::debug_level;
+ }
+
+ bool IsInfoLevel()
+ {
+ return VerbosityLevel() >= VerbosityLevelType::info_level;
+ }
+
+ bool IsWarningLevel()
+ {
+ return VerbosityLevel() >= VerbosityLevelType::warning_level;
+ }
+
+ bool IsErrorLevel()
+ {
+ return VerbosityLevel() >= VerbosityLevelType::error_level;
+ }
}
void BASICS_EXPORT SetVerbosityLevel(VerbosityLevelType level);
void BASICS_EXPORT SetVerbosityLevelStr(const std::string& level);
+ bool BASICS_EXPORT IsDebugLevel();
+ bool BASICS_EXPORT IsInfoLevel();
+ bool BASICS_EXPORT IsWarningLevel();
+ bool BASICS_EXPORT IsErrorLevel();
VerbosityLevelType BASICS_EXPORT VerbosityLevel();
std::string BASICS_EXPORT VerbosityLevelStr();
}
std::string hostname = Kernel_Utils::GetHostname();
#ifndef WIN32
- MESSAGE(hostname << " " << getpid() <<
- " Engines_Container_i starting argc " <<
- _argc << " Thread " << pthread_self() ) ;
+ INFO_MESSAGE("Starting Container servant instance on Hostname :" << hostname << " with PID : " << getpid() ) ;
#else
MESSAGE(hostname << " " << _getpid() <<
" Engines_Container_i starting argc " << _argc<< " Thread " << pthread_self().p ) ;
#endif
-
- int i = 0 ;
- while ( _argv[ i ] )
- {
- MESSAGE(" argv" << i << " " << _argv[ i ]) ;
- i++ ;
- }
-
- if ( argc < 2 )
- {
- INFOS("SALOME_Container usage : SALOME_Container ServerName");
- ASSERT(0) ;
- }
- SCRUTE(argv[1]);
_isSupervContainer = false;
_orb = CORBA::ORB::_duplicate(orb) ;
CORBA::String_var sior = _orb->object_to_string(pCont);
std::ostringstream myCommand;
- myCommand << "pyCont = SALOME_Container.SALOME_Container_i('" << _containerName << "','" << sior << "','" << DFT_TIME_INTERVAL_BTW_MEASURE << "')\n";
- SCRUTE(myCommand.str());
+ myCommand << "pyCont = SALOME_Container.SALOME_Container_i('" << _containerName << "','" << sior << "'," << DFT_TIME_INTERVAL_BTW_MEASURE << ")\n";
+ INFO_MESSAGE("Python command executed : " << myCommand.str());
//[RNV]: Comment the PyEval_AcquireLock() and PyEval_ReleaseLock() because this
//approach leads to the deadlock of the main thread of the application on Windows platform
//PyEval_ReleaseLock();
}
{// register to NS after python initialization to be sure that client invoke after py constructor execution
- SCRUTE(_containerName);
_NS->Register(pCont, _containerName.c_str());
- MESSAGE("Engines_Container_i::Engines_Container_i : Container name " << _containerName);
+ DEBUG_MESSAGE("Container registred in NS as : " << _containerName);
}
fileTransfer_i* aFileTransfer = new fileTransfer_i();
CORBA::Object_var obref=aFileTransfer->_this();
#-------------------------------------------------------------------------
def __init__(self ,containerName, containerIORStr, dftTimeIntervalInMs):
- MESSAGE( "SALOME_Container_i::__init__" )
+ # Warning this part of code is called at the very first step of container launching
+ # so logging is not instanciate. So use verbose method to discrimine if a message should be printed or not
try:
argv = sys.argv
except AttributeError :
self._timeIntervalInMs = dftTimeIntervalInMs
self._logm = None
self._log = None
- # let verbose here because SALOME_Container_i is instanciated before the container process verbosity mecanism is initialized
- if verbose(): print("SALOME_Container.SALOME_Container_i : _containerName ",self._containerName)
self._container = self._orb.string_to_object(containerIORStr)
@property
#-------------------------------------------------------------------------
def import_component(self, componentName):
- MESSAGE( "SALOME_Container_i::import_component" )
ret=""
try:
logging.debug("try import ",componentName)
#-------------------------------------------------------------------------
def create_component_instance(self, componentName, instanceName):
- MESSAGE( "SALOME_Container_i::create_component_instance" )
comp_iors=""
ret=""
try:
instanceName,
componentName)
- MESSAGE( "SALOME_Container_i::create_component_instance : OK")
comp_o = comp_i._this()
comp_iors = self._orb.object_to_string(comp_o)
except Exception:
ret=traceback.format_exc(10)
traceback.print_exc()
- MESSAGE( "SALOME_Container_i::create_component_instance : NOT OK")
return comp_iors, ret
SALOME_ContainerManager::SALOME_ContainerManager(CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_NamingService_Abstract *ns)
: _nbprocUsed(1),_delta_time_ns_lookup_in_ms(DFT_DELTA_TIME_NS_LOOKUP_IN_MS),_delta_time_measure_in_ms(Abstract_Engines_Container_i::DFT_TIME_INTERVAL_BTW_MEASURE)
{
- MESSAGE("constructor");
_NS = ns;
_resManager = new SALOME_ResourcesManager_Client(ns);
_time_out_in_second = GetTimeOutToLoaunchServer();
}
#endif
#endif
-
- MESSAGE("constructor end");
}
//=============================================================================
fileTransfer_i::fileTransfer_i()
{
- MESSAGE("fileTransfer_i::fileTransfer_i");
_fileKey=1;
}
fileTransfer_i::~fileTransfer_i()
{
- MESSAGE("fileTransfer_i::~fileTransfer_i");
}
CORBA::Long fileTransfer_i::open(const char* fileName)
{
- MESSAGE(" fileTransfer_i::open " << fileName);
int aKey = _fileKey++;
_ctr=0;
FILE* fp;
void fileTransfer_i::close(CORBA::Long fileId)
{
- MESSAGE("fileTransfer_i::close");
FILE* fp;
if (! (fp = _fileAccess[fileId]) )
{
Engines::fileBlock* fileTransfer_i::getBlock(CORBA::Long fileId)
{
- //MESSAGE("fileTransfer_i::getBlock");
Engines::fileBlock* aBlock = new Engines::fileBlock;
FILE* fp;
*/
CORBA::Long fileTransfer_i::openW(const char* fileName)
{
- MESSAGE(" fileTransfer_i::openW " << fileName);
int aKey = _fileKey++;
_ctr=0;
FILE* fp;
*/
void fileTransfer_i::putBlock(CORBA::Long fileId, const Engines::fileBlock& block)
{
- MESSAGE("fileTransfer_i::putBlock");
FILE* fp;
if (! (fp = _fileAccess[fileId]) )
{
#--------------------------------------------------------------------------
def openStudy(theStudyPath):
- if verbose(): print("openStudy (begin)")
global myStudy, myStudyName
myStudy.Open(theStudyPath)
myStudyName = myStudy._get_Name()
- if verbose(): print("openStudy (end):", theStudyPath, myStudy._get_Name())
#--------------------------------------------------------------------------
global myStudy, myStudyName
global orb, lcc, naming_service, cm
- if verbose(): print("theStudyPath:", theStudyPath)
if not myStudy:
import CORBA
orb = CORBA.ORB_init([''])
# get Study reference
- if verbose(): print("looking for study...")
import KernelDS
myStudy = KernelDS.myStudy()
- if verbose(): print("Study found")
pass
import types
global myStudy, myStudyName
global orb, lcc, naming_service, cm
- if verbose(): print("theStudyPath:", theStudyPath)
if not myStudy:
orb, lcc, naming_service, cm, _, _, _ = salome_kernel.salome_kernel_init()
# get Study reference
- if verbose(): print("looking for study...")
obj = naming_service.Resolve('/Study')
myStudy = obj._narrow(SALOMEDS.Study)
- if verbose(): print("Study found")
pass
import types
void SALOME_ContainerScriptExecPerfLog::start()
{
AutoGIL gstate;
- PyObject *result = PyObject_CallMethod(pyObj(),(char*)"start","",nullptr);
+ AutoPyRef result = PyObject_CallMethod(pyObj(),(char*)"start","",nullptr);
if (PyErr_Occurred())
{
std::string error("can not start");
_sessions.push_back( executionPtr2 );
{
AutoGIL gstate;
- PyObject *result = PyObject_CallMethod(pyObj(),(char*)"addExecution","",nullptr);
+ AutoPyRef result = PyObject_CallMethod(pyObj(),(char*)"addExecution","",nullptr);
if (PyErr_Occurred())
{
std::string error("can not addExecution");
PyErr_Print();
THROW_SALOME_CORBA_EXCEPTION(error.c_str(),SALOME::INTERNAL_ERROR);
}
- execution->setPyObj( result );
+ execution->setPyObj( result.retn() );//ownership of result is transfered to execution
}
execution->start();
return executionPtr2._retn();
_typeMap(typeMap),_typeList(typeList)
{
- BEGIN_OF("SALOME_ModuleCatalog_Handler");
-
// XML Tags initialisation
// Used in the function endElement
test_path_prefix_name = "path-prefix-name";
test_component_list = "component-list";
test_component="component";
-
- END_OF("SALOME_ModuleCatalog_Handler");
}
//----------------------------------------------------------------------
//----------------------------------------------------------------------
SALOME_ModuleCatalog_Handler::~SALOME_ModuleCatalog_Handler()
{
- BEGIN_OF("~SALOME_ModuleCatalog_Handler()");
- END_OF("~SALOME_ModuleCatalog_Handler()");
}
void SALOME_ModuleCatalog_Handler::ProcessXmlDocument(xmlDocPtr theDoc)
{
- MESSAGE("Begin parse document");
// Empty the private elements
_pathList.resize(0);
_pathPrefix.listOfComputer.resize(0);
{
if ( _typeMap.find(aType.name) == _typeMap.end() )
{
- MESSAGE("Registered basic type: " << aType.name << " " << aType.kind );
_typeMap[aType.name]=aType;
_typeList.push_back(aType);
}
else
- MESSAGE( "Warning: this type (" << aType.name << "," << aType.kind << ") already exists, it will be ignored." );
+ INFO_MESSAGE( "Warning: this type (" << aType.name << "," << aType.kind << ") already exists, it will be ignored." );
}
else
- MESSAGE( "Warning: this type (" << aType.name << "," << aType.kind << ") has incorrect kind, it will be ignored." );
+ INFO_MESSAGE( "Warning: this type (" << aType.name << "," << aType.kind << ") has incorrect kind, it will be ignored." );
}
else if ( !xmlStrcmp(aTypeNode->name, (const xmlChar*)"sequence" ))
{
{
if ( _typeMap.find(aType.name) == _typeMap.end() )
{
- MESSAGE("Registered sequence type: " << aType.name << " " << aType.content );
_typeMap[aType.name]=aType;
_typeList.push_back(aType);
}
else
- MESSAGE( "Warning: this type (" << aType.name << "," << aType.kind << ") already exists, it will be ignored." );
+ INFO_MESSAGE( "Warning: this type (" << aType.name << "," << aType.kind << ") already exists, it will be ignored." );
}
else
{
- MESSAGE( "Warning: this sequence type (" << aType.name << "," << aType.content << ") has unknown content type, it will be ignored." );
+ INFO_MESSAGE( "Warning: this sequence type (" << aType.name << "," << aType.content << ") has unknown content type, it will be ignored." );
}
}
else if ( !xmlStrcmp(aTypeNode->name, (const xmlChar*)"objref" ))
{
if ( _typeMap.find(aType.name) == _typeMap.end() )
{
- MESSAGE("Registered struct type: " << aType.name << " " << aType.id );
_typeMap[aType.name]=aType;
_typeList.push_back(aType);
}
SALOME_ModuleCatalogImpl::SALOME_ModuleCatalogImpl(int argc, char** argv, CORBA::ORB_ptr orb) : _orb(orb)
{
myPrivate = new Private;
- MESSAGE("Catalog creation");
+ DEBUG_MESSAGE("Catalog creation");
/* Init libxml */
xmlInitParser();
// Verification of _general_path_list content
if (!myPrivate->_verify_path_prefix(myPrivate->_general_path_list)) {
- MESSAGE( "Error while parsing the general path list, "
+ WARNING_MESSAGE( "Error while parsing the general path list, "
"different paths are associated to the same computer,"
"the first one will be chosen");
} else {
- MESSAGE("General path list OK");
+ DEBUG_MESSAGE("General path list OK");
}
if (myPrivate->_personal_path != NULL) {
MESSAGE("Personal path list OK");
}
}else
- MESSAGE("No personal catalog indicated or error while "
+ INFO_MESSAGE("No personal catalog indicated or error while "
"opening the personal catalog");
}
}
ParserTypes& typeMap,
TypeList& typeList)
{
- BEGIN_OF("_parse_xml_file");
- SCRUTE(file);
+ DEBUG_MESSAGE("parsing of " << file);
//Local path and module list for the file to parse
ParserPathPrefixes _pathList;
aCurNode = aCurNode->next;
}
-#ifdef _DEBUG_
- for (std::map<std::string, ParserResourcesType>::const_iterator iter = _resources_list.begin();
- iter != _resources_list.end();
- iter++)
+ DEBUG_MESSAGE( "************************************************" );
+ for (std::map<std::string, ParserResourcesType>::const_iterator iter = _resources_list.begin(); iter != _resources_list.end(); iter++)
{
- MESSAGE( "************************************************" );
- MESSAGE( "Resource " << (*iter).first << " found:" );
- MESSAGE( (*iter).second );
- MESSAGE( "************************************************" );
+ DEBUG_MESSAGE( "Resource " << (*iter).first << " found: " << std::endl << (*iter).second);
}
-#endif
+ DEBUG_MESSAGE( "************************************************" );
}
bool
}
catch (const ResourcesException &)
{
- MESSAGE( "Warning, invalid type \"" << (const char*)type << "\" for resource \"" <<
+ INFO_MESSAGE( "Warning, invalid type \"" << (const char*)type << "\" for resource \"" <<
resource.Name << "\", using default value \"" << resource.getResourceTypeStr() <<
"\"" ) ;
}
}
else
{
- MESSAGE( "Warning, no type found for resource \"" << resource.Name <<
+ INFO_MESSAGE( "Warning, no type found for resource \"" << resource.Name <<
"\", using default value \"" << resource.getResourceTypeStr() << "\"");
}
PortableServer::POA_var poa,
SALOME_NamingService_Abstract *ns) : _rm(new ResourcesManager_cpp())
{
- MESSAGE("SALOME_ResourcesManager constructor");
_NS = ns;
_orb = CORBA::ORB::_duplicate(orb) ;
//
Engines::ResourcesManager_var refContMan = Engines::ResourcesManager::_narrow(obj);
if(_NS)
_NS->Register(refContMan,_ResourcesManagerNameInNS);
-
- MESSAGE("SALOME_ResourcesManager constructor end");
}
//=============================================================================
PortableServer::POA_ptr SALOMEDS_Study_i::_default_POA()
{
PortableServer::POA_ptr poa = GetThePOA();
- MESSAGE("SALOMEDS_Study_i::_default_POA: " << poa);
return PortableServer::POA::_duplicate(poa);
}
if( SALOME::VerbosityActivated() )
{
std::cout << std::flush ;
-#ifndef WIN32
- std::cerr << "th. " << myTrace.threadId << " " << myTrace.trace;
-#else
- std::cerr << "th. " << (void*)(&myTrace.threadId)
- << " " << myTrace.trace;
-#endif
+ std::cerr << myTrace.trace;
std::cerr << std::flush ;
}
}
<< " at " << __TIME__ << MESS_END }}
-#define MESSAGE(msg) { if (SALOME::VerbosityActivated()) {MESS_BEGIN("- Trace ") << msg << MESS_END}}
-#define SCRUTE(var) { if (SALOME::VerbosityActivated()) {MESS_BEGIN("- Trace ") << #var << "=" << var <<MESS_END}}
+#define MESSAGE(msg) { if (SALOME::VerbosityActivated()) {MESS_BEGIN("Trace -") << msg << MESS_END}}
+#define SCRUTE(var) { if (SALOME::VerbosityActivated()) {MESS_BEGIN("Trace -") << #var << "=" << var <<MESS_END}}
+#define ERROR_MESSAGE(msg) { if (SALOME::VerbosityActivated() && SALOME::IsErrorLevel()) {MESS_BEGIN("ERROR -") << msg << MESS_END}}
+#define WARNING_MESSAGE(msg) { if (SALOME::VerbosityActivated() && SALOME::IsWarningLevel()) {MESS_BEGIN("WARNING -") << msg << MESS_END}}
+#define INFO_MESSAGE(msg) { if (SALOME::VerbosityActivated() && SALOME::IsInfoLevel()) {MESS_BEGIN("INFO -") << msg << MESS_END}}
+#define DEBUG_MESSAGE(msg) { if (SALOME::VerbosityActivated() && SALOME::IsDebugLevel()) {MESS_BEGIN("DBG -") << msg << MESS_END}}
#define REPERE ("------- ")
#define BEGIN_OF(msg) { if (SALOME::VerbosityActivated()) {MESS_BEGIN(REPERE) << "Begin of: " << msg << MESS_END}}
}
myTraceBuffer->retrieve(myTrace);
- //if (!CORBA::is_nil(_orb))
- if (true)
- {
- if (myTrace.traceType == ABORT_MESS)
- {
- std::stringstream abortMessage("");
-#ifndef WIN32
- abortMessage << "INTERRUPTION from thread "
- << myTrace.threadId << " : " << myTrace.trace;
-#else
- abortMessage << "INTERRUPTION from thread "
- << (void*)&myTrace.threadId
- << " : " << myTrace.trace;
-#endif
- CORBA::String_var LogMsg =
- CORBA::string_dup(abortMessage.str().c_str());
- m_pInterfaceLogger->putMessage(LogMsg);
- exit(1);
- }
- else
- {
- std::stringstream aMessage("");
-#ifndef WIN32
- aMessage << "th. " << myTrace.threadId
-#else
- aMessage << "th. " << (void*)&myTrace.threadId
-#endif
- << " " << myTrace.trace;
- CORBA::String_var LogMsg =
- CORBA::string_dup(aMessage.str().c_str());
- m_pInterfaceLogger->putMessage(LogMsg);
- }
- }
+ {
+ if (myTrace.traceType == ABORT_MESS)
+ {
+ std::ostringstream abortMessage;
+ abortMessage << "INTERRUPTION from thread : " << myTrace.trace;
+ CORBA::String_var LogMsg =
+ CORBA::string_dup(abortMessage.str().c_str());
+ m_pInterfaceLogger->putMessage(LogMsg);
+ exit(1);
+ }
+ else
+ {
+ std::ostringstream aMessage;
+ aMessage << " " << myTrace.trace;
+ CORBA::String_var LogMsg =
+ CORBA::string_dup(aMessage.str().c_str());
+ m_pInterfaceLogger->putMessage(LogMsg);
+ }
+ }
}
pthread_exit(NULL);
return NULL;