好的,所以在我的 environment.py 文件中,我可以通过以下方式记录内容:
logging.basicConfig(level=logging.DEBUG, filename="example.log")
def before_feature(context, feature):
logging.info("test logging")
但是当我在步骤文件中时,我无法执行日志记录:
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
@given("we have a step")
def step_impl(context):
logger.debug("Test logging 2")
步骤内的日志消息不显示。我正在使用 python 行为模块。有任何想法吗?
我尝试在运行行为时启用和禁用日志捕获,但这没有区别。