Adds optional config setting to enable database level logging (#5617)

This commit is contained in:
Oliver 2023-09-25 16:54:17 +10:00 committed by GitHub
parent 67b2d02a7f
commit dad240529d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 0 deletions

View File

@ -109,6 +109,14 @@ LOGGING = {
},
}
# Optionally add database-level logging
if get_setting('INVENTREE_DB_LOGGING', 'db_logging', False):
LOGGING['loggers'] = {
'django.db.backends': {
'level': log_level or 'DEBUG',
},
}
# Get a logger instance for this setup file
logger = logging.getLogger("inventree")

View File

@ -69,6 +69,10 @@ debug: True
# Options: DEBUG / INFO / WARNING / ERROR / CRITICAL
log_level: WARNING
# Enable database-level logging
# Use the environment variable INVENTREE_DB_LOGGING
db_logging: False
# Select default system language (default is 'en-us')
# Use the environment variable INVENTREE_LANGUAGE
language: en-us

View File

@ -4,6 +4,7 @@
# Set DEBUG to True for a development setup
INVENTREE_DEBUG=True
INVENTREE_LOG_LEVEL=INFO
INVENTREE_DB_LOGGING=False
# Database configuration options
# Note: The example setup is for a PostgreSQL database (change as required)

View File

@ -53,6 +53,7 @@ The following basic options are available:
| --- | --- | --- | --- |
| INVENTREE_DEBUG | debug | Enable [debug mode](./intro.md#debug-mode) | True |
| INVENTREE_LOG_LEVEL | log_level | Set level of logging to terminal | WARNING |
| INVENTREE_DB_LOGGING | db_logging | Enable logging of database messages | False |
| INVENTREE_TIMEZONE | timezone | Server timezone | UTC |
| ADMIN_URL | admin_url | URL for accessing [admin interface](../settings/admin.md) | admin |
| INVENTREE_LANGUAGE | language | Default language | en-us |