log.py 687 B

1234567891011121314151617181920212223242526
  1. from progress.bar import IncrementalBar
  2. def to_color(s, c):
  3. return f'\x1b[{c}m{s}\x1b[0m' if use_color else s
  4. def out_line(s='', color=37, indent=0, thread_name=None):
  5. t = ''
  6. if thread_name is not None and show_threads:
  7. t = to_color(f'<{thread_name}> ', thread_color)
  8. print(t + ' ' * indent + to_color(s, color))
  9. def out(s='', color=37, indent=0, thread_name=None):
  10. for line in s.split('\n'):
  11. out_line(line, color, indent, thread_name)
  12. use_color = True
  13. show_threads = True
  14. thread_color = 34
  15. # stuff for progress bars
  16. export_task_count = 0
  17. filtered_export_task_count = 0
  18. bar = IncrementalBar()
  19. bar.suffix = "%(index)d / %(max)d (%(elapsed_td)s)"