def test_bound_logger_isolation(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')
  records = caplog.records
  assert (len(records) == 1)
  assert ('test1' in records[0].msg)
  assert ('key1=value1' in records[0].msg)
 with caplog.at_level(slogging.TRACE):
  real_log.info('test2')
  records = caplog.records
  assert (len(records) == 2)
  assert ('test2' in records[1].msg)
  assert ('key1=value1' not in records[1].msg)

def test_bound_logger_isolation ( 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' ) records = caplog . records assert ( len ( records ) == 1 ) assert ( 'test1' in records [ 0 ] . msg ) assert ( 'key1=value1' in records [ 0 ] . msg ) with caplog . at_level ( slogging . TRACE ) : real_log . info ( 'test2' ) records = caplog . records assert ( len ( records ) == 2 ) assert ( 'test2' in records [ 1 ] . msg ) assert ( 'key1=value1' not in records [ 1 ] . msg )
ensure bound loggers dont "contaminate" their parent .