#NEWLINE# @ contextmanager #NEWLINE# def capture_log( logger = 'beets' ) : #NEWLINE# #INDENT# capture = LogCapture ( ) #NEWLINE# log = logging . getLogger ( logger ) #NEWLINE# log . addHandler ( capture ) #NEWLINE# try : #NEWLINE# #INDENT# ( yield capture . messages ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# log . removeHandler ( capture )