本文整理匯總了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
#
示例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 = {}
示例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
示例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")
示例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)
示例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,
)
示例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
示例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
}
示例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