import inspect
import logging


def get_logger(name=None):
    """Return a logger named `name` if specified, otherwise use the name
    of the calling context.
    """
    if name is None:
        name = inspect.stack()[1][3]
        # code = inspect.currentframe().f_back.f_code
        # func = [obj for obj in gc.get_referrers(code)][0]
        # name = func.__qualname__
    return logging.getLogger(name)