Update formatting to comply with black code style

This commit is contained in:
Bruno Alla 2019-03-19 20:31:47 +00:00
parent 05113c2a8a
commit b149c9933d
3 changed files with 59 additions and 66 deletions

View File

@ -198,95 +198,84 @@ AWS_PRELOAD_METADATA = True
# performed by this configuration is to send an email to # performed by this configuration is to send an email to
# the site admins on every HTTP 500 error when DEBUG=False. # the site admins on every HTTP 500 error when DEBUG=False.
LOGGING = { LOGGING = {
'version': 1, "version": 1,
'disable_existing_loggers': False, "disable_existing_loggers": False,
'filters': { "filters": {"require_debug_false": {"()": "django.utils.log.RequireDebugFalse"}},
'require_debug_false': { "formatters": {
'()': 'django.utils.log.RequireDebugFalse' "verbose": {
"format": "%(levelname)s %(asctime)s %(module)s "
"%(process)d %(thread)d %(message)s"
} }
}, },
'formatters': { "handlers": {
'verbose': { "mail_admins": {
'format': '%(levelname)s %(asctime)s %(module)s ' "level": "ERROR",
'%(process)d %(thread)d %(message)s' "filters": ["require_debug_false"],
"class": "django.utils.log.AdminEmailHandler",
},
"console": {
"level": "DEBUG",
"class": "logging.StreamHandler",
"formatter": "verbose",
}, },
}, },
'handlers': { "loggers": {
'mail_admins': { "django.request": {
'level': 'ERROR', "handlers": ["mail_admins"],
'filters': ['require_debug_false'], "level": "ERROR",
'class': 'django.utils.log.AdminEmailHandler' "propagate": True,
}, },
'console': { "django.security.DisallowedHost": {
'level': 'DEBUG', "level": "ERROR",
'class': 'logging.StreamHandler', "handlers": ["console", "mail_admins"],
'formatter': 'verbose', "propagate": True,
}, },
}, },
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True
},
'django.security.DisallowedHost': {
'level': 'ERROR',
'handlers': ['console', 'mail_admins'],
'propagate': True
}
}
} }
{% else %} {% else %}
LOGGING = { LOGGING = {
'version': 1, "version": 1,
'disable_existing_loggers': True, "disable_existing_loggers": True,
'formatters': { "formatters": {
'verbose': { "verbose": {
'format': '%(levelname)s %(asctime)s %(module)s ' "format": "%(levelname)s %(asctime)s %(module)s "
'%(process)d %(thread)d %(message)s' "%(process)d %(thread)d %(message)s"
},
},
'handlers': {
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'verbose'
} }
}, },
'loggers': { "handlers": {
'django.db.backends': { "console": {
'level': 'ERROR', "level": "DEBUG",
'handlers': ['console'], "class": "logging.StreamHandler",
'propagate': False, "formatter": "verbose",
}
},
"loggers": {
"django.db.backends": {
"level": "ERROR",
"handlers": ["console"],
"propagate": False,
}, },
# Errors logged by the SDK itself # Errors logged by the SDK itself
'sentry_sdk': { "sentry_sdk": {"level": "ERROR", "handlers": ["console"], "propagate": False},
'level': 'ERROR', "django.security.DisallowedHost": {
'handlers': ['console'], "level": "ERROR",
'propagate': False, "handlers": ["console"],
}, "propagate": False,
'django.security.DisallowedHost': {
'level': 'ERROR',
'handlers': ['console'],
'propagate': False,
}, },
}, },
} }
# Sentry # Sentry
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
SENTRY_DSN = env('SENTRY_DSN') SENTRY_DSN = env("SENTRY_DSN")
SENTRY_LOG_LEVEL = env.int('DJANGO_SENTRY_LOG_LEVEL', logging.INFO) SENTRY_LOG_LEVEL = env.int("DJANGO_SENTRY_LOG_LEVEL", logging.INFO)
sentry_logging = LoggingIntegration( sentry_logging = LoggingIntegration(
level=SENTRY_LOG_LEVEL, # Capture info and above as breadcrumbs level=SENTRY_LOG_LEVEL, # Capture info and above as breadcrumbs
event_level=None, # Send no events from log messages event_level=None, # Send no events from log messages
) )
sentry_sdk.init( sentry_sdk.init(dsn=SENTRY_DSN, integrations=[sentry_logging, DjangoIntegration()])
dsn=SENTRY_DSN,
integrations=[sentry_logging, DjangoIntegration()]
)
{% endif %} {% endif %}
# Your stuff... # Your stuff...
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------

View File

@ -20,8 +20,8 @@ from django.core.wsgi import get_wsgi_application
# This allows easy placement of apps within the interior # This allows easy placement of apps within the interior
# {{ cookiecutter.project_slug }} directory. # {{ cookiecutter.project_slug }} directory.
app_path = os.path.abspath(os.path.join( app_path = os.path.abspath(
os.path.dirname(os.path.abspath(__file__)), os.pardir) os.path.join(os.path.dirname(os.path.abspath(__file__)), os.pardir)
) )
sys.path.append(os.path.join(app_path, "{{ cookiecutter.project_slug }}")) sys.path.append(os.path.join(app_path, "{{ cookiecutter.project_slug }}"))
# We defer to a DJANGO_SETTINGS_MODULE already in the environment. This breaks # We defer to a DJANGO_SETTINGS_MODULE already in the environment. This breaks

View File

@ -41,6 +41,7 @@ class CeleryAppConfig(AppConfig):
import sentry_sdk import sentry_sdk
from sentry_sdk.integrations.celery import CeleryIntegration from sentry_sdk.integrations.celery import CeleryIntegration
from sentry_sdk.integrations.logging import LoggingIntegration from sentry_sdk.integrations.logging import LoggingIntegration
{% if cookiecutter.use_pycharm == 'y' -%} {% if cookiecutter.use_pycharm == 'y' -%}
# @formatter:on # @formatter:on
{%- endif %} {%- endif %}
@ -48,7 +49,10 @@ class CeleryAppConfig(AppConfig):
level=settings.SENTRY_LOG_LEVEL, # Capture info and above as breadcrumbs level=settings.SENTRY_LOG_LEVEL, # Capture info and above as breadcrumbs
event_level=None, # Send no events from log messages event_level=None, # Send no events from log messages
) )
sentry_sdk.init(dsn=settings.SENTRY_DSN, integrations=[sentry_logging, CeleryIntegration()]) sentry_sdk.init(
dsn=settings.SENTRY_DSN,
integrations=[sentry_logging, CeleryIntegration()],
)
{%- endif %} {%- endif %}