Create several log files
511859
def run(bam_file, data, out_dir):
    """"""
    m = {"base": None, "secondary": []}
    m.update(_mirbase_stats(data, out_dir))
    m["secondary"].append(_seqcluster_stats(data, out_dir))
528931
def update_log_filenames(self):
        """"""
        log_filenames = os.listdir(self.logs_dir)

        for log_filename in log_filenames:
            full_path = os.path.join(self.logs_dir, log_filename)
            if full_path not in self.log_filenames:
                self.log_filenames.add(full_path)
                self.closed_file_infos.append(
                    LogFileInfo(
                        filename=full_path,
                        size_when_last_opened=0,
                        file_position=0,
                        file_handle=None))
                logger.info("Beginning to track file {}".format(log_filename))
288130
def create_run_logfile(folder):
    
    with open(os.path.join(folder, "run.log"), "w") as f:
        datestring = datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S")
        f.write("timestamp: '%s'" % datestring)
492274
def log_to_file(log_path, log_urllib=False, limit=None):
    
    log_path = log_path
    file_handler = logging.FileHandler(log_path)
    if limit:
        file_handler = RotatingFileHandler(
            log_path,
            mode='a',
            maxBytes=limit * 1024 * 1024,
            backupCount=2,
            encoding=None,
            delay=0)
    fmt = '[%(asctime)s %(filename)18s] %(levelname)-7s - %(message)7s'
    date_fmt = '%Y-%m-%d %H:%M:%S'
    formatter = logging.Formatter(fmt, datefmt=date_fmt)
    file_handler.setFormatter(formatter)
    logger.addHandler(file_handler)
    if log_urllib:
        urllib_logger.addHandler(file_handler)
        urllib_logger.setLevel(logging.DEBUG)
81684
def dump_logs(job_queue='run_reach_queue', job_status='RUNNING'):
    """"""
    jobs = get_jobs(job_queue, job_status)
    for job in jobs:
        get_job_log(job, write_file=True)
233321
def create_logger():
    """"""
    global logger

    formatter = logging.Formatter('%(asctime)s|%(levelname)s|%(message)s')
    handler = TimedRotatingFileHandler(log_file, when="midnight", interval=1)
    handler.setFormatter(formatter)
    handler.setLevel(log_level)
    handler.suffix = "%Y-%m-%d"
    logger = logging.getLogger("sacplus")
    logger.setLevel(log_level)
    logger.addHandler(handler)
964272
def writeB1logfile(filename, data):
    
    allkeys = list(data.keys())
    f = open(filename, 'wt', encoding='utf-8')
    for ld in _logfile_data:  # process each line
        linebegin = ld[0]
        fieldnames = ld[1]
        # set the default formatter if it is not given
        if len(ld) < 3:
            formatter = str
        elif ld[2] is None:
            formatter = str
        else:
            formatter = ld[2]
        # this will contain the formatted values.
        formatted = ''
        if isinstance(fieldnames, str):
            # scalar field name, just one field. Formatter should be a
            # callable.
            if fieldnames not in allkeys:
                # this field has already been processed
                continue
            try:
                formatted = formatter(data[fieldnames])
            except KeyError:
                # field not found in param structure
                continue
        elif isinstance(fieldnames, tuple):
            # more than one field names in a tuple. In this case, formatter can
            # be a tuple of callables...
            if all([(fn not in allkeys) for fn in fieldnames]):
                # if all the fields have been processed:
                continue
            if isinstance(formatter, tuple) and len(formatter) == len(fieldnames):
                formatted = ' '.join([ft(data[fn])
                                      for ft, fn in zip(formatter, fieldnames)])
            # ...or a single callable...
            elif not isinstance(formatter, tuple):
                formatted = formatter([data[fn] for fn in fieldnames])
            # ...otherwise raise an exception.
            else:
                raise SyntaxError('Programming error: formatter should be a scalar or a tuple\
of the same length as the field names in logfile_data.')
        else:  # fieldnames is neither a string, nor a tuple.
            raise SyntaxError(
                'Invalid syntax (programming error) in logfile_data in writeparamfile().')
        # try to get the values
        linetowrite = linebegin + ':\t' + formatted + '\n'
        f.write(linetowrite)
        if isinstance(fieldnames, tuple):
            for fn in fieldnames:  # remove the params treated.
                if fn in allkeys:
                    allkeys.remove(fn)
        else:
            if fieldnames in allkeys:
                allkeys.remove(fieldnames)
    # write untreated params
    for k in allkeys:
        linetowrite = k + ':\t' + str(data[k]) + '\n'
        f.write(linetowrite)

    f.close()
567865
def open_logfile(filename, mode='a'):
    
    filename = os.path.expanduser(filename)
    filename = os.path.abspath(filename)
    dirname = os.path.dirname(filename)
    if not os.path.exists(dirname):
        os.makedirs(dirname)
    exists = os.path.exists(filename)

    log_fp = open(filename, mode)
    if exists:
        log_fp.write('%s\n' % ('-'*60))
        log_fp.write('%s run on %s\n' % (sys.argv[0], time.strftime('%c')))
    return log_fp
