def log_to_stream(name=None, stream=None, format=None, level=None, debug=False):
 if (level is None):
  level = (logging.DEBUG if debug else logging.INFO)
 if (format is None):
  format = '%(message)s'
 if (stream is None):
  stream = sys.stderr
 handler = logging.StreamHandler(stream)
 handler.setLevel(level)
 handler.setFormatter(logging.Formatter(format))
 logger = logging.getLogger(name)
 logger.setLevel(level)
 logger.addHandler(handler)

def log_to_stream ( name = None , stream = None , format = None , level = None , debug = False ) : if ( level is None ) : level = ( logging . DEBUG if debug else logging . INFO ) if ( format is None ) : format = '%(message)s' if ( stream is None ) : stream = sys . stderr handler = logging . StreamHandler ( stream ) handler . setLevel ( level ) handler . setFormatter ( logging . Formatter ( format ) ) logger = logging . getLogger ( name ) logger . setLevel ( level ) logger . addHandler ( handler )
set up logging .