本文整理汇总了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`
示例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
示例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)
示例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)
示例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)
示例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