Try to remove the old mock logs first.
423025
def start(self):
        
        if self.resultdir:
            for lname in self.mock_logfiles:
                self.logfiles[lname] = self.build.path_module.join(self.resultdir,
                                                                   lname)
        else:
            for lname in self.mock_logfiles:
                self.logfiles[lname] = lname
        self.addLogObserver('state.log', MockStateObserver())

        cmd = remotecommand.RemoteCommand('rmdir', {'dir':
                                                    [self.build.path_module.join('build', self.logfiles[l])
                                                     for l in self.mock_logfiles]})
        d = self.runCommand(cmd)
        # must resolve super() outside of the callback context.
        super_ = super()

        @d.addCallback
        def removeDone(cmd):
            super_.start()
        d.addErrback(self.failed)
1118884
def redo!
      version = log_data.next_version
      return false if version.nil?

      switch_to!(version.version)
    end
729519
private void tearDownShiro()
  {
    try
    {
      SecurityManager securityManager = SecurityUtils.getSecurityManager();

      LifecycleUtils.destroy(securityManager);
      ThreadContext.unbindSecurityManager();
      ThreadContext.unbindSubject();
      ThreadContext.remove();
    }
    catch (UnavailableSecurityManagerException e)
    {

      // we don't care about this when cleaning up the test environment
      // (for example, maybe the subclass is a unit test and it didn't
      // need a SecurityManager instance because it was using only mock Subject instances)
    }

    SecurityUtils.setSecurityManager(null);
  }
918790
function (config, mockSrc) {
    var dataWithContext = readMockManifest(config, mockSrc);

    // log('readScenarioData config', config);
    if (config.plugins) {
      dataWithContext = runPlugins(dataWithContext, config.plugins);
    }

    return removeContext(dataWithContext);
  }
469533
def _RemoveOsLoginNssCache(self):
    """"""
    if os.path.exists(constants.OSLOGIN_NSS_CACHE):
      try:
        os.remove(constants.OSLOGIN_NSS_CACHE)
      except OSError as e:
        if e.errno != errno.ENOENT:
          raise
658594
public function cleanupCommand(): void
    {
        try {
            $indicesToBeRemoved = $this->nodeIndexer->removeOldIndices();
            if (count($indicesToBeRemoved) > 0) {
                foreach ($indicesToBeRemoved as $indexToBeRemoved) {
                    $this->logger->log('Removing old index ' . $indexToBeRemoved);
                }
            } else {
                $this->logger->log('Nothing to remove.');
            }
        } catch (ApiException $exception) {
            $response = json_decode($exception->getResponse());
            if ($response->error instanceof \stdClass) {
                $this->logger->log(sprintf('Nothing removed. ElasticSearch responded with status %s, saying "%s: %s"', $response->status, $response->error->type, $response->error->reason));
            } else {
                $this->logger->log(sprintf('Nothing removed. ElasticSearch responded with status %s, saying "%s"', $response->status, $response->error));
            }
        }
    }
989947
private void cleanup() {
        StatsDataReference ref = null;
        while ((ref = (StatsDataReference) statisticsReferenceQueue.poll()) != null) {
            StatsData oldStats = null;
            StatsData updatedStats = null;
            do {
                oldStats = terminatedThreadStats.get();
                updatedStats = aggregateStats(oldStats, ref.statsData);
            } while (!terminatedThreadStats.compareAndSet(oldStats, updatedStats));
            allReferences.remove(ref);
        }
    }
31043
def cleanup_logger(self):
        
        self.log_handler.close()
        self.log.removeHandler(self.log_handler)
1326412
def remove_loghandler (handler):
    """"""
    logging.getLogger(LOG_ROOT).removeHandler(handler)
    logging.getLogger().removeHandler(handler)
601737
protected void prune (long now, List<Entry> history)
    {
        int prunepos = 0;
        for (int ll = history.size(); prunepos < ll; prunepos++) {
            Entry entry = history.get(prunepos);
            if (now - entry.message.timestamp < HISTORY_EXPIRATION) {
                break; // stop when we get to the first valid message
            }
        }
        history.subList(0, prunepos).clear();
    }
7250
@JmxOperation(description = "Forcefully invoke the log cleaning")
    public void cleanLogs() {
        synchronized(lock) {
            try {
                for(Environment environment: environments.values()) {
                    environment.cleanLog();
                }
            } catch(DatabaseException e) {
                throw new VoldemortException(e);
            }
        }
    }
1000659
def sanitize_logger (self):
        """"""
        if not self['output']:
            log.warn(LOG_CHECK, _("activating text logger output."))
            self['output'] = 'text'
        self['logger'] = self.logger_new(self['output'])
1260794
def cleanup(self):
        
        with LogTask('Stop prefix'):
            self.stop()
        with LogTask("Tag prefix as uninitialized"):
            os.unlink(self.paths.prefix_lagofile())
1090019
def Clear(self):
    """"""
    try:
      with io.open(self.logfile, "wb") as fd:
        fd.write(b"")
    except (IOError, OSError):
      pass
229633
public synchronized void resetLogger() {
        Logger.appenderList.clear();
        Logger.stopWatch.stop();
        Logger.stopWatch.reset();
        Logger.firstLogEvent = true;
    }
1249026
def reset():
        """"""
        Logger.journal = []
        Logger.fatal_warnings = False
        Logger._ignored_codes = set()
        Logger._ignored_domains = set()
        Logger._verbosity = 2
        Logger._last_checkpoint = 0
1077955
public static void revert() {
        stop();
        delegate = StaticValue.mutateStaticValue(delegate, null);
        loggingConfig.get().set(null);
    }