#!/usr/bin/env python # encoding: utf-8 # # Copyright (c) 2008 Doug Hellmann All rights reserved. # """ """ #end_pymotw_header import warnings import logging logging.basicConfig(level=logging.INFO) def send_warnings_to_log(message, category, filename, lineno, file=None): logging.warning( '%s:%s: %s:%s' % (filename, lineno, category.__name__, message)) return old_showwarning = warnings.showwarning warnings.showwarning = send_warnings_to_log warnings.warn('This is a warning message')