1 # Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License.
11 # This library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Lesser General Public License for more details.
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this library; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 # SALOME Logger : CORBA server managing trace output
23 # File : SALOME_Trace.py
28 from omniORB import CORBA
34 if (os.environ.has_key("SALOME_trace")):
35 if (os.environ["SALOME_trace"] == "with_logger"):
40 self.m_pInterfaceLogger = None
44 while steps > 0 and ok == 0:
47 orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
48 theObj = orb.resolve_initial_references("NameService")
49 inc = theObj._narrow(CosNaming.NamingContext)
50 name = [CosNaming.NameComponent("Logger","")]
51 obj = inc.resolve(name);
53 self.m_pInterfaceLogger = obj._narrow(SALOME_Logger.Logger)
55 if not self.m_pInterfaceLogger is None:
58 except CosNaming.NamingContext.NotFound, e :
59 if steps == 1: print "Caught exception: Naming Service can't found Logger"
60 except (CORBA.TRANSIENT,CORBA.OBJECT_NOT_EXIST,CORBA.COMM_FAILURE):
61 if steps == 1: print "Caught CORBA::SystemException CommFailure"
62 except CORBA.SystemException, e:
63 if steps == 1: print "Caught CORBA::SystemException."
64 except CORBA.Exception, e:
65 if steps == 1: print "Caught CORBA::Exception."
67 if steps == 1: print "Caught unknown exception."
73 def putMessage ( self, LogMsg ) :
75 if (CORBA.is_nil(self.m_pInterfaceLogger)):
78 self.m_pInterfaceLogger.putMessage (LogMsg)