mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-15 05:54:11 +02:00
Don't use json locally, plus review changes
This commit is contained in:
parent
bdec43e2f3
commit
eb3cb1e3d8
1 changed files with 2 additions and 18 deletions
|
@ -448,21 +448,8 @@ PHONENUMBER_DEFAULT_REGION = "US"
|
||||||
# logger.error("Can't do this important task. Something is very wrong.")
|
# logger.error("Can't do this important task. Something is very wrong.")
|
||||||
# logger.critical("Going to crash now.")
|
# logger.critical("Going to crash now.")
|
||||||
|
|
||||||
class JsonFormatter(logging.Formatter):
|
|
||||||
def __init__(self):
|
|
||||||
super().__init__(datefmt="%d/%b/%Y %H:%M:%S")
|
|
||||||
|
|
||||||
def format(self, record):
|
|
||||||
log_record = {
|
|
||||||
"timestamp": self.formatTime(record, self.datefmt),
|
|
||||||
"level": record.levelname,
|
|
||||||
"name": record.name,
|
|
||||||
"lineno": record.lineno,
|
|
||||||
"message": record.getMessage(),
|
|
||||||
}
|
|
||||||
return json.dumps(log_record)
|
|
||||||
|
|
||||||
class JsonServerFormatter(ServerFormatter):
|
class JsonServerFormatter(ServerFormatter):
|
||||||
|
"""Formats logs into JSON for easier and more accurate processing."""
|
||||||
def format(self, record):
|
def format(self, record):
|
||||||
formatted_record = super().format(record)
|
formatted_record = super().format(record)
|
||||||
log_entry = {
|
log_entry = {
|
||||||
|
@ -489,9 +476,6 @@ LOGGING = {
|
||||||
"json.server": {
|
"json.server": {
|
||||||
"()": JsonServerFormatter,
|
"()": JsonServerFormatter,
|
||||||
},
|
},
|
||||||
"json": {
|
|
||||||
"()": JsonFormatter,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
# define where log messages will be sent;
|
# define where log messages will be sent;
|
||||||
# each logger can have one or more handlers
|
# each logger can have one or more handlers
|
||||||
|
@ -499,7 +483,7 @@ LOGGING = {
|
||||||
"console": {
|
"console": {
|
||||||
"level": env_log_level,
|
"level": env_log_level,
|
||||||
"class": "logging.StreamHandler",
|
"class": "logging.StreamHandler",
|
||||||
"formatter": "json",
|
"formatter": "verbose",
|
||||||
},
|
},
|
||||||
"django.server": {
|
"django.server": {
|
||||||
"level": "INFO",
|
"level": "INFO",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue