def convert_level(level, table):
    """ Convert logging levels using lookup table """
    try:
        return table[level][0]
    except KeyError:
        keys = table.keys()
        keys.sort()
        for key in keys:
            if level < key:
                return table[key][0]
        return table[keys[-1]][0]
