def format_stack_trace(value): stack_trace = [] fmt = ('<span class="path">{0}/</span>' '<span class="file">{1}</span> in <span class="func">{3}</span>' '(<span class="lineno">{2}</span>) <span class="code">{4}</span>') for frame in value: params = map(escape, frame[0].rsplit('/', 1) + list(frame[1:])) stack_trace.append(fmt.format(*params)) return markup('\n'.join(stack_trace))
def format_stack_trace(value): stack_trace = [] fmt = ( '<span class="path">{0}/</span>' '<span class="file">{1}</span> in <span class="func">{3}</span>' '(<span class="lineno">{2}</span>) <span class="code">{4}</span>' ) for frame in value: params = map(escape, frame[0].rsplit('/', 1) + list(frame[1:])) stack_trace.append(fmt.format(*params)) return markup('\n'.join(stack_trace))
class LogView(ModelView): show_popover = True column_list = [ 'message', 'levelname', 'module', 'funcName', 'lineno', 'url', 'created' ] column_center_list = [ 'levelname', 'module', 'funcName', 'lineno', 'created' ] column_filters = ['levelname', 'module', 'funcName', 'lineno', 'created'] column_searchable_list = ['message', 'url', 'user_agent'] column_formatters = dict(message=formatter_popover( lambda m: (m.message, '<pre>%s</pre>' % markup(m.exc or ''))), ) html = """<style>.popover {max-width: 800px;}</style>"""
def embolden_file(path): head, tail = os.path.split(escape(path)) return markup(os.sep.join([head, '<strong>{0}</strong>'.format(tail)]))