当前位置: 首页>>代码示例>>Python>>正文


Python coloredlogs.install方法代码示例

本文整理汇总了Python中coloredlogs.install方法的典型用法代码示例。如果您正苦于以下问题:Python coloredlogs.install方法的具体用法?Python coloredlogs.install怎么用?Python coloredlogs.install使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在coloredlogs的用法示例。


在下文中一共展示了coloredlogs.install方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setup_logging

# 需要导入模块: import coloredlogs [as 别名]
# 或者: from coloredlogs import install [as 别名]
def setup_logging(level):
    try:
        import coloredlogs
        coloredlogs.install(level=level.upper())
    except ImportError:
        LOGGER = logging.getLogger()
        handler = logging.StreamHandler()
        handler.setLevel(level.upper())
        formatter = logging.Formatter(('%(asctime)s - '
                                       '%(name)s - '
                                       '%(levelname)s - '
                                       '%(message)s'))
        handler.setFormatter(formatter)
        LOGGER.addHandler(handler)
        LOGGER.setLevel(level.upper())
    for logger in LOGGERS_TO_DISABLE:
        logging.getLogger(logger).disabled = True

# TODO extend debug logging in the following methods 
开发者ID:costastf,项目名称:toonapilib,代码行数:21,代码来源:core_library.py

示例2: _get_logger

# 需要导入模块: import coloredlogs [as 别名]
# 或者: from coloredlogs import install [as 别名]
def _get_logger(name):
    logger = logging.getLogger(name)

    logger.setLevel(logging.DEBUG)

    # leave the handlers level at NOTSET so the level checking is only handled by the logger
    logger.addHandler(_get_console_handler())

    if ENABLE_CLOUDWATCH:
        print(
            "enable cloudwatch, log group",
            CLOUDWATCH_LOG_GROUP,
            "; log stream:",
            CLOUDWATCH_LOG_STREAM,
        )
        logger.addHandler(_get_watchtower_handler())

    # no propagation to avoid propagating to root logger
    logger.propagate = False

    if COLOR_LOG:
        coloredlogs.install(level="DEBUG", logger=logger, fmt=_log_format)

    return logger 
开发者ID:simple-login,项目名称:app,代码行数:26,代码来源:log.py

示例3: get_logger

# 需要导入模块: import coloredlogs [as 别名]
# 或者: from coloredlogs import install [as 别名]
def get_logger(name='', debug=None, format=None):

    import coloredlogs
    # logging.basicConfig() # this will make paramiko log a lot of stuff
    logger = logging.getLogger(name if name else 'aetros')

    level = 'INFO'
    fmt = '%(message)s' if format is None else format

    if debug is None:
        debug = is_debug()

    if debug:
        level = 'DEBUG'
        if format is None:
            fmt = coloredlogs.DEFAULT_LOG_FORMAT

    atty = None
    if '1' == os.getenv('AETROS_ATTY'):
        atty = True

    coloredlogs.install(fmt=fmt, level=level, logger=logger, isatty=atty)

    return logger 
开发者ID:aetros,项目名称:aetros-cli,代码行数:26,代码来源:__init__.py

示例4: apply_config_defaults

# 需要导入模块: import coloredlogs [as 别名]
# 或者: from coloredlogs import install [as 别名]
def apply_config_defaults(config):
    defaults = {
        'model': None,
        'dockerfile': None,
        'command': None,
        'install': None,
        'ignore': None,
        'image': None,
        'server': None,
        'parameters': {},
        'import': None,
        'root': os.getcwd(),
        'working_dir': None,
        'servers': None,
        'configPath': None,
        'before_command': [],
    }

    defaults.update(config)

    return defaults 
开发者ID:aetros,项目名称:aetros-cli,代码行数:23,代码来源:__init__.py

示例5: __init__

# 需要导入模块: import coloredlogs [as 别名]
# 或者: from coloredlogs import install [as 别名]
def __init__(self, configuration, merger, extractor, converter):
        coloredlogs.install()

        logging.info("Using configuration: \n" + str(configuration))

        self.configuration = configuration
        self.merger = merger
        self.converter = converter
        self.extractor = extractor

        self.merger.source_assets_dir = configuration.generated_assets_dir
        self.merger.default_xcasset_dir = configuration.xcassets_dir

        self.converter.input_dir = configuration.raw_assets
        self.converter.output_dir = configuration.generated_assets_dir
        self.converter.force_convert = configuration.force_convert

        self.extractor.input_dir = configuration.extract_path
        self.extractor.output_dir = configuration.raw_assets 
开发者ID:Polidea,项目名称:basset-ios,代码行数:21,代码来源:basset_ios.py

示例6: launch

