:param logger: logging, a logging object
    :return: decorator, wraps exception loggers

def handle_exception(logger, **kw_decorator):
    """
    :param logger: logging, a logging object
    :return: decorator, wraps exception loggers
    """

    def decorator(query_func):
        @functools.wraps(query_func)
        def wrapper(*args, **kwargs):
            try:
                return query_func(*args, **kwargs)
            except Exception as e:
                logger.info('Exception in function {0} -- {1}'.format(query_func.__name__, e))
                if valid_dict(kw_decorator, ['subject', 'sender', 'username', 'password', 'host', 'receiver']):
                    logger.info('Now is sending the email with exception message')
                    t = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))
                    msg = t + ' ' + 'Exception in function {0} -- {1}'.format(query_func.__name__, e)
                    _send(subject=kw_decorator['subject'],
                          text=msg,
                          sender=kw_decorator['sender'],
                          username=kw_decorator['username'],
                          password=kw_decorator['password'],
                          host=kw_decorator['host'],
                          receiver=kw_decorator['receiver'])

                    logger.info('Email is sent')

        return wrapper

    return decorator