Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding DJANGO_DB_LOG_HANDLER and #233

Merged
merged 3 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ DB_TEST_NAME=test_imis
# Site root that will prefix all exposed endpoints. It's required when working with openIMIS frontend
SITE_ROOT=api
# Should the debug be on (i.e. debug information will be displayed)
DEBUG=True
MODE=DEV
# this will also show the DB request in the console
DJANGO_DB_LOG_HANDLER=console
# Photo path root used in insuree module. Only used if InsureeConfig value not specified. Comment out for default.
#PHOTO_ROOT_PATH=<photo path>
# Should the database be migrated before start (entrypoint.sh - docker setup). Will be migrated anyway if $SITE_ROOT=api. Comment out for False
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
| SITE_ROOT | String | Site root that will prefix all exposed endpoints. It's required when working with openIMIS frontend. For example, if the value is set `api` then the endpoint will appear like `your_domain_name/api/xxx` |
| DJANGO_LOG_LEVEL | INFO, WARNING, ERROR, DEBUG | Define the level of logs |
| DJANGO_LOG_HANDLER | console, debug-log | Depending on the value set, application will print the logs |
| DJANGO_DB_LOG_HANDLER | console, debug-log | Depending on the value set, application will print the logs |
| PHOTO_ROOT_PATH | String | Define the path for the photos of insurees. This setting is used in the Insuree module. The value set here will be overwritten by the InsureeConfig file. |
| DJANGO_MIGRATE | True, False | Based on the value set, application runs the migration command before starting up. If the SITE_ROOT value is set to api then the migration will always run regardless of the value |
| SCHEDULER_AUTOSTART | True, False | All the modules will be searched for the scheduled tasks, if the value is set to True |
Expand Down
12 changes: 9 additions & 3 deletions openIMIS/openIMIS/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,15 @@

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = os.environ.get("MODE", "PROD") == "DEV"

LOGGING_LEVEL = os.getenv("DJANGO_LOG_LEVEL", "DEBUG" if DEBUG else "WARNING")
DEFAULT_LOGGING_HANDLER = os.getenv("DJANGO_LOG_HANDLER", "console")
DEFAULT_DB_LOGGING_HANDLER = os.getenv("DJANGO_DB_LOG_HANDLER", "db-queries")
LOGGING_LEVEL = os.getenv("DJANGO_LOG_LEVEL", "DEBUG" if DEBUG else "WARNING")
if DEBUG:
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'





LOGGING = {
"version": 1,
Expand Down Expand Up @@ -59,7 +65,7 @@
"django.db.backends": {
"level": LOGGING_LEVEL,
"propagate": False,
"handlers": ["console" if os.environ.get("MODE", "PROD") == "DEV" else "db-queries"],
"handlers": [DEFAULT_DB_LOGGING_HANDLER],
},
"openIMIS": {
"level": LOGGING_LEVEL,
Expand Down
Loading