def on_read(self, data: bytes, address: Tuple[(str, int)]):
    metrics['syslog_msg_in'] += 1
    cfg = self.service.lookup_config(address[0])
    if (not cfg):
        return
    data = smart_text(data, errors='ignore')
    priority = 0
    if data.startswith('<'):
        idx = data.find('>')
        if (idx == (- 1)):
            return
        try:
            priority = int(data[1:idx])
        except ValueError:
            pass
        data = data[(idx + 1):].strip()
    ts = int(time.time())
    self.service.register_message(cfg, ts, data, facility=(priority >> 3), severity=(priority & 7))
def on_read(self, data: bytes, address: Tuple[(str, int)]):
    metrics['syslog_msg_in'] += 1
    cfg = self.service.lookup_config(address[0])
    if (not cfg):
        return
    data = smart_text(data, errors='ignore')
    priority = 0
    if data.startswith('<'):
        idx = data.find('>')
        if (idx == (- 1)):
            return
        try:
            priority = int(data[1:idx])
        except ValueError:
            pass
        data = data[(idx + 1):].strip()
    ts = int(time.time())
    self.service.register_message(cfg, ts, data, facility=(priority >> 3), severity=(priority & 7))