def enable_loggly(graph):
    """
    Enable loggly if it is configured and not debug/testing.

    """
    if graph.metadata.debug or graph.metadata.testing:
        return False
    try:
        if not graph.config.logging.loggly.token:
            return False
        if not graph.config.logging.loggly.environment:
            return False
    except AttributeError:
        return False
    return True
