Skip to content

Commit

Permalink
integrated sentry & added custom logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Amark19 committed May 5, 2024
1 parent b4618ef commit 0d4f0ce
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
12 changes: 12 additions & 0 deletions basicsite/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"""

import os
import sentry_sdk

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
Expand Down Expand Up @@ -158,3 +159,14 @@ def get_cache():


CACHES = get_cache()

sentry_sdk.init(
dsn=os.environ.get('SENTRY_DSN'),
# Set traces_sample_rate to 1.0 to capture 100%
# of transactions for performance monitoring.
traces_sample_rate=1.0,
# Set profiles_sample_rate to 1.0 to profile 100%
# of sampled transactions.
# We recommend adjusting this value in production.
profiles_sample_rate=1.0,
)
7 changes: 6 additions & 1 deletion mysite/Services/TextService.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import langdetect
from pycountry import languages
import translators as ts
import logging


def detect_language(text):
Expand All @@ -10,5 +11,9 @@ def detect_language(text):


def translate_text(text, src='auto', target='en'):
translated_text = ts.translate_text(text, from_language=src, to_language=target)
try:
translated_text = ts.translate_text(text, from_language=None, to_language=target)
except Exception as e:
logging.error(e)
translated_text = "There is some Error while processing, can be due to invalid input such as blank space"
return translated_text
Binary file modified requirements.txt
Binary file not shown.

0 comments on commit 0d4f0ce

Please sign in to comment.