@WebApp.route('/logs/<build>/')
@auth_required
def log_file(request, build):
    data_dir = request.app.app.data_dir
    filename = os.path.join(data_dir, build, 'log.txt')
    levelno = request.values.get('levelno', default=logging.INFO, type=int)
    thread = request.values.get('thread')
    logger = request.values.get('name')
    def records():
        with open(filename) as f:
            for number, line in enumerate(f):
                if not line.strip():
                    continue
                try:
                    record = json.loads(line)
                except Exception:
                    record = {
                        'parsing_error': traceback.format_exc(),
                        'line_number': number + 1
                    }
                else:
                    if logger and not record['name'].startswith(logger):
                        continue
                    if record['levelno'] < levelno:
                        continue
                    if thread and thread != (record['process_name'] +
                                             '/' + record['thread_name']):
                        continue
                    record['created_time'] = time.gmtime(record['created'])
                    record['created_string'] = time.strftime(
                        '%Y-%m-%d %H:%M:%S',
                        record['created_time']
                    )
                yield record
    return render(request, records(), 'log_file',
                  build=build, records=records(), levelno=levelno)
dataset/ETHPy150Open crosspop/asuka/asuka/web.py/log_file/original