'Returns the log
Returns [{"response":
{"msg": "Hey",
"result": "success"},
"data": [{"time": "29-sept.2015",
"thread: "MainThread",
"msg: "Called x from y",
"loglevel": "DEBUG"'

def _getLogs(self, sort='', search='', order='desc', regex='', **kwargs):

    logfile = os.path.join(plexpy.CONFIG.LOG_DIR, logger.FILENAME)
    templog = []
    start = int(kwargs.get('start', 0))
    end = int(kwargs.get('end', 0))
    if regex:
        logger.debug(('Filtering    log    using    regex    %s' % regex))
        reg = re.compile(('u' + regex), flags=re.I)
    for line in open(logfile, 'r').readlines():
        temp_loglevel_and_time = None
        try:
            temp_loglevel_and_time = line.split('-    ')
            loglvl = temp_loglevel_and_time[1].split('    :')[0].strip()
            tl_tread = line.split('    ::    ')
            if (loglvl is None):
                msg = line.replace('\n', '')
            else:
                msg = line.split('    :    ')[1].replace('\n', '')
            thread = tl_tread[1].split('    :    ')[0]
        except IndexError:
            tl = (len(templog) - 1)
            templog[tl]['msg'] += line.replace('\n', '')
            continue
        if ((len(line) > 1) and (temp_loglevel_and_time is not None) and (loglvl in line)):
            d = {'time': temp_loglevel_and_time[0], 'loglevel': loglvl, 'msg': msg.replace('\n', ''), 'thread': thread}
            templog.append(d)
    if (end > 0):
        logger.debug(('Slicing    the    log    from    %s    to    %s' % (start, end)))
        templog = templog[start:end]
    if sort:
        logger.debug(('Sorting    log    based    on    %s' % sort))
        templog = sorted(templog, key=(lambda k: k[sort]))
    if search:
        logger.debug(('Searching    log    values    for    %s' % search))
        tt = [d for d in templog for (k, v) in d.items() if (search.lower() in v.lower())]
        if len(tt):
            templog = tt
    if regex:
        tt = []
        for l in templog:
            stringdict = '    '.join(('{}{}'.format(k, v) for (k, v) in l.items()))
            if reg.search(stringdict):
                tt.append(l)
        if len(tt):
            templog = tt
    if (order == 'desc'):
        templog = templog[::(-1)]
    self.data = templog
    return templog
