Cleans up Mbed-test default log directory.

    :param silent: Defaults to False
    :param log_location: Location of log files, defaults to "log"
    :return: Nothing
176674
def _cleanlogs(silent=False, log_location="log"):
    
    try:
        print("cleaning up Icetea log directory.")
        shutil.rmtree(log_location, ignore_errors=silent,
                      onerror=None if silent else _clean_onerror)
    except OSError as error:
        print(error)
1322781
def logging_file_install(path):
    
    if path is None:
        path = configuration_get_default_folder() / LOGGING_DEFAULTNAME

    if not path.parent.exists():
        log.error('File logger installation FAILED!')
        log.error('The directory of the log file does not exist.')
        return

    formatter = logging.Formatter(LOGGING_FORMAT)
    logger = logging.getLogger()

    logger.removeHandler(LOGGING_HANDLERS['file'])

    logFileHandler = logging.handlers.RotatingFileHandler(filename=str(path),
                                                          mode='a',
                                                          maxBytes=LOGGING_MAXBYTES,
                                                          backupCount=LOGGING_BACKUPCOUNT)
    logFileHandler.setLevel(logging.DEBUG)
    logFileHandler.setFormatter(formatter)

    LOGGING_HANDLERS['file'] = logFileHandler

    logger.addHandler(logFileHandler)
1155603
protected boolean isVeraEnabled( boolean quiet ) 
    {
        if ( vera.getSkip() )
        {
            if ( ! quiet )
            {
                getLog().info( VeraConfiguration.SKIP_MESSAGE 
                        + ", 'skip' set to true in the " + VeraConfiguration.TOOL_NAME + " configuration" );
            }
            
            return false;
        }
        
        if ( vera.getVeraHome() == null ) 
        {
            if ( ! quiet )
            {
                getLog().info( VeraConfiguration.SKIP_MESSAGE 
                        + ", path to " + VeraConfiguration.TOOL_NAME + " home directory not set" );
            }
            
            return false;
        }        
        
        return true;
    }
1289753
def update_history_log(history_log,
                       clear=False,
                       description=None,
                       test_log=None):
    
    if not test_log and not clear:
        raise IpaUtilsException(
            'A test log or clear flag must be provided.'
        )

    if clear:
        with ignored(OSError):
            os.remove(history_log)

    else:
        history_dir = os.path.dirname(history_log)
        if not os.path.isdir(history_dir):
            try:
                os.makedirs(history_dir)
            except OSError as error:
                raise IpaUtilsException(
                    'Unable to create directory: %s' % error
                )

        with open(history_log, 'a+') as f:
            # Using append mode creates file if it does not exist
            if description:
                description = '"%s"' % description

            out = '{} {}'.format(
                test_log,
                description or ''
            )
            f.write(out.strip() + '\n')
1277767
def add_log_options(self, verbose_func=None, quiet_func=None):
        

        if not verbose_func:
            def verbose_func():
                return log.config(verbose=True)

        if not quiet_func:
            def quiet_func():
                return log.config(quiet=True)

        self.option('-v, --verbose', 'show more logs', verbose_func)
        self.option('-q, --quiet', 'show less logs', quiet_func)
        return self
1189540
def get_logging_dir(appname='default'):
    
    from utool._internal import meta_util_cache
    from utool._internal import meta_util_cplat
    from utool import util_cache
    if appname is None or  appname == 'default':
        appname = util_cache.get_default_appname()
    resource_dpath = meta_util_cplat.get_resource_dir()
    default = join(resource_dpath, appname, 'logs')
    # Check global cache for a custom logging dir otherwise
    # use the default.
    log_dir = meta_util_cache.global_cache_read(logdir_cacheid,
                                                appname=appname,
                                                default=default)
    log_dir_realpath = realpath(log_dir)
    return log_dir_realpath
1204182
def silence(temporary_level = ::Logger::ERROR)
      begin
        old_logger_level, self.level = level, temporary_level
        yield self
      ensure
        self.level = old_logger_level
      end
    end
1127411
def main(ctx, verbose, quiet):
    
    verbosity = verbose - quiet
    configure_logging(verbosity)
    ctx.obj = {}
    ctx.obj['verbosity'] = verbosity
173114
private void cleanupLogs() throws IOException {
        logger.trace("Beginning log cleanup...");
        int total = 0;
        Iterator<Log> iter = getLogIterator();
        long startMs = System.currentTimeMillis();
        while (iter.hasNext()) {
            Log log = iter.next();
            total += cleanupExpiredSegments(log) + cleanupSegmentsToMaintainSize(log);
        }
        if (total > 0) {
            logger.warn("Log cleanup completed. " + total + " files deleted in " + (System.currentTimeMillis() - startMs) / 1000 + " seconds");
        } else {
            logger.trace("Log cleanup completed. " + total + " files deleted in " + (System.currentTimeMillis() - startMs) / 1000 + " seconds");
        }
    }
820792
public static void ignore(Log log,Throwable th)
    {
        if (log.isTraceEnabled()) log.trace(IGNORED,th);
    }
976232
def clear_silence(self, kwargs):
        
        self._request('POST', '/silenced/clear', data=json.dumps(kwargs))
        return True
232128
def set_silent(self):
        """"""
        self.set_icntl(1, -1) # output stream for error msgs
        self.set_icntl(2, -1) # otuput stream for diagnostic msgs
        self.set_icntl(3, -1) # output stream for global info
        self.set_icntl(4, 0)
204108
private String getLogDir() {
        StringBuffer output = new StringBuffer();
        WsLocationAdmin locationAdmin = locationAdminRef.getService();
        output.append(locationAdmin.resolveString("${server.output.dir}").replace('\\', '/')).append("/logs");
        return output.toString();
    }
1174356
def init_logger(root_dir, name="train.log"):
    
    os.makedirs(root_dir, exist_ok=True)
    log_formatter = logging.Formatter("%(message)s")
    logger = logging.getLogger(name)
    file_handler = logging.FileHandler("{0}/{1}".format(root_dir, name), mode='w')
    file_handler.setFormatter(log_formatter)
    logger.addHandler(file_handler)
    console_handler = logging.StreamHandler()
    console_handler.setFormatter(log_formatter)
    logger.addHandler(console_handler)
    logger.setLevel(logging.INFO)
    return logger
166091
def _setup_logging(self):
        
        self._log_level_delta = (self._args.quiet * 10) - (self._args.verbose * 10)
        level = max(1, self._default_log_level + self._log_level_delta)
        logging.basicConfig(level=level, format=LOG_FORMAT)
307091
private void cleanLogs() throws Exception {
        File logsDir = new File(serverOutputDir.getAbsolutePath(), "logs");
        if (logsDir.exists()) {
            cleanDir(logsDir);
            log(MessageFormat.format(messages.getString("info.element.cleaned"), "logs"));
        } else {
            log(MessageFormat.format(messages.getString("info.directory.noexist"), logsDir.getAbsolutePath()));
        }
    }
191496
def context(self, outdir, log_prefix):
        
        try:
            self._outdir = outdir
            self._log_prefix = log_prefix
            yield
        finally:
            self._log_prefix = None
            self._outdir = None