Skip to content

why can't filter 'DeprecationWarning' that is generated by warnings #6352

@15554710621

Description

@15554710621

import logging
import warnings
class stringFilter(logging.Filter):
def filter(self, record):
if record.msg.find('DeprecationWarning') == -1:
return True
return False

logging.basicConfig(level=logging.INFO)
logging.captureWarnings(True)
warnings_logger = logging.getLogger("py.warnings")
warnings_logger.setLevel(logging.INFO)
warnings_logger.addFilter(stringFilter())

warnings.warn('DeprecationWarning')

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions