def get_logging_level(level):
    logging_level = None
    if isinstance(level, (str, unicode)):
        level = level.upper()
        try:
            logging_level = getattr(logging, level.upper())
        except AttributeError:
            raise AttributeError('Tried to grab logging level "%s"'
                    ' but it does not exist' % level)
    elif isinstance(level, int):
        # Do nothing
        logging_level = level
    else:
        raise TypeError('Invalid logging level. Must be string or int %s'
                % str(level))
    return logging_level