From b5c2536eedb4d360f54985e002b9184fe8631f41 Mon Sep 17 00:00:00 2001 From: adorda <adorda@boletinoficial.gob.ar> Date: Tue, 26 Feb 2019 16:45:57 -0300 Subject: [PATCH] =?UTF-8?q?Agregados=20un=20par=20de=20logs=20a=20la=20apl?= =?UTF-8?q?icaci=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views.py | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/app/views.py b/app/views.py index d5f8a2c..2642b5b 100644 --- a/app/views.py +++ b/app/views.py @@ -8,21 +8,23 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/ """ import base64 +import logging + +import coreapi +import coreschema from django.core.exceptions import ValidationError from django.utils.translation import gettext as _ +from raven.contrib.django.raven_compat.models import client from rest_framework import status -from rest_framework.views import APIView from rest_framework.response import Response -from web3.exceptions import CannotHandleRequest -from raven.contrib.django.raven_compat.models import client from rest_framework.schemas import ManualSchema -import coreschema, coreapi +from rest_framework.views import APIView +from web3.exceptions import CannotHandleRequest +from TsaApi.local_settings import PERMANENT_OTS_PREFIX from app.managers import TimestampManager -from app.services import VerifyService, VerifyServiceTranslation +from app.services import VerifyServiceTranslation from app.utils import Utils -from TsaApi.local_settings import TEMPORARY_OTS_PREFIX, PERMANENT_OTS_PREFIX, CONTRACTS -import logging logger = logging.getLogger('logger') @@ -65,8 +67,9 @@ class Stamp(APIView): ots_hash = Utils.get_ots_hash(file_hash) + logger.info("Haciendo stamp para hash: {} ots: {} ".format(file_hash, ots_hash)) tx_hash = TimestampManager.stamp(ots_hash, file_hash) - + logger.info("Stamp para hash: {} ots: {} terminado, tx_hash : {}".format(file_hash, ots_hash, tx_hash.hex())) # Al OTS se le agrega la transacción para poder verificar luego si está pendiente de subida ots = Utils.get_temporary_ots(ots_hash, tx_hash.hex()) @@ -139,16 +142,20 @@ class Verify(APIView): # importante la asignación del prefijo de ots permanente self.verify_service.verify_service.permanent_ots_prefix = PERMANENT_OTS_PREFIX + logger.info("Iniciando verificacion para hash {} rd {} baserd {}".format(original_file_hash, rd, base64_rd)) result, res_status = self.verify_service.verify(original_file_hash, rd) - + logger.info( + "Verificacion terminada para hash {} rd {}, resultado {}".format(original_file_hash, rd, str(result))) return Response(result, status=res_status) except ValidationError as e: return Response({_('status'): _('failure'), _('messages'): _('parameter_missing') % e.message}, status=status.HTTP_400_BAD_REQUEST) - except CannotHandleRequest: + except CannotHandleRequest as e: + logger.critical('Servicio a nivel Geth no disponible!! error: {}'.format(str(e))) return Response({_('status'): _('failure'), _('messages'): _('could_not_connect')}, status=status.HTTP_503_SERVICE_UNAVAILABLE) except Exception as e: client.captureException() + logger.error('Error interno en la verificacion : {}'.format(str(e))) return Response({_('status'): _('failure'), _('messages'): _('operation_failed')}, - status=status.HTTP_500_INTERNAL_SERVER_ERROR) \ No newline at end of file + status=status.HTTP_500_INTERNAL_SERVER_ERROR) -- GitLab