Creates a one-line summary on the actions that were logged by the given
    Logger.

    :type  logger: Logger
    :param logger: The logger that recorded what happened in the queue.
    :rtype:  string
    :return: A string summarizing the status.
168846
def status(logger):
    
    aborted = logger.get_aborted_actions()
    succeeded = logger.get_succeeded_actions()
    total = aborted + succeeded
    if total == 0:
        return 'No actions done'
    elif total == 1 and succeeded == 1:
        return 'One action done (succeeded)'
    elif total == 1 and succeeded == 0:
        return 'One action done (failed)'
    elif total == succeeded:
        return '%d actions total (all succeeded)' % total
    elif succeeded == 0:
        return '%d actions total (all failed)' % total
    else:
        msg = '%d actions total (%d failed, %d succeeded)'
        return msg % (total, aborted, succeeded)
966781
def print_summary(num_actions, failed, duration):
    
    num_failed = len(failed)
    print("""
Summary:
{num_total} actions were in the queue.
{num_failed} actions failed to execute.

This run took: {elapsed_time:8.3f} seconds.
    """.format(
        num_total=num_actions, num_failed=num_failed, elapsed_time=duration))
378876
def _logger_api(self):
        """"""
        from .tcex_logger import TcExLogHandler, TcExLogFormatter

        api = TcExLogHandler(self.session)
        api.set_name('api')
        api.setLevel(logging.DEBUG)
        api.setFormatter(TcExLogFormatter())
        self.log.addHandler(api)
87259
def getLoggerWithConsoleHandler(logger_name=None):
    
    logger = logging.getLogger(logger_name)
    logger.setLevel(logging.INFO)
    if not logger.handlers:
        handler = logging.StreamHandler(sys.stdout)
        if sys.platform == 'win32':
            formatter = logging.Formatter(
                            fmt="%(asctime)s %(name)s %(message)s",
                            datefmt='%H:%M:%S')
        else:
            formatter = ColorFormatter(fmt="$RESET %(asctime)s "
                                       "$BOLD$COLOR%(name)s$RESET "
                                       "%(message)s", datefmt='%H:%M:%S')
        handler.setFormatter(formatter)
        logger.addHandler(handler)
    return logger
708092
def logStream(fileHandle, shortName, printFunction=logger.info):
    
    printFunction("Reporting file: %s" % shortName)
    line = fileHandle.readline()
    while line != '':
        if line[-1] == '\n':
            line = line[:-1]
        printFunction("%s:\t%s" % (shortName, line))
        line = fileHandle.readline()
    fileHandle.close()
968552
def log(self, msg, level="info"):
        
        if not self.config.get("log_file"):
            # If level was given as a str then convert to actual level
            level = LOG_LEVELS.get(level, level)
            syslog(level, u"{}".format(msg))
        else:
            # Binary mode so fs encoding setting is not an issue
            with open(self.config["log_file"], "ab") as f:
                log_time = time.strftime("%Y-%m-%d %H:%M:%S")
                # nice formating of data structures using pretty print
                if isinstance(msg, (dict, list, set, tuple)):
                    msg = pformat(msg)
                    # if multiline then start the data output on a fresh line
                    # to aid readability.
                    if "\n" in msg:
                        msg = u"\n" + msg
                out = u"{} {} {}\n".format(log_time, level.upper(), msg)
                try:
                    # Encode unicode strings to bytes
                    f.write(out.encode("utf-8"))
                except (AttributeError, UnicodeDecodeError):
                    # Write any byte strings straight to log
                    f.write(out)
682678
def register_logger(self, logger):
        
        handler = CommandHandler(self)
        handler.setFormatter(CommandFormatter())
        logger.handlers = [handler]
        logger.propagate = False

        output = self.output
        level = logging.WARNING
        if output.is_debug():
            level = logging.DEBUG
        elif output.is_very_verbose() or output.is_verbose():
            level = logging.INFO

        logger.setLevel(level)
1242916
def log_status (self, checked, in_progress, queue, duration, num_urls):
        """"""
        msg = _n("%2d thread active", "%2d threads active", in_progress) % \
          in_progress
        self.write(u"%s, " % msg)
        msg = _n("%5d link queued", "%5d links queued", queue) % queue
        self.write(u"%s, " % msg)
        msg = _n("%4d link", "%4d links", checked) % checked
        self.write(u"%s" % msg)
        msg = _n("%3d URL", "%3d URLs", num_urls) % num_urls
        self.write(u" in %s checked, " % msg)
        msg = _("runtime %s") % strformat.strduration_long(duration)
        self.writeln(msg)
        self.flush()
923805
def logtrace(logger, msg, *args, **kwargs):
    '''
    
    '''
    if esgfpid.defaults.LOG_TRACE_TO_DEBUG:
        logdebug(logger, '[trace] %s' % msg, *args, **kwargs)
    else:
        pass
699168
def log(self, msg, level=INFO):
        
        logger.log(level, '<{}> - '.format(self._name) + msg)
825977
def get_logger(name, verbosity, stream):
    
    logger = logging.getLogger(name)
    logger.setLevel(
        {0: DEFAULT_LOGGING_LEVEL, 1: logging.INFO, 2: logging.DEBUG}.get(min(2, verbosity), DEFAULT_LOGGING_LEVEL)
    )
    logger.handlers = []
    handler = logging.StreamHandler(stream)
    handler.setLevel(logging.DEBUG)
    handler.setFormatter(logging.Formatter(LOG_FORMAT))
    logger.addHandler(handler)
    return logger
891097
def info (logname, msg, *args, **kwargs):
    
    log = logging.getLogger(logname)
    if log.isEnabledFor(logging.INFO):
        _log(log.info, msg, args, **kwargs)
890147
def log(*args, level=INFO):
    
    Logger.CURRENT.log(*args, level=level)
171994
def get_logfile(logger=None):
    
    logger = logger or logging.getLogger()
    handlers = [i for i in logger.handlers if isinstance(i, logging.FileHandler)]
    return handlers[0].baseFilename if handlers else None
435379
def write(self, msg, level=logging.INFO):
        
        if msg is not None and len(msg.strip()) > 0:
            self.logger.log(level, msg)
963476
def logging_list_loggers(**kwargs):
    
    ctx = Context(**kwargs)
    ctx.execute_action('logging:list_loggers', **{
        'logging_service': ctx.repo.create_secure_service('logging'),
    })
816613
def init_logger():
    
    formatter = logging.Formatter('%(levelname)s: %(message)s')
    console = logging.StreamHandler(stream=sys.stdout)
    console.setLevel(logging.INFO)
    console.setFormatter(formatter)
    logger.addHandler(console)