# 需要导入模块: import coloredlogs [as 别名]
# 或者: from coloredlogs import install [as 别名]
def launch(command_args, prog, description):
    parser = argparse.ArgumentParser(prog=prog, description=description)
    _docker_image(parser)
    _debug(parser)
    _interactive(parser)
    _jupyter(parser)
    _port(parser)
    _use_gpu(parser)
    _gpus(parser)

    args = parser.parse_args(command_args)
    coloredlogs.install(level=args.log_level)

    config = {"sysconfig": {"docker_image": args.docker_image}}
    _set_gpus(config, args.use_gpu, args.gpus)

    rig = Evaluator(config)
    rig.run(
        interactive=args.interactive,
        jupyter=args.jupyter,
        host_port=args.port,
        command="true # No-op",
    ) 
开发者ID:twosixlabs,项目名称:armory,代码行数:25,代码来源:__main__.py

示例7: test_chart_set_values

# 需要导入模块: import coloredlogs [as 别名]
# 或者: from coloredlogs import install [as 别名]
def test_chart_set_values(self):
        for chart in self.charts:
            if chart.name == test_flat_values_chart:
                self.assertEqual(chart.set_values, test_flat_values)
                self.assertIsInstance(chart.set_values, dict)
                self.assertIsInstance(chart.set_values['string'], str)
                self.assertIsInstance(chart.set_values['integer'], int)
                self.assertIsInstance(chart.set_values['boolean'], bool)
            elif chart.name == test_nested_values_chart:
                self.assertEqual(chart.set_values, test_nested_values)
            elif chart.release_name == test_values_strings_chart:
                self.assertIsInstance(chart.values_strings['string'], str)
                self.assertIsInstance(chart.values_strings['integer'], int)
                self.assertIsInstance(chart.values_strings['boolean'], bool)

    # FIXME: Related to the FIXME in install() of Chart class. 
开发者ID:FairwindsOps,项目名称:reckoner,代码行数:18,代码来源:test_reckoner.py

示例8: main

# 需要导入模块: import coloredlogs [as 别名]
# 或者: from coloredlogs import install [as 别名]
def main(self):
        """
        Main entry point
        :return:
        """
        parser = self.init_parser()
        if len(sys.argv) < 2:
            parser.print_usage()
            sys.exit(0)

        self.args = parser.parse_args()
        self.roca.args.flatten = self.args.flatten
        self.roca.args.indent = self.args.indent

        if self.args.debug:
            coloredlogs.install(level=logging.DEBUG)
            self.roca.args.debug = True

        self.work() 
开发者ID:crocs-muni,项目名称:roca,代码行数:21,代码来源:detect_tls.py

示例9: try_open_jks

# 需要导入模块: import coloredlogs [as 别名]
# 或者: from coloredlogs import install [as 别名]
def try_open_jks(self, data, name):
        """
        Tries to guess JKS password
        :param name:
        :param data:
        :return:
        """
        try:
            import jks
        except:
            logger.warning('Could not import jks, try running: pip install pyjks')
            raise ImportException('Cannot import pyjks')

        pwdlist = sorted(list(set(self.jks_file_passwords + self.jks_passwords)))
        for cur in pwdlist:
            try:
                return jks.KeyStore.loads(data, cur)
            except Exception as e:
                pass
        return None 
开发者ID:crocs-muni,项目名称:roca,代码行数:22,代码来源:detect.py

示例10: setup_logging

# 需要导入模块: import coloredlogs [as 别名]
# 或者: from coloredlogs import install [as 别名]
def setup_logging():
    """configure logging

    call this as soon as possible
    """
    try:
        import coloredlogs

        coloredlogs.install(level=logging.INFO)
    except Exception:
        logger.warning("Could not import coloredlogs")
        # fall back to basicConfig
        logging.basicConfig(level=logging.INFO,)


# setup the logger 
开发者ID:codeforboston,项目名称:GovLens,代码行数:18,代码来源:settings.py

示例11: get_logger

# 需要导入模块: import coloredlogs [as 别名]
# 或者: from coloredlogs import install [as 别名]
def get_logger(name='', save_dir=None, distributed_rank=0, filename="log.txt"):
    logger = logging.getLogger(name)
    coloredlogs.install(level='DEBUG', logger=logger)
    # logger.setLevel(logging.DEBUG)
    # don't log results for the non-master process
    if distributed_rank > 0:
        return logger
    formatter = logging.Formatter(
        "%(asctime)s %(name)s %(levelname)s: %(message)s")

    # ch = logging.StreamHandler(stream=sys.stdout)
    # ch.setLevel(logging.DEBUG)
    # ch.setFormatter(formatter)
    # logger.addHandler(ch)

    if save_dir:
        fh = logging.FileHandler(os.path.join(save_dir, filename))
        fh.setLevel(logging.DEBUG)
        fh.setFormatter(formatter)
        if len(logger.handlers) > 0:
            logger.removeHandler(logger.handlers[0])
        logger.addHandler(fh)

    return logger 
