Beispiel #1
0
class ExtendedLogger(Logger):
  """ The logger object, for use inside the pilot. It prints messages.
      But can be also used to send messages to the queue
  """

  def __init__(self, name='Pilot', debugFlag=False, pilotOutput='pilot.out', isPilotLoggerOn=False):
    """ c'tor
    If flag PilotLoggerOn is not set, the logger will behave just like
    the original Logger object, that means it will just print logs locally on the screen
    """
    super(ExtendedLogger, self).__init__(name, debugFlag, pilotOutput)
    if isPilotLoggerOn:
      # the import here was suggest F.S cause PilotLogger imports stomp
      # which is not yet in the DIRAC externals
      # so up to now we want to turn it off
      from Pilot.PilotLogger import PilotLogger
      self.pilotLogger = PilotLogger()
    else:
      self.pilotLogger = None
    self.isPilotLoggerOn = isPilotLoggerOn

  def debug(self, msg, header=True, sendPilotLog=False):
    super(ExtendedLogger, self).debug(msg, header)
    if self.isPilotLoggerOn:
      if sendPilotLog:
        self.pilotLogger.sendMessage(msg, status="debug")

  def error(self, msg, header=True, sendPilotLog=False):
    super(ExtendedLogger, self).error(msg, header)
    if self.isPilotLoggerOn:
      if sendPilotLog:
        self.pilotLogger.sendMessage(msg, status="error")

  def warn(self, msg, header=True, sendPilotLog=False):
    super(ExtendedLogger, self).warn(msg, header)
    if self.isPilotLoggerOn:
      if sendPilotLog:
        self.pilotLogger.sendMessage(msg, status="warning")

  def info(self, msg, header=True, sendPilotLog=False):
    super(ExtendedLogger, self).info(msg, header)
    if self.isPilotLoggerOn:
      if sendPilotLog:
        self.pilotLogger.sendMessage(msg, status="info")

  def sendMessage(self, msg, source, phase, status='info', localFile=None, sendPilotLog=False):
    pass
    if self.isPilotLoggerOn:
      if sendPilotLog:
        self.pilotLogger.sendMessage(messageContent=msg,
                                     source=source,
                                     phase=phase,
                                     status=status,
                                     localOutputFile=localFile)
Beispiel #2
0
class ExtendedLogger(Logger):
    """ The logger object, for use inside the pilot. It prints messages.
      But can be also used to send messages to the queue
  """
    def __init__(self,
                 name='Pilot',
                 debugFlag=False,
                 pilotOutput='pilot.out',
                 isPilotLoggerOn=True,
                 setup='DIRAC-Certification'):
        """ c'tor
    If flag PilotLoggerOn is not set, the logger will behave just like
    the original Logger object, that means it will just print logs locally on the screen
    """
        super(ExtendedLogger, self).__init__(name, debugFlag, pilotOutput)
        if isPilotLoggerOn:
            self.pilotLogger = PilotLogger(setup=setup)
        else:
            self.pilotLogger = None
        self.isPilotLoggerOn = isPilotLoggerOn

    def debug(self, msg, header=True, sendPilotLog=False):
        super(ExtendedLogger, self).debug(msg, header)
        if self.isPilotLoggerOn and sendPilotLog:
            self.pilotLogger.sendMessage(msg, status="debug")

    def error(self, msg, header=True, sendPilotLog=False):
        super(ExtendedLogger, self).error(msg, header)
        if self.isPilotLoggerOn and sendPilotLog:
            self.pilotLogger.sendMessage(msg, status="error")

    def warn(self, msg, header=True, sendPilotLog=False):
        super(ExtendedLogger, self).warn(msg, header)
        if self.isPilotLoggerOn and sendPilotLog:
            self.pilotLogger.sendMessage(msg, status="warning")

    def info(self, msg, header=True, sendPilotLog=False):
        super(ExtendedLogger, self).info(msg, header)
        if self.isPilotLoggerOn and sendPilotLog:
            self.pilotLogger.sendMessage(msg, status="info")

    def sendMessage(self,
                    msg,
                    source,
                    phase,
                    status='info',
                    sendPilotLog=True):
        if self.isPilotLoggerOn and sendPilotLog:
            self.pilotLogger.sendMessage(messageContent=msg,
                                         source=source,
                                         phase=phase,
                                         status=status)