'logs <sid> [-l count] [-w]
Show the most recent [count] logs for a given scan ID, <sid>.
If no count is supplied, all logs are given.
If -w is supplied, logs will be streamed to the console until
Ctrl-C is entered.'

def do_logs(self, line):

    c = self.myparseline(line)
    if (len(c[0]) < 1):
        self.edprint('Invalid    syntax.')
        return
    sid = c[0][0]
    limit = None
    if ('-l' in c[0]):
        limit = c[0][(c[0].index('-l') + 1)]
    if ('-w' not in c[0]):
        d = self.request((self.ownopts['cli.server_baseurl'] + '/scanlog'), post={'id': sid, 'limit': limit})
        if (not d):
            return
        j = json.loads(d)
        if (len(j) < 1):
            self.dprint('No    results.')
            return
        self.send_output(d, line, titles={'0': 'Generated', '1': 'Type', '2': 'Source', '3': 'Message'})
        return
    else:
        d = self.request((self.ownopts['cli.server_baseurl'] + '/scanlog'), post={'id': sid, 'limit': '1'})
        if (not d):
            return
        j = json.loads(d)
        if (len(j) < 1):
            self.dprint('No    logs    (yet?).')
            return
        else:
            rowid = j[0][4]
        try:
            if (not limit):
                limit = 10
            d = self.request((self.ownopts['cli.server_baseurl'] + '/scanlog'), post={'id': sid, 'reverse': '1', 'rowId': (rowid - int(limit))})
            if (not d):
                return
            j = json.loads(d)
            for r in j:
                if (r[2] == 'ERROR'):
                    self.edprint(((r[1] + ':    ') + r[3]))
                else:
                    self.dprint(((r[1] + ':    ') + r[3]))
            while True:
                d = self.request((self.ownopts['cli.server_baseurl'] + '/scanlog'), post={'id': sid, 'reverse': '1', 'rowId': rowid})
                if (not d):
                    return
                j = json.loads(d)
                for r in j:
                    if (r[2] == 'ERROR'):
                        self.edprint(((r[1] + ':    ') + r[3]))
                    else:
                        self.dprint(((r[1] + ':    ') + r[3]))
                    rowid = str(r[4])
                time.sleep(0.5)
        except KeyboardInterrupt:
            return
