mirror of
https://github.com/ansible/awx.git
synced 2026-05-15 05:17:36 -02:30
Remove json formatter for job lifecycle
* We didn't really make use of json formatting across the app. Remove the special case json formatter. Instead, output all of the meta-data associated with a job lifecycle event every time. Before, we tried to only output this extra meta data when in DEBUG mode. It turns out this information is smaller than we thought and more useful than we thought so always output it.
This commit is contained in:
committed by
Chris Meyers
parent
4b6f7e0ebe
commit
d06ce8f911
@@ -1599,7 +1599,8 @@ class UnifiedJob(
|
|||||||
extra["controller_node"] = self.controller_node or "NOT_SET"
|
extra["controller_node"] = self.controller_node or "NOT_SET"
|
||||||
elif state == "execution_node_chosen":
|
elif state == "execution_node_chosen":
|
||||||
extra["execution_node"] = self.execution_node or "NOT_SET"
|
extra["execution_node"] = self.execution_node or "NOT_SET"
|
||||||
logger_job_lifecycle.info(msg, extra=extra)
|
|
||||||
|
logger_job_lifecycle.info(f"{msg} {json.dumps(extra)}")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def launched_by(self):
|
def launched_by(self):
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
from copy import copy
|
from copy import copy
|
||||||
import json
|
import json
|
||||||
import json_log_formatter
|
|
||||||
import logging
|
import logging
|
||||||
import traceback
|
import traceback
|
||||||
import socket
|
import socket
|
||||||
@@ -15,15 +14,6 @@ from django.core.serializers.json import DjangoJSONEncoder
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
|
|
||||||
class JobLifeCycleFormatter(json_log_formatter.JSONFormatter):
|
|
||||||
def json_record(self, message: str, extra: dict, record: logging.LogRecord):
|
|
||||||
if 'time' not in extra:
|
|
||||||
extra['time'] = now()
|
|
||||||
if record.exc_info:
|
|
||||||
extra['exc_info'] = self.formatException(record.exc_info)
|
|
||||||
return extra
|
|
||||||
|
|
||||||
|
|
||||||
class TimeFormatter(logging.Formatter):
|
class TimeFormatter(logging.Formatter):
|
||||||
"""
|
"""
|
||||||
Custom log formatter used for inventory imports
|
Custom log formatter used for inventory imports
|
||||||
|
|||||||
@@ -849,7 +849,6 @@ LOGGING = {
|
|||||||
'json': {'()': 'awx.main.utils.formatters.LogstashFormatter'},
|
'json': {'()': 'awx.main.utils.formatters.LogstashFormatter'},
|
||||||
'timed_import': {'()': 'awx.main.utils.formatters.TimeFormatter', 'format': '%(relativeSeconds)9.3f %(levelname)-8s %(message)s'},
|
'timed_import': {'()': 'awx.main.utils.formatters.TimeFormatter', 'format': '%(relativeSeconds)9.3f %(levelname)-8s %(message)s'},
|
||||||
'dispatcher': {'format': '%(asctime)s %(levelname)-8s [%(guid)s] %(name)s PID:%(process)d %(message)s'},
|
'dispatcher': {'format': '%(asctime)s %(levelname)-8s [%(guid)s] %(name)s PID:%(process)d %(message)s'},
|
||||||
'job_lifecycle': {'()': 'awx.main.utils.formatters.JobLifeCycleFormatter'},
|
|
||||||
},
|
},
|
||||||
# Extended below based on install scenario. You probably don't want to add something directly here.
|
# Extended below based on install scenario. You probably don't want to add something directly here.
|
||||||
# See 'handler_config' below.
|
# See 'handler_config' below.
|
||||||
@@ -917,7 +916,7 @@ handler_config = {
|
|||||||
'wsrelay': {'filename': 'wsrelay.log'},
|
'wsrelay': {'filename': 'wsrelay.log'},
|
||||||
'task_system': {'filename': 'task_system.log'},
|
'task_system': {'filename': 'task_system.log'},
|
||||||
'rbac_migrations': {'filename': 'tower_rbac_migrations.log'},
|
'rbac_migrations': {'filename': 'tower_rbac_migrations.log'},
|
||||||
'job_lifecycle': {'filename': 'job_lifecycle.log', 'formatter': 'job_lifecycle'},
|
'job_lifecycle': {'filename': 'job_lifecycle.log'},
|
||||||
'rsyslog_configurer': {'filename': 'rsyslog_configurer.log'},
|
'rsyslog_configurer': {'filename': 'rsyslog_configurer.log'},
|
||||||
'cache_clear': {'filename': 'cache_clear.log'},
|
'cache_clear': {'filename': 'cache_clear.log'},
|
||||||
'ws_heartbeat': {'filename': 'ws_heartbeat.log'},
|
'ws_heartbeat': {'filename': 'ws_heartbeat.log'},
|
||||||
|
|||||||
Reference in New Issue
Block a user