@server_blueprint.route('/log')
@login_required
def listen_log():

    def followLog(serverLogsDir):
        logFilePattern = '*_DebugLog-server.txt'
        logFiles = glob.glob(path.join(serverLogsDir, logFilePattern))
        if (not logFiles):
            (yield 'data: {}\n\n'.format(json.dumps({'error': True, 'errorMessage': 'No log file found'})))
            return
        logFiles.sort(reverse=True)
        with open(logFiles[0]) as serverLogFile:
            try:
                while True:
                    line = serverLogFile.readline()
                    if (not line):
                        continue
                    time.sleep(0.01)
                    (yield 'data: {}\n\n'.format(json.dumps({'log': line.strip()})))
            finally:
                pass
    serverLogsDir = current_app.config['PZ_SERVER_LOGS_DIR']
    return Response(followLog(serverLogsDir), mimetype='text/event-stream')
@server_blueprint.route('/log')
@login_required
def listen_log():

    def followLog(serverLogsDir):
        logFilePattern = '*_DebugLog-server.txt'
        logFiles = glob.glob(path.join(serverLogsDir, logFilePattern))
        if (not logFiles):
            (yield 'data: {}\n\n'.format(json.dumps({'error': True, 'errorMessage': 'No log file found'})))
            return
        logFiles.sort(reverse=True)
        with open(logFiles[0]) as serverLogFile:
            try:
                while True:
                    line = serverLogFile.readline()
                    if (not line):
                        continue
                    time.sleep(0.01)
                    (yield 'data: {}\n\n'.format(json.dumps({'log': line.strip()})))
            finally:
                pass
    serverLogsDir = current_app.config['PZ_SERVER_LOGS_DIR']
    return Response(followLog(serverLogsDir), mimetype='text/event-stream')