Python logbook 模块,more() 实例源码

我们从Python开源项目中,提取了以下2个代码示例,用于说明如何使用logbook.more()

项目:exconf    作者:maginetv    | 项目源码 | 文件源码
def init_logging_stderr(log_level='notset', bubble=False):
    handler = logbook.more.ColorizedStderrHandler(level=figure_out_log_level(log_level),
                                                  bubble=bubble)
    handler.format_string = '{record.time:%Y-%m-%dT%H:%M:%S.%f} ' \
                            '{record.level_name} {record.channel}: {record.message}'
    handler.push_application()
项目:saltyrtc-server-python    作者:saltyrtc    | 项目源码 | 文件源码
def cli(ctx, verbosity, colored):
    """
    Command Line Interface. Use --help for details.
    """
    if verbosity > 0:
        try:
            # noinspection PyPackageRequirements,PyUnresolvedReferences
            import logbook
            # noinspection PyUnresolvedReferences,PyPackageRequirements
            import logbook.more
        except ImportError:
            click.echo('Please install saltyrtc.server[logging] for logging support.',
                       err=True)
            ctx.exit(code=_ErrorCode.import_error)

        # Translate logging level
        level = _get_logging_level(verbosity)

        # Enable asyncio debug logging if verbosity is high enough
        # noinspection PyUnboundLocalVariable
        if level <= logbook.DEBUG:
            os.environ['PYTHONASYNCIODEBUG'] = '1'

        # Enable logging
        util.enable_logging(level=level, redirect_loggers={
            'asyncio': level,
            'websockets': level,
        })

        # Get handler class
        if colored:
            handler_class = logbook.more.ColorizedStderrHandler
        else:
            handler_class = logbook.StderrHandler

        # Set up logging handler
        handler = handler_class(level=level)
        handler.push_application()
        ctx.obj['logging_handler'] = handler