Redirect Recipe log messages to a file.
185257
def create_recipe_file_logger(logger, logfile, logformat):
    """"""
    recipe_formatter = logging.Formatter(logformat)
    fh = logging.FileHandler(logfile, mode='w')
    fh.setLevel(logging.DEBUG)
    fh.setFormatter(recipe_formatter)
    return fh
448031
def log_to_file(filename, level=DEBUG):
    """"""
    logger = logging.getLogger("paramiko")
    if len(logger.handlers) > 0:
        return
    logger.setLevel(level)
    f = open(filename, "a")
    handler = logging.StreamHandler(f)
    frm = "%(levelname)-.3s [%(asctime)s.%(msecs)03d] thr=%(_threadid)-3d"
    frm += " %(name)s: %(message)s"
    handler.setFormatter(logging.Formatter(frm, "%Y%m%d-%H:%M:%S"))
    logger.addHandler(handler)
1157883
def create_shipfile(target, source, env):
    """"""

    source_dir = os.path.dirname(str(source[0]))
    recipe_name = os.path.basename(str(source[0]))[:-5]

    resman = RecipeManager()

    resman.add_recipe_actions(env['CUSTOM_STEPS'])
    resman.add_recipe_folder(source_dir, whitelist=[os.path.basename(str(source[0]))])
    recipe = resman.get_recipe(recipe_name)

    recipe.archive(str(target[0]))
270903
def dlog(msg, log_path=DEFAULT_LOG_PATH):
  """"""
  with open(log_path, 'a') as f:
    f.write('\n{}@{}: {}'.format(os.getpid(), threading.current_thread().name, msg))
1089347
def create_log_message(log_dict, use_sql_info=False, fmt=True):
    
    log_msg = (
        "%(remote_address)s %(user_email)s %(method)s %(url)s %(status)d "
        "%(content_length)d (%(request_time).2f seconds)"
    )
    if use_sql_info:
        sql_time = sum(
            float(q['time']) for q in connection.queries) * 1000
        extra_log = {
            'nr_queries': len(connection.queries),
            'sql_time': sql_time}
        log_msg += " (%(nr_queries)d SQL queries, %(sql_time)f ms)"
        log_dict.update(extra_log)
    return log_msg % log_dict if fmt else log_msg
684345
def log(_self, _level, _message, *args, **kwargs):
        """
        logger = _self.opt(
            exception=_self._exception,
            record=_self._record,
            lazy=_self._lazy,
            ansi=_self._ansi,
            raw=_self._raw,
            depth=_self._depth + 1,
        )
        logger._make_log_function(_level)(logger, _message, *args, **kwargs)
1098525
def redirect_output!
      if log_path = options[:log_path]
        # if the log directory doesn't exist, create it
        FileUtils.mkdir_p File.dirname(options[:log_path]), :mode => 0755
        # touch the log file to create it
        FileUtils.touch log_path
        # Set permissions on the log file
        File.chmod(0644, log_path)
        # Reopen $stdout (NOT +STDOUT+) to start writing to the log file
        $stdout.reopen(log_path, 'a')
        # Redirect $stderr to $stdout
        $stderr.reopen $stdout
        $stdout.sync = true
      else # redirect to /dev/null
        # We're not bothering to sync if we're dumping to /dev/null
        # because /dev/null doesn't care about buffered output
        $stdin.reopen '/dev/null'
        $stdout.reopen '/dev/null', 'a'
        $stderr.reopen $stdout
      end
      log_path = options[:log_path] ? options[:log_path] : '/dev/null'
    end
171819
def _log_to_file(self, etype, source, msg='', target='', hostmask='', params=''):
        
        today = datetime.utcnow()
        # TODO: Use self.locale['timezone'] for changing time
        date = today.strftime(self.locale['date_fmt'])
        time = today.strftime(self.locale['time_fmt'])
        datetime_s = today.strftime(self.locale['short_datetime_fmt'])
        datetime_l = today.strftime(self.locale['long_datetime_fmt'])
        
        if target == self.nickname and etype in ('privmsg', 'action'):
            target = source

        if etype in self.log_formats:
            file_path = os.path.expanduser(self.log_file.format(**locals()))
            file_dir = os.path.dirname(file_path)
            if not os.path.isdir(file_dir):
                os.makedirs(file_dir)

            line = self.log_formats[etype].format(**locals())
            with open(file_path, 'a') as log:
                log.write(line+'\n')
297975
def run(self):
        """"""
        titles = ['date', 'host', 'state/message']
        table_rows = []

        for host, state, logevent in self.mloginfo.logfile.rs_state:
            stats = OrderedDict()
            stats['date'] = logevent.datetime.strftime("%b %d %H:%M:%S")
            stats['host'] = host
            stats['state/message'] = state
            table_rows.append(stats)

        print_table(table_rows, titles, uppercase_headers=False)

        if len(self.mloginfo.logfile.rs_state) == 0:
            print("  no rs state changes found")
885595
def set_up_logging(log_filename: str = "log", verbosity: int = 0) ->logging.Logger:
    """"""
    LOG.setLevel(logging.DEBUG)

    # Log everything verbosely to a file.
    file_handler = RotatingFileHandler(filename=log_filename, maxBytes=1024000000, backupCount=10)
    verbose_form = logging.Formatter(fmt="%(asctime)s - %(levelname)s - %(module)s - %(message)s")
    file_handler.setFormatter(verbose_form)
    file_handler.setLevel(logging.DEBUG)
    LOG.addHandler(file_handler)

    # Provide a stdout handler logging at INFO.
    stream_handler = logging.StreamHandler(sys.stdout)
    simple_form = logging.Formatter(fmt="%(message)s")
    stream_handler.setFormatter(simple_form)

    if verbosity > 0:
        stream_handler.setLevel(logging.DEBUG)
    else:
        stream_handler.setLevel(logging.INFO)

    LOG.addHandler(stream_handler)

    return LOG
1041192
def log_message(self, msg, *args):
        """"""
        if args:
            msg = msg % args
        self.logger.info(msg)
826474
def _write_to_log(self, s, truncate=False):
        """"""
        # if truncate is True, set write mode to truncate
        with open(self._logfile, 'w' if truncate else 'a') as fp:
            fp.writelines((to_text(s) if six.PY2 else to_text(s), ))
2404
def vlog(self, msg, *args):
        """"""
        if self.verbose:
            self.log(msg, *args)
371732
def rerunExperimentFromLogfile(logFilename):
    
    callLog = LoggingDecorator.load(logFilename)

    # Assume first one is call to constructor
    exp = L246aNetwork(*callLog[0][1]["args"], **callLog[0][1]["kwargs"])

    # Call subsequent methods, using stored parameters
    for call in callLog[1:]:
      method = getattr(exp, call[0])
      method(*call[1]["args"], **call[1]["kwargs"])

    return exp
413355
function writeLog(entries){
    var output = '';

    _.each(entries, function(entry){
        output += entry + '\n';
    });

    return fs.appendFileAsync(this.config.path, output);
}
325094
def log(self, msg):
        '''
        '''
        if self.logfile:
            fd = self.logfile.fileno()
        else:
            fd = sys.stdout.fileno()

        os.write(fd, ('%.3f %s\n' % (time.time(), msg)).encode('UTF-8'))
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))