aboutsummaryrefslogtreecommitdiff
"""Debug utilities"""
import logging
import importlib.util

__this_module_name__ = __name__


# pylint: disable=invalid-name
def getLogger(name: str):
    """Return a logger"""
    flask_spec = importlib.util.find_spec("flask")
    if bool(flask_spec):
        current_app = importlib.import_module("flask").current_app
        return (
            logging.getLogger(name)
            if not bool(current_app)
            else current_app.logger)

    return logging.getLogger(name)


def __pk__(*args):
    """Format log entry"""
    value = args[-1]
    title_vals = " => ".join(args[0:-1])
    logger = getLogger(__this_module_name__)
    logger.debug("%s: %s", title_vals, value)
    return value