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


Python logbook.StderrHandler方法代码示例

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


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

示例1: analyze

# 需要导入模块: import logbook [as 别名]
# 或者: from logbook import StderrHandler [as 别名]
def analyze(context=None, results=None):
    import matplotlib.pyplot as plt
    import logbook
    logbook.StderrHandler().push_application()
    log = logbook.Logger('Algorithm')

    fig = plt.figure()
    ax1 = fig.add_subplot(211)

    results.algorithm_period_return.plot(ax=ax1,color='blue',legend=u'策略收益')
    ax1.set_ylabel(u'收益')
    results.benchmark_period_return.plot(ax=ax1,color='red',legend=u'基准收益')

    plt.show()

# capital_base is the base value of capital
# 
开发者ID:zhanghan1990,项目名称:zipline-chinese,代码行数:19,代码来源:doubleMA.py

示例2: cli

# 需要导入模块: import logbook [as 别名]
# 或者: from logbook import StderrHandler [as 别名]
def cli(ctx, verbosity, colored):
    """
    Command Line Interface. Use --help for details.
    """
    if verbosity > 0:
        # Enable logging
        util.enable_logging(level=_logging_levels[verbosity])

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

        # Set up logging handler
        handler = handler_class(level=_logging_levels[verbosity])
        handler.push_application()
        global _logging_handler
        _logging_handler = handler

    # Create context object
    ctx.obj = {} 
开发者ID:lgrahl,项目名称:threema-msgapi-sdk-python,代码行数:24,代码来源:callback_server.py

示例3: cli

# 需要导入模块: import logbook [as 别名]
# 或者: from logbook import StderrHandler [as 别名]
def cli(ctx: click.Context, verbosity: int, colored: bool) -> None:
    """
    Command Line Interface. Use --help for details.
    """
    if verbosity > 0:
        try:
            # noinspection PyUnresolvedReferences
            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 
开发者ID:saltyrtc,项目名称:saltyrtc-server-python,代码行数:39,代码来源:bin.py

示例4: init_logging_stderr

# 需要导入模块: import logbook [as 别名]
# 或者: from logbook import StderrHandler [as 别名]
def init_logging_stderr(log_level='notset', bubble=False):
    handler = logbook.StderrHandler(level=figure_out_log_level(log_level), bubble=bubble)
    handler.push_application()
    get_logger().debug("stderr logging initialized") 
开发者ID:spotify,项目名称:postgresql-metrics,代码行数:6,代码来源:common.py

示例5: add_stderr_log

# 需要导入模块: import logbook [as 别名]
# 或者: from logbook import StderrHandler [as 别名]
def add_stderr_log(self):
        stderr_handler = logbook.StderrHandler(level=self.log_level)
        stderr_handler.format_string = self.format_string
        stderr_handler.formatter

        self.add_handler(stderr_handler) 
开发者ID:haukurk,项目名称:flask-restapi-recipe,代码行数:8,代码来源:logging.py

示例6: main

# 需要导入模块: import logbook [as 别名]
# 或者: from logbook import StderrHandler [as 别名]
def main(extension, strict_extensions, default_extension):
    """Top level catalyst entry point.
    """
    # install a logbook handler before performing any other operations
    logbook.StderrHandler().push_application()
    load_extensions(
        default_extension,
        extension,
        strict_extensions,
        os.environ,
    ) 
开发者ID:enigmampc,项目名称:catalyst,代码行数:13,代码来源:__main__.py

示例7: logging_context

# 需要导入模块: import logbook [as 别名]
# 或者: from logbook import StderrHandler [as 别名]
def logging_context(path=None, level=None):
    from logbook import StderrHandler, FileHandler
    from logbook.compat import redirected_logging
    with StderrHandler(level=level or 'INFO').applicationbound():
        if path:
            if not os.path.isdir(os.path.dirname(path)):
                os.makedirs(os.path.dirname(path))
            with FileHandler(path, bubble=True).applicationbound():
                with redirected_logging():
                    yield
        else:
            with redirected_logging():
                yield 
开发者ID:Answeror,项目名称:srep,代码行数:15,代码来源:__init__.py

示例8: cli

# 需要导入模块: import logbook [as 别名]
# 或者: from logbook import StderrHandler [as 别名]
def cli(ctx, verbosity, colored, verify_fingerprint, fingerprint):
    """
    Command Line Interface. Use --help for details.
    """
    if verbosity > 0:
        # Enable logging
        util.enable_logging(level=_logging_levels[verbosity])

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

        # Set up logging handler
        handler = handler_class(level=_logging_levels[verbosity])
        handler.push_application()
        global _logging_handler
        _logging_handler = handler

    # Fingerprint
    if fingerprint is not None:
        fingerprint = binascii.unhexlify(fingerprint)

    # Store on context
    ctx.obj = {
        'verify_fingerprint': verify_fingerprint,
        'fingerprint': fingerprint
    } 
开发者ID:lgrahl,项目名称:threema-msgapi-sdk-python,代码行数:31,代码来源:gateway_client.py

示例9: server_factory

# 需要导入模块: import logbook [as 别名]
# 或者: from logbook import StderrHandler [as 别名]
def server_factory(request, event_loop, server_permanent_keys):
    """
    Return a factory to create :class:`saltyrtc.Server` instances.
    """
    # Enable asyncio debug logging
    event_loop.set_debug(True)

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

    # Push handlers
    logging_handler = logbook.StderrHandler(bubble=True)
    logging_handler.push_application()

    _server_instances = []

    def _server_factory(permanent_keys=None):
        if permanent_keys is None:
            permanent_keys = server_permanent_keys

        # Setup server
        port = unused_tcp_port()
        coroutine = serve(
            util.create_ssl_context(
                pytest.saltyrtc.cert, keyfile=pytest.saltyrtc.key,
                dh_params_file=pytest.saltyrtc.dh_params),
            permanent_keys,
            host=pytest.saltyrtc.host,
            port=port,
            loop=event_loop,
            server_class=TestServer,
        )
        server_ = event_loop.run_until_complete(coroutine)
        # Inject timeout and address (little bit of a hack but meh...)
        server_.timeout = _get_timeout(request=request)
        server_.address = (pytest.saltyrtc.host, port)

        _server_instances.append(server_)

        def fin():
            server_.close()
            event_loop.run_until_complete(server_.wait_closed())
            _server_instances.remove(server_)
            if len(_server_instances) == 0:
                logging_handler.pop_application()

        request.addfinalizer(fin)
        return server_
    return _server_factory 
开发者ID:saltyrtc,项目名称:saltyrtc-server-python,代码行数:54,代码来源:conftest.py


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