Skip to content

Commit

Permalink
upgrage python and django versions with logging (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
NileshPant1999 authored Oct 23, 2023
1 parent 6e234e5 commit 9cc952e
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Pull python base image
FROM python:3.10-slim
FROM python:3.11-slim

# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
Expand Down
12 changes: 6 additions & 6 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ croniter==1.3.8
cryptography==38.0.3

# Django and Django REST Framework
Django==3.1.2
django-cors-headers==3.2.0
Django==4.1.2
django-cors-headers==4.3.0
django-rest-framework==0.1.0
djangorestframework==3.14.0
django-db-geventpool==4.0.1
django-request-logging==0.7.1
django-request-logging==0.7.5
django-filter==21.1

# DjangoQ for running async tasks
django-q==1.3.4
django-q2==1.6.1

# Read Database Credentials as URL
dj-database-url==0.5.0
Expand All @@ -29,10 +29,10 @@ fyle==0.30.0
# Reusable Fyle Packages
fyle-rest-auth==1.4.0
fyle-accounting-mappings==1.26.0
fyle-integrations-platform-connector==1.30.0
fyle-integrations-platform-connector==1.35.3

# Postgres Dependincies
psycopg2-binary==2.8.4
psycopg2-binary==2.9.9

# Pylint
pylint==2.7.4
Expand Down
65 changes: 63 additions & 2 deletions sage_desktop_api/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,7 @@
MIDDLEWARE = [
'request_logging.middleware.LoggingMiddleware',
'corsheaders.middleware.CorsMiddleware',
'corsheaders.middleware.CorsPostCsrfMiddleware',
'django.middleware.common.CommonMiddleware',
'corsheaders.middleware.CorsPostCsrfMiddleware',
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
Expand Down Expand Up @@ -116,6 +114,69 @@
'PAGE_SIZE': 100
}

SERVICE_NAME = os.environ.get('SERVICE_NAME')

LOGGING = {
'version': 1,
'disable_existing_loggers': True,
'formatters': {
'verbose': {
'format': '{levelname} %s {asctime} {module} {message} ' % SERVICE_NAME,
'style': '{',
},
'requests': {
'format': 'request {levelname} %s {asctime} {message}' % SERVICE_NAME,
'style': '{'
}
},
'handlers': {
'debug_logs': {
'class': 'logging.StreamHandler',
'stream': sys.stdout,
'formatter': 'verbose'
},
'request_logs': {
'class': 'logging.StreamHandler',
'stream': sys.stdout,
'formatter': 'requests'
},
},
'loggers': {
'django': {
'handlers': ['request_logs'],
'propagate': True,
},
'django.request': {
'handlers': ['request_logs'],
'propagate': False
},
'fyle_intacct_api': {
'handlers': ['debug_logs'],
'level': 'ERROR',
'propagate': False
},
'apps': {
'handlers': ['debug_logs'],
'level': 'ERROR',
'propagate': False
},
'django_q': {
'handlers': ['debug_logs'],
'propagate': True,
},
'fyle_integrations_platform_connector': {
'handlers': ['debug_logs'],
'propagate': True,
},
'gunicorn': {
'handlers': ['request_logs'],
'level': 'INFO',
'propagate': False
}
}
}



CACHES = {
'default': {
Expand Down
3 changes: 1 addition & 2 deletions sage_desktop_api/tests/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,9 @@
MIDDLEWARE = [
'request_logging.middleware.LoggingMiddleware',
'corsheaders.middleware.CorsMiddleware',
'corsheaders.middleware.CorsPostCsrfMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
Expand Down

0 comments on commit 9cc952e

Please sign in to comment.