Stolen verbatim from django-zappa: 
        https://github.com/Miserlou/django-zappa/blob/master/django_zappa/management/commands/tail.py

def tail(environment, zappa_settings):
    """ Stolen verbatim from django-zappa: 
        https://github.com/Miserlou/django-zappa/blob/master/django_zappa/management/commands/tail.py
    """

    def print_logs(logs):

        for log in logs:
            timestamp = log['timestamp']
            message = log['message']
            if "START RequestId" in message:
                continue
            if "REPORT RequestId" in message:
                continue
            if "END RequestId" in message:
                continue

            print("[" + str(timestamp) + "] " + message.strip())

    zappa, settings, _, lambda_name = _init(environment, zappa_settings)

    try:
        # Tail the available logs
        all_logs = zappa.fetch_logs(lambda_name)
        print_logs(all_logs)

        # Keep polling, and print any new logs.
        while True:
            all_logs_again = zappa.fetch_logs(lambda_name)
            new_logs = []
            for log in all_logs_again:
                if log not in all_logs:
                    new_logs.append(log)

            print_logs(new_logs)
            all_logs = all_logs + new_logs
    except KeyboardInterrupt:
        # Die gracefully
        try:
            sys.exit(0)
        except SystemExit:
            os._exit(0)