我们从Python开源项目中,提取了以下16个代码示例,用于说明如何使用logging.capturewarnings()。
def execute(self, *args, **options): if options['verbosity'] > 0: # ensure that deprecation warnings are displayed during testing # the following state is assumed: # logging.capturewarnings is true # a "default" level warnings filter has been added for # DeprecationWarning. See django.conf.LazySettings._configure_logging logger = logging.getLogger('py.warnings') handler = logging.StreamHandler() logger.addHandler(handler) super(Command, self).execute(*args, **options) if options['verbosity'] > 0: # remove the testing-specific handler logger.removeHandler(handler)
def run(self): if self.verbosity > 0: # ensure that deprecation warnings are displayed during testing # the following state is assumed: # logging.capturewarnings is true # a "default" level warnings filter has been added for # DeprecationWarning. See django.conf.LazySettings._configure_logging logger = logging.getLogger('py.warnings') handler = logging.StreamHandler() logger.addHandler(handler) TestCommand.run(self) if self.verbosity > 0: # remove the testing-specific handler logger.removeHandler(handler)
def execute(self, *args, **options): if int(options['verbosity']) > 0: # ensure that deprecation warnings are displayed during testing # the following state is assumed: # logging.capturewarnings is true # a "default" level warnings filter has been added for # DeprecationWarning. See django.conf.LazySettings._configure_logging logger = logging.getLogger('py.warnings') handler = logging.StreamHandler() logger.addHandler(handler) super(Command, self).execute(*args, **options) if int(options['verbosity']) > 0: # remove the testing-specific handler logger.removeHandler(handler)