有很多小伙伴需要根据运行日志进行排查错误,我们可视化指令打印日志是可以显示对应流程名称、行号的,但是呢print方法不显示,这时候就要进行改写print了

import xbot_visual
import inspect
import os
def print(*args):
stack = inspect.stack()
caller_frame_record = stack[1]
caller_file_path = caller_frame_record.filename
file_name, file_extension = os.path.splitext(os.path.basename(caller_file_path))
caller_line_number = caller_frame_record.lineno
text = ' '.join(str(arg) for arg in args)
xbot_visual.programing.log(type="info", text=text, _block=(file_name, caller_line_number, "打印日志"))
