'Handle a log message.'

def handle(self, record):

    if (record.name == NAME_STREAM):
        if (not record.msg.startswith('STREAM')):
            return
        if record.msg.endswith('ATTACHED'):
            self.entity.count += 1
        elif record.msg.endswith('RESPONSE    CLOSED'):
            self.entity.count -= 1
    elif (not record.msg.startswith('WS')):
        return
    elif (len(record.args) < 2):
        return
    elif (record.args[1] == 'Connected'):
        self.entity.count += 1
    elif (record.args[1] == 'Closed    connection'):
        self.entity.count -= 1
    self.entity.schedule_update_ha_state()
