<commit_before>from pyramid.httpexceptions import HTTPFound
from pyramid.response import Response
from pyramid.view import view_config
from sqlalchemy import func, desc
from sqlalchemy.orm import joinedload
from sqlalchemy.orm.exc import NoResultFound
from websauna.system.core.views.notfound import notfound

from enkiblog import models<commit_msg>added sentry exceptions logger listener<commit_after>from pyramid.httpexceptions import HTTPFound
from pyramid.response import Response
from pyramid.view import view_config
from sqlalchemy import func, desc
from sqlalchemy.orm import joinedload
from sqlalchemy.orm.exc import NoResultFound
from websauna.system.core.views.notfound import notfound

from enkiblog import models

from pyramid.events import subscriber
from websauna.system.core.events import InternalServerError
from websauna.system.core.loggingcapture import get_logging_user_context


# https://github.com/websauna/websauna.sentry/blob/master/websauna/sentry/subscribers.py#L14
@subscriber(InternalServerError)
def notify_raven(event):
    request = event.request
    user_context = get_logging_user_context(request)
    request.raven.user_context(user_context)
    request.raven.captureException()
{'fraction_non_alphanumeric': 0.05693069306930693, 'fraction_numerical': 0.0016501650165016502, 'mean_word_length': 6.628930817610063, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7111321', 'n_tokens_mistral': 364, 'n_tokens_neox': 335, 'n_words': 91}