diff --git a/.env.example b/.env.example index da8390d6..3bc0787d 100644 --- a/.env.example +++ b/.env.example @@ -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= # Should the database be migrated before start (entrypoint.sh - docker setup). Will be migrated anyway if $SITE_ROOT=api. Comment out for False diff --git a/README.md b/README.md index 6332705a..e6351ff7 100644 --- a/README.md +++ b/README.md @@ -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 | diff --git a/openIMIS/openIMIS/settings.py b/openIMIS/openIMIS/settings.py index f7e157dc..9da25359 100644 --- a/openIMIS/openIMIS/settings.py +++ b/openIMIS/openIMIS/settings.py @@ -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, @@ -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,