當前位置: 首頁>>代碼示例>>Python>>正文


Python rainbow_logging_handler.RainbowLoggingHandler方法代碼示例

本文整理匯總了Python中rainbow_logging_handler.RainbowLoggingHandler方法的典型用法代碼示例。如果您正苦於以下問題:Python rainbow_logging_handler.RainbowLoggingHandler方法的具體用法?Python rainbow_logging_handler.RainbowLoggingHandler怎麽用?Python rainbow_logging_handler.RainbowLoggingHandler使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在rainbow_logging_handler的用法示例。


在下文中一共展示了rainbow_logging_handler.RainbowLoggingHandler方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: from_list

# 需要導入模塊: import rainbow_logging_handler [as 別名]
# 或者: from rainbow_logging_handler import RainbowLoggingHandler [as 別名]
def from_list(cls, items: t.Optional[list], key_func: t.Callable[[t.Any], t.Any]) -> 'InsertionTimeOrderedDict':
        """
        Creates an ordered dict out of a list of elements.

        :param items: list of elements
        :param key_func: function that returns a key for each passed list element
        :return: created ordered dict with the elements in the same order as in the passed list
        """
        if items is None:
            return InsertionTimeOrderedDict()
        ret = InsertionTimeOrderedDict()
        for item in items:
            ret[key_func(item)] = item
        return ret

#formatter = logging.Formatter("[%(asctime)s] %(name)s %(levelname)s \t%(message)s")
# setup `RainbowLoggingHandler` 
開發者ID:parttimenerd,項目名稱:temci,代碼行數:19,代碼來源:util.py

示例2: execute

# 需要導入模塊: import rainbow_logging_handler [as 別名]
# 或者: from rainbow_logging_handler import RainbowLoggingHandler [as 別名]
def execute(args=None, parser=None):
    parser = build_parser(parent=parser)
    parser.add_argument('--max-cycles', metavar='N', default=None, type=int,
                        help='limit number of fuzz job cycles to %(metavar)s (default: no limit)')
    arguments = parser.parse_args(args)

    logger = logging.getLogger('fuzzinator')
    logger.addHandler(RainbowLoggingHandler(sys.stdout))
    logger.setLevel(arguments.log_level)

    config = configparser.ConfigParser(interpolation=configparser.ExtendedInterpolation())
    config.read(arguments.config)

    controller = Controller(config=config)
    controller.listener += CliListener()

    try:
        controller.run(max_cycles=arguments.max_cycles)
    except KeyboardInterrupt:
        pass 
開發者ID:renatahodovan,項目名稱:fuzzinator,代碼行數:22,代碼來源:cli.py

示例3: add_stdout_handler

# 需要導入模塊: import rainbow_logging_handler [as 別名]
# 或者: from rainbow_logging_handler import RainbowLoggingHandler [as 別名]
def add_stdout_handler(logger, formatter):
    try:
        from rainbow_logging_handler import RainbowLoggingHandler
        handler = RainbowLoggingHandler(sys.stderr, color_funcName=(
            'black', 'black', True))
    except ImportError:
        handler = logging.StreamHandler()
        pass

    handler.setFormatter(formatter)
    logger.addHandler(handler) 
開發者ID:animeshkundu,項目名稱:torrent-dl,代碼行數:13,代碼來源:logger.py

示例4: _setupLogging

# 需要導入模塊: import rainbow_logging_handler [as 別名]
# 或者: from rainbow_logging_handler import RainbowLoggingHandler [as 別名]
def _setupLogging(stream, level, color=True): # pragma: no cover
    "Setup logging according to the command line parameters"
    if isinstance(stream, str):
        class Stream(file):
            """
            File subclass that allows RainbowLoggingHandler to write
            with colors
            """
            def isatty(self):
                return color

        stream = Stream(stream, 'ab', buffering=1)

    from rainbow_logging_handler import RainbowLoggingHandler
    rainbow_stream_handler = RainbowLoggingHandler(
        stream,
        #  Customizing each column's color
        # pylint: disable=bad-whitespace
        color_asctime          = ('dim white',  'black'),
        color_name             = ('dim white',  'black'),
        color_funcName         = ('green',      'black'),
        color_lineno           = ('dim white',  'black'),
        color_pathname         = ('black',      'red'),
        color_module           = ('yellow',     None),
        color_message_debug    = ('color_59',   None),
        color_message_info     = (None,         None),
        color_message_warning  = ('color_226',  None),
        color_message_error    = ('red',        None),
        color_message_critical = ('bold white', 'red'))
        # pylint: enable=bad-whitespace

    logging.root.addHandler(rainbow_stream_handler)
    logging.root.setLevel(level) 
開發者ID:suoto,項目名稱:hdlcc,代碼行數:35,代碼來源:run_tests.py

示例5: setup_console_logging

# 需要導入模塊: import rainbow_logging_handler [as 別名]
# 或者: from rainbow_logging_handler import RainbowLoggingHandler [as 別名]
def setup_console_logging(log_level: t.Optional[str]=None):
    """Setup console logging.

    Aimed to give easy sane defaults for logging in command line applications.

    Don't use logging settings from INI, but use hardcoded defaults.
    """

    formatter = logging.Formatter("[%(asctime)s] [%(name)s %(funcName)s] %(message)s")  # same as default

    # setup `RainbowLoggingHandler`
    # and quiet some logs for the test output
    handler = RainbowLoggingHandler(sys.stdout)
    handler.setFormatter(formatter)
    logger = logging.getLogger()
    logger.handlers = [handler]

    env_level = os.environ.get("LOG_LEVEL", "info")
    log_level = log_level or getattr(logging, env_level.upper())
    logger.setLevel(log_level)

    logger = logging.getLogger("requests.packages.urllib3.connectionpool")
    logger.setLevel(logging.ERROR)

    # SQL Alchemy transactions
    logger = logging.getLogger("txn")
    logger.setLevel(logging.ERROR) 
開發者ID:websauna,項目名稱:websauna,代碼行數:29,代碼來源:cmdline.py

示例6: __init__

# 需要導入模塊: import rainbow_logging_handler [as 別名]
# 或者: from rainbow_logging_handler import RainbowLoggingHandler [as 別名]
def __init__(self, device=None, username=None, password=None, verify_cert=False, domain='Global', loglevel=20):
        self.logger = logging.getLogger('FIREPOWER')
        self.logger.setLevel(loglevel)
        formatter = logging.Formatter('%(asctime)s [%(name)s] [%(levelname)s] %(message)s')
        handler = RainbowLoggingHandler(sys.stderr, color_funcName=('black', 'yellow', True))
        handler.setFormatter(formatter)
        self.logger.addHandler(handler)

        self.api = FireREST(device=device, username=username, password=password, verify_cert=verify_cert,
                            loglevel=loglevel)
        self.domain = domain 
開發者ID:kaisero,項目名稱:fireREST,代碼行數:13,代碼來源:firepower.py


注:本文中的rainbow_logging_handler.RainbowLoggingHandler方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。