python的spinner记录器
spinlog的Python项目详细描述
spinlog.py
Spinner Logger for Python
安装
只要pip install spinlog
你就可以使用它。
用法
spinlog构建在提供不同api的halo之上 与微调器交互。
基本用法
fromspinlogimportSpinnerfromtimeimportsleepprint("About to launch Spinner")withSpinner.get("I'm spinning around")ass:sleep(2)s.info("Here is an info message while spinning around")# you can use s.warn, s.error, or s.debugsleep(2)print("Spinning Over")
高级使用
spinlog的构建方式使您可以禁用旋转动画 并用适当的日志记录替换它,而不必更改代码库。
这是通过创建一个spinner实例来完成的,该实例可能配置了两个logger,
要与微调器一起运行的concommitant_logger
(例如,用于记录到文件)。
以及alternative_logger
来替换微调器动画和日志。
完整的示例可以在the examples folder中找到 这里有一个例外:
# imports and logger definitionsshould_spin="--no-spin"notinsys.argv# Configure spinnerspinner=Spinner(spinner="triangle",is_spinning=should_spin,alternative_logger=stream_logger,concommitant_logger=file_logger)# Use spinnerwithspinner("Operation in progress")ass:sleep(2)s.info("Checkpoint reached")sleep(2)
许可证
麻省理工学院AdrieanKhisbe