import logging


def level_from_verbosity(verbosity=3, maxlevel=logging.CRITICAL):
    """Return the logging level corresponding to the given verbosity."""
    return max(1,  # 0 disables it, so we use the next lowest.
               min(maxlevel,
                   maxlevel - verbosity * 10))