Python logbook.StderrHandler() Examples
The following are 9
code examples of logbook.StderrHandler().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
logbook
, or try the search function
.
Example #1
Source File: doubleMA.py From zipline-chinese with Apache License 2.0 | 6 votes |
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 #
Example #2
Source File: callback_server.py From threema-msgapi-sdk-python with MIT License | 6 votes |
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 = {}
Example #3
Source File: bin.py From saltyrtc-server-python with MIT License | 5 votes |
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
Example #4
Source File: common.py From postgresql-metrics with Apache License 2.0 | 5 votes |
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")
Example #5
Source File: logging.py From flask-restapi-recipe with MIT License | 5 votes |
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)
Example #6
Source File: __main__.py From catalyst with Apache License 2.0 | 5 votes |
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, )
Example #7
Source File: __init__.py From srep with GNU General Public License v3.0 | 5 votes |
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
Example #8
Source File: gateway_client.py From threema-msgapi-sdk-python with MIT License | 5 votes |
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 }
Example #9
Source File: conftest.py From saltyrtc-server-python with MIT License | 4 votes |
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