mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-13 04:59:59 +02:00
linter errors
This commit is contained in:
parent
180a0240e5
commit
d33f9ae8e2
1 changed files with 6 additions and 7 deletions
|
@ -451,6 +451,7 @@ PHONENUMBER_DEFAULT_REGION = "US"
|
||||||
|
|
||||||
class JsonFormatter(logging.Formatter):
|
class JsonFormatter(logging.Formatter):
|
||||||
"""Formats logs into JSON for better parsing"""
|
"""Formats logs into JSON for better parsing"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__(datefmt="%d/%b/%Y %H:%M:%S")
|
super().__init__(datefmt="%d/%b/%Y %H:%M:%S")
|
||||||
|
|
||||||
|
@ -467,21 +468,19 @@ class JsonFormatter(logging.Formatter):
|
||||||
|
|
||||||
class JsonServerFormatter(ServerFormatter):
|
class JsonServerFormatter(ServerFormatter):
|
||||||
"""Formats server logs into JSON for better parsing"""
|
"""Formats server logs into JSON for better parsing"""
|
||||||
|
|
||||||
def format(self, record):
|
def format(self, record):
|
||||||
formatted_record = super().format(record)
|
formatted_record = super().format(record)
|
||||||
log_entry = {
|
log_entry = {"server_time": record.server_time, "level": record.levelname, "message": formatted_record}
|
||||||
"server_time": record.server_time,
|
|
||||||
"level": record.levelname,
|
|
||||||
"message": formatted_record
|
|
||||||
}
|
|
||||||
return json.dumps(log_entry)
|
return json.dumps(log_entry)
|
||||||
|
|
||||||
|
|
||||||
# default to json formatted logs
|
# default to json formatted logs
|
||||||
server_formatter, console_formatter = 'json.server', 'json'
|
server_formatter, console_formatter = "json.server", "json"
|
||||||
|
|
||||||
# don't use json format locally, it makes logs hard to read in console
|
# don't use json format locally, it makes logs hard to read in console
|
||||||
if "localhost" in env_base_url:
|
if "localhost" in env_base_url:
|
||||||
server_formatter, console_formatter = 'django.server', 'verbose'
|
server_formatter, console_formatter = "django.server", "verbose"
|
||||||
|
|
||||||
LOGGING = {
|
LOGGING = {
|
||||||
"version": 1,
|
"version": 1,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue