Skip to content

Commit

Permalink
chore: use app level logger
Browse files Browse the repository at this point in the history
  • Loading branch information
evanshortiss authored Oct 12, 2023
1 parent 595696e commit 80a4d4c
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions roshambo-ai/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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

0 comments on commit 80a4d4c

Please sign in to comment.