Skip to content

Commit

Permalink
Configure logging
Browse files Browse the repository at this point in the history
  • Loading branch information
joe-nghiem-goldenowl committed Dec 25, 2023
1 parent 58b0c45 commit 037c2d0
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
26 changes: 26 additions & 0 deletions django_template/settings/dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,29 @@
MIDDLEWARE.index("django.middleware.common.CommonMiddleware") + 1,
"debug_toolbar.middleware.DebugToolbarMiddleware",
)

# Logging
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'standard': {
'format': "[%(asctime)s] %(levelname)s [%(name)s:%(lineno)s] %(message)s",
'datefmt': "%d/%b/%Y %H:%M:%S"
},
},
'handlers': {
'console': {
'level': 'INFO',
'class': 'logging.StreamHandler',
'formatter': 'standard'
},
},
'loggers': {
'django': {
'handlers': ['console'],
'propagate': True,
'level': 'INFO',
},
}
}
36 changes: 36 additions & 0 deletions django_template/settings/prod.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,39 @@
),
],
)

# Logging
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'standard': {
'format': "[%(asctime)s] %(levelname)s [%(name)s:%(lineno)s] %(message)s",
'datefmt': "%d/%b/%Y %H:%M:%S"
},
},
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'handlers': {
'console': {
'level': 'INFO',
'class': 'logging.StreamHandler',
'formatter': 'standard'
},
'sentry': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'raven.contrib.django.handlers.SentryHandler',
},
},
'loggers': {
'django': {
'handlers': ['console', 'sentry'],
'propagate': True,
'level': 'INFO',
},
}
}

0 comments on commit 037c2d0

Please sign in to comment.