Codebase list loguru / 0297b4a1-5a4e-4a8d-bb2f-ef1cf5dea31f/upstream loguru / _filters.py
0297b4a1-5a4e-4a8d-bb2f-ef1cf5dea31f/upstream

Tree @0297b4a1-5a4e-4a8d-bb2f-ef1cf5dea31f/upstream (Download .tar.gz)

_filters.py @0297b4a1-5a4e-4a8d-bb2f-ef1cf5dea31f/upstreamraw · history · blame

def filter_none(record):
    return record["name"] is not None


def filter_by_name(record, parent, length):
    name = record["name"]
    if name is None:
        return False
    return (name + ".")[:length] == parent


def filter_by_level(record, level_per_module):
    name = record["name"]

    while True:
        level = level_per_module.get(name, None)
        if level is False:
            return False
        if level is not None:
            return record["level"].no >= level
        if not name:
            return True
        index = name.rfind(".")
        name = name[:index] if index != -1 else ""