Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _init_logging():
# Redirect INFO or lower to stdout, WARNING or higher to stderr:
stdout = _WrappingStreamHandler(sys.stdout)
stdout.setLevel(logging.DEBUG)
stdout.addFilter(lambda record: record.levelno <= logging.INFO)
# Don't wrap stderr because it may contain stack traces:
stderr = logging.StreamHandler(sys.stderr)
stderr.setLevel(logging.WARNING)
logging.basicConfig(
level=logging.INFO, format='%(message)s', handlers=(stdout, stderr)
)