• Facebook
  • Twitter
  • Reddit
  • StumbleUpon
  • Digg
  • email

All Samples(12)  |  Call(11)  |  Derive(0)  |  Import(1)
Hook to write a warning to a file; replace if you like.

        def _show_warning(message, category, filename, lineno, file=None, line=None):
    """Hook to write a warning to a file; replace if you like."""
    if file is None:
        file = sys.stderr
    try:
        file.write(formatwarning(message, category, filename, lineno, line))
    except IOError:
        pass # the file (probably stderr) is invalid - this warning gets lost.
        


src/g/o/gonium-HEAD/src/daemon.py   gonium(Download)
import sys
import logging
import warnings
from warnings import showwarning as showwarning_orig
 
_logger_warnings = logging.getLogger('warnings')
 
def _showwarning_logging(message, category, filename, lineno, file=None, *args,
      **kwargs):
   if not (file is None):
      showwarning_orig(message, category, filename, lineno, file, *args, **kwargs)
      return
 
   _logger_warnings.warn(formatwarning(message, category, filename, lineno,