def test_bound_logger(caplog):
slogging.configure(config_string=':trace')
real_log = slogging.getLogger()
bound_log_1 = real_log.bind(key1="value1")
with caplog.at_level(slogging.TRACE):
bound_log_1.info("test1")
assert "test1" in caplog.text
assert 'key1=value1' in caplog.text
bound_log_2 = bound_log_1.bind(key2="value2")
with caplog.at_level(slogging.TRACE):
bound_log_2.info("test2")
assert "test2" in caplog.text
assert 'key1=value1' in caplog.text
assert 'key2=value2' in caplog.text
评论列表
文章目录