import logging


def get_stream_logger(file=None, level=logging.INFO):
	"""Return logger with configured StreamHandler."""
	stream_logger = logging.getLogger('stream_logger')
	stream_logger.handlers = []
	stream_logger.setLevel(level)
	if not file:
		sh = logging.StreamHandler()
	else:
		sh = logging.FileHandler(file)

	sh.setLevel(level)
	fmt = '[%(asctime)s %(levelname)-8s %(processName)s] --- %(message)s'
	formatter = logging.Formatter(fmt)
	sh.setFormatter(formatter)
	stream_logger.addHandler(sh)

	return stream_logger