diff --git a/game.py b/game.py index 5b43adb..50a814a 100755 --- a/game.py +++ b/game.py @@ -5,7 +5,6 @@ from flask import Flask, render_template, request from configparser import ConfigParser from datetime import datetime import random -import logging import pytz app = Flask(__name__, @@ -15,51 +14,8 @@ app = Flask(__name__, config = ConfigParser() config.read('config.ini') -logging.basicConfig(encoding='utf-8', level=logging.INFO, format='%(message)s') -logger = logging.getLogger('waitress') tz = pytz.timezone(config.get('main', 'timezone')) -@app.after_request -def log_the_request(response): - now = datetime.now(tz=tz) - - if 'X-Forwarded-For' in request.headers: - remote_addr = request.headers['X-Forwarded-For'] - else: - remote_addr = request.remote_addr - - if not request.remote_user: - remote_user = "-" - else: - remote_user = request.remote_user - - if not request.referrer: - referrer = "-" - else: - referrer = request.referrer - - if request.full_path[-1] == '?': - full_path = request.full_path[:-1] - else: - full_path = request.full_path - - log = { - 'remote_addr': remote_addr, - 'remote_user': remote_user, - 'url': full_path, - 'date': now.strftime("%d/%b/%Y:%H:%M:%S %z"), - 'referrer': referrer, - 'user_agent': request.user_agent.string, - 'method': request.method, - 'content_length': response.content_length, - 'status_code': response.status_code - } - - logfile = "{} - {} [{}] \"{} {}\" {} {} \"{}\" \"{}\"".format(log['remote_addr'], log['remote_user'], log['date'], log['method'], log['url'], log['status_code'], log['content_length'], log['referrer'], log['user_agent']) - logger.info(logfile) - - return response - @app.errorhandler(404) def page_not_found(e): lang = config.get('i18n', 'lang') @@ -104,7 +60,7 @@ def hello(): lines = getContent() while len(lines) < 2: - logger.error('Error reading content') + print('Error reading content') print(lines) lines = getContent() diff --git a/supervisor.conf b/supervisor.conf index 3dc9874..c05e49c 100644 --- a/supervisor.conf +++ b/supervisor.conf @@ -4,6 +4,6 @@ directory=/opt/ab/ autostart=true autorestart=true redirect_stderr=true -stdout_logfile_maxbytes=32MB +stdout_logfile_maxbytes=1MB stdout_logfile_backups=10 user=www-data