use flask logging
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Torma Kristóf 2020-09-20 02:19:14 +02:00
parent d3a8057820
commit 9a7258cb4d
Signed by: tormakris
GPG Key ID: DC83C4F2C41B1047

View File

@ -9,6 +9,7 @@ from db import db
from models import SampleMetadata
from schemas import SampleSchema, SampleMetadataSchema
from config import *
from app import app
from fpika import fpika
"""
@ -20,8 +21,6 @@ __copyright__ = "Copyright 2020, Birbnetes Team"
__module_name__ = "endpoints"
__version__text__ = "1"
LOGGER = logging.getLogger(__name__)
class SampleResource(Resource):
"""
@ -48,14 +47,14 @@ class SampleResource(Resource):
description = request.form.get("description")
if soundfile.content_type != 'audio/wave':
LOGGER.info(
app.logger.info(
f"Input file was not WAV.")
return {'err_msg': 'Input file not a wave file.'}, 415
try:
desc = self.sampleschema.loads(description)
except Exception as e:
LOGGER.exception(e)
app.logger.exception(e)
return {'err_msg': 'Input JSON schema invalid'}, 417
xeger = Xeger(limit=30)
@ -81,7 +80,7 @@ class SampleResource(Resource):
body=json.dumps({'tag': generated_tag}).encode('UTF-8'))
fpika.return_channel(ch)
except Exception as e:
LOGGER.exception(e)
app.logger.exception(e)
db.session.rollback()
return {"err_msg": str(
e), "hint": "DB or downstream service error"}, 569