def METHOD_NAME( app, filepath ):
  global shared_filepaths
  global shared_log_indexes
  if filepath not in shared_filepaths.setdefault( app, [] ):
    GetDiagnostics( app, filepath )
    shared_filepaths[ app ].append( filepath )
    WaitUntilCsCompleterIsReady( app, filepath )
  logfiles = []
  response = GetDebugInfo( app, filepath )
  for server in response[ 'completer' ][ 'servers' ]:
    logfiles.extend( server[ 'logfiles' ] )
  try:
    yield
  finally:
    for logfile in logfiles:
      if os.path.isfile( logfile ):
        log_content, log_end_position = ReadFile(
            logfile, shared_log_indexes.get( logfile, 0 ) )
        shared_log_indexes[ logfile ] = log_end_position
        sys.stdout.write( f'Logfile { logfile }:\n\n' )
        sys.stdout.write( log_content )
        sys.stdout.write( '\n' )