Пример #1
0
def add_logentries_handler(log):
  """Function to add the logentries handler to swaglog.
  This can be used to send logs when logmessaged is not running."""
  from selfdrive.logmessaged import get_le_handler
  handler = get_le_handler()
  handler.setFormatter(SwagFormatter(log))
  log.addHandler(handler)
Пример #2
0
        if os.getpid() != self.pid:
            self.connect()

        msg = self.format(record).rstrip('\n')
        # print("SEND".format(repr(msg)))
        try:
            s = chr(record.levelno) + msg
            self.sock.send(s.encode('utf8'), zmq.NOBLOCK)
        except zmq.error.Again:
            # drop :/
            pass


def add_file_handler(log):
    """
  Function to add the file log handler to swaglog.
  This can be used to store logs when logmessaged is not running.
  """
    handler = get_file_handler()
    handler.setFormatter(SwagLogFileFormatter(log))
    log.addHandler(handler)


cloudlog = log = SwagLogger()
log.setLevel(logging.DEBUG)

outhandler = logging.StreamHandler()
log.addHandler(outhandler)
# logs are sent through IPC before writing to disk to prevent disk I/O blocking
log.addHandler(UnixDomainSocketHandler(SwagFormatter(log)))
Пример #3
0
        self.pid = os.getpid()

    def emit(self, record):
        if os.getpid() != self.pid:
            self.connect()

        msg = self.format(record).rstrip('\n')
        # print("SEND".format(repr(msg)))
        try:
            s = chr(record.levelno) + msg
            self.sock.send(s.encode('utf8'), zmq.NOBLOCK)
        except zmq.error.Again:
            # drop :/
            pass


def add_logentries_handler(log):
    """Function to add the logentries handler to swaglog.
  This can be used to send logs when logmessaged is not running."""
    handler = get_le_handler()
    handler.setFormatter(SwagFormatter(log))
    log.addHandler(handler)


cloudlog = log = SwagLogger()
log.setLevel(logging.DEBUG)

outhandler = logging.StreamHandler()
log.addHandler(outhandler)
log.addHandler(LogMessageHandler(SwagFormatter(log)))