Skip to content

Commit 5f22342

Browse files
authored
Merge pull request #233 from openimis/delcroip-patch-1
Adding DJANGO_DB_LOG_HANDLER and
2 parents 287668e + 0e5cc63 commit 5f22342

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

.env.example

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ DB_TEST_NAME=test_imis
2121
# Site root that will prefix all exposed endpoints. It's required when working with openIMIS frontend
2222
SITE_ROOT=api
2323
# Should the debug be on (i.e. debug information will be displayed)
24-
DEBUG=True
24+
MODE=DEV
25+
# this will also show the DB request in the console
26+
DJANGO_DB_LOG_HANDLER=console
2527
# Photo path root used in insuree module. Only used if InsureeConfig value not specified. Comment out for default.
2628
#PHOTO_ROOT_PATH=<photo path>
2729
# Should the database be migrated before start (entrypoint.sh - docker setup). Will be migrated anyway if $SITE_ROOT=api. Comment out for False

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
| 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` |
2020
| DJANGO_LOG_LEVEL | INFO, WARNING, ERROR, DEBUG | Define the level of logs |
2121
| DJANGO_LOG_HANDLER | console, debug-log | Depending on the value set, application will print the logs |
22+
| DJANGO_DB_LOG_HANDLER | console, debug-log | Depending on the value set, application will print the logs |
2223
| 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. |
2324
| 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 |
2425
| SCHEDULER_AUTOSTART | True, False | All the modules will be searched for the scheduled tasks, if the value is set to True |

openIMIS/openIMIS/settings.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,15 @@
2121

2222
# SECURITY WARNING: don't run with debug turned on in production!
2323
DEBUG = os.environ.get("MODE", "PROD") == "DEV"
24-
25-
LOGGING_LEVEL = os.getenv("DJANGO_LOG_LEVEL", "DEBUG" if DEBUG else "WARNING")
2624
DEFAULT_LOGGING_HANDLER = os.getenv("DJANGO_LOG_HANDLER", "console")
25+
DEFAULT_DB_LOGGING_HANDLER = os.getenv("DJANGO_DB_LOG_HANDLER", "db-queries")
26+
LOGGING_LEVEL = os.getenv("DJANGO_LOG_LEVEL", "DEBUG" if DEBUG else "WARNING")
27+
if DEBUG:
28+
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
29+
30+
31+
32+
2733

2834
LOGGING = {
2935
"version": 1,
@@ -59,7 +65,7 @@
5965
"django.db.backends": {
6066
"level": LOGGING_LEVEL,
6167
"propagate": False,
62-
"handlers": ["console" if os.environ.get("MODE", "PROD") == "DEV" else "db-queries"],
68+
"handlers": [DEFAULT_DB_LOGGING_HANDLER],
6369
},
6470
"openIMIS": {
6571
"level": LOGGING_LEVEL,

0 commit comments

Comments
 (0)