def logger(height=1):                 # http://stackoverflow.com/a/900404/48251
    """
    Obtain a function logger for the calling function. Uses the inspect module
    to find the name of the calling function and its position in the module
    hierarchy. With the optional height argument, logs for caller's caller, and
    so forth.
    """
    caller = inspect.stack()[height]
    scope = caller[0].f_globals
    function = caller[3]
    path = scope["__name__"]
    if path == "__main__" and scope["__package__"]:
        path = scope["__package__"]
    return logging.getLogger(path + "." + function + "()")
Obtain a function logger for the calling function. Uses the inspect module
    to find the name of the calling function and its position in the module
    hierarchy. With the optional height argument, logs for caller's caller, and
    so forth.