开发者ID:DingXiaoH,项目名称:ACNet,代码行数:26,代码来源:logger.py

示例12: main

# 需要导入模块: import coloredlogs [as 别名]
# 或者: from coloredlogs import install [as 别名]
def main():
    """Convert zipped EPA CEMS Hourly data to Apache Parquet format."""
    # Display logged output from the PUDL package:
    logger = logging.getLogger(pudl.__name__)
    log_format = '%(asctime)s [%(levelname)8s] %(name)s:%(lineno)s %(message)s'
    coloredlogs.install(fmt=log_format, level='INFO', logger=logger)

    args = parse_command_line(sys.argv)

    pudl_settings = pudl.workspace.setup.derive_paths(
        pudl_in=args.pudl_in, pudl_out=args.pudl_out)

    epacems_to_parquet(datapkg_path=pathlib.Path(args.datapkg),
                       epacems_years=args.years,
                       epacems_states=args.states,
                       out_dir=pathlib.Path(
                           pudl_settings['parquet_dir'], "epacems"),
                       compression=args.compression,
                       partition_cols=('year', 'state'),
                       clobber=args.clobber) 
开发者ID:catalyst-cooperative,项目名称:pudl,代码行数:22,代码来源:epacems_to_parquet.py

示例13: get_logger

# 需要导入模块: import coloredlogs [as 别名]
# 或者: from coloredlogs import install [as 别名]
def get_logger(component_name, level=logging.INFO, stdout=True):
    coloredlogs.DEFAULT_FIELD_STYLES = {'asctime': {'color': 'green'}, 'hostname': {'color': 'magenta'},
                                        'levelname': {'bold': True, 'color': 'black'},
                                        'name': {'color': 'cyan', 'bold': True},
                                        'programname': {'color': 'blue'}, 'username': {'color': 'yellow'}}

    utilities.makedirs(const.LOG_PATH, exist_ok=True)
    today_formatted_date = datetime.strftime(datetime.today(), '%d-%m-%Y')
    logger = logging.getLogger(component_name)
    logger.setLevel(level)
    if not len(logger.handlers):
        fh = logging.FileHandler(os.path.join(const.LOG_PATH, 'dynamite-{}.log'.format(today_formatted_date)))
        fformatter = logging.Formatter(
            '%(asctime)s | %(name)15s | %(module)20s | %(funcName)45s | %(lineno)4s | %(levelname)8s |  %(message)s')
        fh.setFormatter(fformatter)
        logger.addHandler(fh)
    if stdout:
        coloredlogs.install(level=level, logger=logger,
                            fmt='%(asctime)s %(name)-15s %(levelname)-10s | %(message)s')
    logger.propagate = False
    return logger 
开发者ID:DynamiteAI,项目名称:dynamite-nsm,代码行数:23,代码来源:logger.py

示例14: setup_logging

# 需要导入模块: import coloredlogs [as 别名]
# 或者: from coloredlogs import install [as 别名]
def setup_logging(level):
    try:
        import coloredlogs
        coloredlogs.install(level=level.upper())
    except ImportError:
        LOGGER = logging.getLogger()
        handler = logging.StreamHandler()
        handler.setLevel(level.upper())
        formatter = logging.Formatter(('%(asctime)s - '
                                       '%(name)s - '
                                       '%(levelname)s - '
                                       '%(message)s'))
        handler.setFormatter(formatter)
        LOGGER.addHandler(handler)
        LOGGER.setLevel(level.upper())
    for logger in LOGGERS_TO_DISABLE:
        logging.getLogger(logger).disabled = True


# TODO extend debug logging in the following methods 
开发者ID:schubergphilis,项目名称:towerlib,代码行数:22,代码来源:core_library.py

示例15: install

# 需要导入模块: import coloredlogs [as 别名]
# 或者: from coloredlogs import install [as 别名]
def install(level=logging.INFO, **kw):
    """
    Install a :py:class:`ColoredStreamHandler` for the root logger. Calling
    this function multiple times will never install more than one handler.

    :param level: The logging level to filter on (defaults to :py:data:`logging.INFO`).
    :param kw: Optional keyword arguments for :py:class:`ColoredStreamHandler`.
    """
    global root_handler
    if not root_handler:
        # Create the root handler.
        root_handler = ColoredStreamHandler(level=level, **kw)
        # Install the root handler.
        root_logger = logging.getLogger()
        root_logger.setLevel(logging.NOTSET)
        root_logger.addHandler(root_handler)

# TODO Move these functions into ColoredStreamHandler? 
开发者ID:xtiankisutsa,项目名称:MARA_Framework,代码行数:20,代码来源:coloredlogs.py


注:本文中的coloredlogs.install方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。