From 80a4d4c4b5df4f5966dad5a6d60bb591e6bda507 Mon Sep 17 00:00:00 2001 From: Evan Shortiss Date: Thu, 12 Oct 2023 10:04:20 -0700 Subject: [PATCH] chore: use app level logger --- roshambo-ai/wsgi.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/roshambo-ai/wsgi.py b/roshambo-ai/wsgi.py index 453f8f5..a6b87f2 100644 --- a/roshambo-ai/wsgi.py +++ b/roshambo-ai/wsgi.py @@ -6,14 +6,14 @@ from prediction import predict log_level = os.getenv("LOG_LEVEL", "INFO").upper() -logging.basicConfig(level=log_level) -formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s') -handler = logging.StreamHandler() -handler.setFormatter(formatter) -logging.getLogger().addHandler(handler) application = Flask(__name__) +formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s') +handler = logging.StreamHandler() +handler.setFormatter(formatter) +app.logger.addHandler(handler) +app.logger.setLevel(log_level) @application.route('/') @application.route('/status') @@ -25,11 +25,11 @@ def status(): @application.route('/predictions', methods=['POST']) def create_prediction(): short_uuid = uuid.uuid4().hex[:8] - logging.info('prediction request received (ID:' + short_uuid + ')') + application.logger.info('prediction request received (ID:' + short_uuid + ')') data = request.data or '{}' body = json.loads(data) result = jsonify(predict(body)) - logging.info('prediction request complete (ID:' + short_uuid + ')') + application.logger.info('prediction request complete (ID:' + short_uuid + ')') return result