def audit_log(action, entity, message):
    """
    Logs given action
    :param action: The action being logged e.g. assign_role, create_role etc
    :param entity: The entity undergoing the action e.g. name of the role
    :param message: Additional info e.g. Role being assigned to user X
    :return:
    """

    user = g.current_user.email if hasattr(g, 'current_user') else "LEMUR"
    log_data = {
        "function": "lemur-audit",
        "action": action,
        "user": user,
        "entity": entity,
        "details": message,
        "message": f"[lemur-audit] action: {action}, user: {user}, entity: {entity}, details: {message}."
    }
    # format before August 2021: f"[lemur-audit] action: {action}, user: {user}, entity: {entity}, details: {message}"
    current_app.logger.info(log_data)

    Logs given action
    :param action: The action being logged e.g. assign_role, create_role etc
    :param entity: The entity undergoing the action e.g. name of the role
    :param message: Additional info e.g. Role being assigned to user X
    :return:
    
lemur/logs/service.py