X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FLogger%2FSALOME_Logger_Server.cxx;h=05751ac9763718dfcd5384128c48299c7f0fd4f6;hb=a98a09635ad776cf8eb98664e0933760eb9edbe4;hp=3f5cc115295d6fb991a01f92b3c957e81eab6a37;hpb=4655b0b0eb5345da6a86852021014b0cbae2ad30;p=modules%2Fkernel.git diff --git a/src/Logger/SALOME_Logger_Server.cxx b/src/Logger/SALOME_Logger_Server.cxx index 3f5cc1152..05751ac97 100644 --- a/src/Logger/SALOME_Logger_Server.cxx +++ b/src/Logger/SALOME_Logger_Server.cxx @@ -1,17 +1,41 @@ -using namespace std; -//============================================================================= -// File : SALOME_Logger_Server.cxx -// Created : nov 18 10:28:17 2002 -// Author : Vasily Rusyaev -// Project : SALOME/PRO -//============================================================================= - -// SALOME_Logger_Server.cxx: implementation of the SALOME_Logger_Server class. +// Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -////////////////////////////////////////////////////////////////////// +// SALOME Logger : CORBA server managing trace output +// File : SALOME_Logger_Server.cxx +// Author : Vasily Rusyaev +// Module : SALOME +// #include #include "SALOME_Logger_Server.hxx" +#include +#include +#ifndef WIN32 +# include +#endif + +#ifdef WIN32 +#include +#endif omni_mutex Logger::myLock; @@ -27,7 +51,7 @@ Logger::Logger() Logger::Logger(const char *filename) { // m_outputFile.open( filename, ios::out | ios::trunc , filebuf::openprot); - m_outputFile.open( filename, ios::out | ios::trunc); + m_outputFile.open( filename, std::ios::out | std::ios::trunc); if (m_outputFile.is_open()) m_putIntoFile = true; else @@ -44,85 +68,14 @@ void Logger::putMessage(const char* message) { myLock.lock(); if (m_putIntoFile) - m_outputFile << message << flush; + + m_outputFile << message << std::flush; else - cout << message; + std::cout << message; myLock.unlock(); } -int main(int argc, char **argv) +void Logger::ping() { - if (argc > 2) - { - cout << "usage: SALOME_Logger_Server [output_file]" << endl; - exit(1); - } - try - { - //Initialize the ORB - CORBA::ORB_var orb = CORBA::ORB_init(argc,argv) ; - - CORBA::Object_var obj = orb->resolve_initial_references("RootPOA") ; - PortableServer::POA_var poa = PortableServer::POA::_narrow(obj) ; - - // NB. You can activate the POA before or after - // activating objects in that POA. - PortableServer::POAManager_var pman = poa->the_POAManager(); - pman->activate(); - - Logger* myLogger; - if (argc == 1) - myLogger = new Logger(); - else - myLogger = new Logger(argv[1]); - - - // This activates the object in the root POA (by default), and - // returns a reference to it. - SALOME_Logger::Logger_var myLoggerRef = myLogger->_this(); - - //NB. You can't use SALOME_NamingService class because it uses MESSAGE macro - //Otherwise, you will get segmentation fault. - - //Get initial naming context - CORBA::Object_var theObj = orb->resolve_initial_references("NameService"); - //Narrow to NamingContext - CosNaming::NamingContext_var inc = CosNaming::NamingContext::_narrow(theObj); - - CosNaming::Name name; - name.length(1); - name[0].id = CORBA::string_dup("Logger"); - - inc->bind(name,myLoggerRef); - - myLogger->_remove_ref(); - - orb->run() ; - - orb->destroy() ; - } - catch(CORBA::COMM_FAILURE& ex) - { - cerr << "Caught system exception COMM_FAILURE -- unable to contact the " - << "object." << endl; - } - catch(CORBA::SystemException&) - { - cerr << "Caught CORBA::SystemException." << endl; - } - catch(CORBA::Exception&) - { - cerr << "Caught CORBA::Exception." << endl; - } - catch(omniORB::fatalException& fe) - { - cerr << "Caught omniORB::fatalException:" << endl; - cerr << " file: " << fe.file() << endl; - cerr << " line: " << fe.line() << endl; - cerr << " mesg: " << fe.errmsg() << endl; - } - catch(...) - { - cerr << "Caught unknown exception." << endl; - } + //cout<<" Logger::ping() pid "<< getpid()<