Skip to content

Commit

Permalink
Add logging for development and support for .env file
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-s committed Oct 29, 2020
1 parent 4348109 commit 16f9435
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .env-example
@@ -0,0 +1,8 @@
# env variables in dbbackup/tests/settings.py
DB_ENGINE
DB_NAME
DB_USER
DB_PASSWORD
DB_HOST
CONNECTOR
DJANGO_LOG_LEVEL=DEBUG
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -7,6 +7,7 @@ __pycache__/

# Distribution / packaging
.Python
.env
env/
build/
develop-eggs/
Expand Down Expand Up @@ -62,3 +63,4 @@ target/
.idea/
*.sw[po]
test-sqlite
venv
34 changes: 34 additions & 0 deletions dbbackup/tests/settings.py
Expand Up @@ -3,6 +3,8 @@
"""
import os
import tempfile
from dotenv import load_dotenv
load_dotenv()

DEBUG = False

Expand Down Expand Up @@ -50,3 +52,35 @@
DBBACKUP_STORAGE_OPTIONS = dict([keyvalue.split('=') for keyvalue in
os.environ.get('STORAGE_OPTIONS', '').split(',')
if keyvalue])

LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'root': {
'handlers': ['console'],
'level': 'DEBUG'
},
'handlers': {
'console': {
'level': os.getenv('DJANGO_LOG_LEVEL', 'INFO'),
'class': 'logging.StreamHandler',
'formatter': 'simple'
}
},
'formatters': {
'verbose': {
'format': "[%(asctime)s] %(levelname)s [%(name)s:%(lineno)s] %(message)s",
'datefmt': "%d/%b/%Y %H:%M:%S"
},
'simple': {
'format': '%(levelname)s %(message)s'
},
},
'loggers': {
'django.db.backends': {
# uncomment to see all queries
# 'level': 'DEBUG',
'handlers': ['console'],
}
}
}
2 changes: 2 additions & 0 deletions requirements-tests.txt
Expand Up @@ -7,3 +7,5 @@ django-storages
pytz
testfixtures
mock
python-dotenv
psycopg2

0 comments on commit 16f9435

Please sign in to comment.