450356
def _setup_log(self):
        ''''''
        logger = logging.getLogger()
        formatter = logging.Formatter(
            '%(asctime)s - %(name)s - %(levelname)s - %(message)s')
        self._log_temp_file = NamedTemporaryFile(
            prefix='tmp-wpull-warc-',
            dir=self._params.temp_dir,
            suffix='.log.gz',
            delete=False,
        )
        self._log_temp_file.close()  # For Windows

        self._log_handler = handler = logging.StreamHandler(
            io.TextIOWrapper(
                gzip.GzipFile(
                    filename=self._log_temp_file.name, mode='wb'
                ),
                encoding='utf-8'
            )
        )

        logger.setLevel(logging.DEBUG)
        logger.debug('Wpull needs the root logger level set to DEBUG.')

        handler.setFormatter(formatter)
        logger.addHandler(handler)
        handler.setLevel(logging.INFO)
1314343
def setup_logging(logfile_path):
    
    date_fmt = "%y-%m-%d (%a) %H:%M:%S"

    std_formatter = logging.Formatter('%(asctime)s:%(levelname)s:%(message)s',
                                      date_fmt)

    # Get to the following size before splitting log into multiple files:
    log_chunk_bytesize = 5e6

    info_logfile = logging.handlers.RotatingFileHandler(logfile_path,
                                                        maxBytes=log_chunk_bytesize,
                                                        backupCount=10)
    info_logfile.setFormatter(std_formatter)
    info_logfile.setLevel(logging.DEBUG)

    stdout_log = logging.StreamHandler()
    stdout_log.setLevel(logging.DEBUG)
    stdout_log.setFormatter(std_formatter)

    # Set up root logger
    logger = logging.getLogger()
    logger.handlers = []
    logger.setLevel(logging.DEBUG)
    logger.addHandler(info_logfile)
    logger.addHandler(stdout_log)
    logging.getLogger('iso8601').setLevel(
        logging.ERROR)  # Suppress iso8601 debug log.
    return logger
511210
def set_logfile(path, instance):
    """"""

    global logfile
    logfile = os.path.normpath(path) + '/hfos.' + instance + '.log'
1007097
function writeLogs(test, dirName) {
  var logs =
    test.fullTitle() +
    '\n' +
    test.file +
    '\nStart: ' +
    test.start +
    '\nEnd: ' +
    test.end +
    '\nElapsed: ' +
    test.duration +
    '\nStatus: ' +
    test.state;
  if (test.state === 'fail') {
    logs += '\nError: ' + test.err.stack;
  }
  mkdirp.sync(testDir(test, dirName));
  fs.writeFileSync(testURL(test, dirName), logs);
  test.url = testURL(test, dirName);
}
1033978
function createLogDirectory()
    {
        $this->files->ensureDirExists(VALET_HOME_PATH.'/Log', user());

        $this->files->touch(VALET_HOME_PATH.'/Log/nginx-error.log');
    }
1353157
def create_files(filedef, cleanup=True):
    
    cwd = os.getcwd()
    tmpdir = tempfile.mkdtemp()
    try:
        Filemaker(tmpdir, filedef)
        if not cleanup:  # pragma: nocover
            pass
            # print("TMPDIR =", tmpdir)
        os.chdir(tmpdir)
        yield tmpdir
    finally:
        os.chdir(cwd)
        if cleanup:  # pragma: nocover
            shutil.rmtree(tmpdir, ignore_errors=True)
717181
def get_logs(self):
        ''''''
        folder = os.path.dirname(self.pcfg['log_file'])
        for path, dir, files in os.walk(folder):
            for file in files:
                if os.path.splitext(file)[-1] == '.log':
                    yield os.path.join(path, file)
1090099
def start_file_logger(self, name, log_file_level=logging.DEBUG, log_file_path='./'):
        """"""

        log_file_path = os.path.expanduser(log_file_path) / '{}.log'.format(name)
        logdir = log_file_path.parent

        try:
            logdir.mkdir(parents=True, exist_ok=True)

            # If the log file exists, backs it up before creating a new file handler
            if log_file_path.exists():
                strtime = datetime.datetime.utcnow().strftime('%Y-%m-%d_%H:%M:%S')
                shutil.move(log_file_path, log_file_path + '.' + strtime)

            self.fh = TimedRotatingFileHandler(str(log_file_path), when='midnight', utc=True)
            self.fh.suffix = '%Y-%m-%d_%H:%M:%S'
        except (IOError, OSError) as ee:
            warnings.warn('log file {0!r} could not be opened for writing: '
                          '{1}'.format(log_file_path, ee), RuntimeWarning)
        else:
            self.fh.setFormatter(fmt)
            self.addHandler(self.fh)
            self.fh.setLevel(log_file_level)

        self.log_filename = log_file_path
1103011
def log(self, logfile=None):
        """"""
        if logfile is None:
            logfile = sys.stderr
        tb = self.plaintext.encode('utf-8', 'replace').rstrip() + '\n'
        logfile.write(tb)