mirror of
https://github.com/ansible/awx.git
synced 2026-07-29 08:59:55 -02:30
improve readability of the honcho console logs in the dev environment
* colorize uwsgi and celery logs; DEBUG lines are green, WARN lines are yellow, ERROR lines (and tracebacks) are red * pretty-print fact callback receiver JSON * simplify the uwsgi log format so it's more legible
This commit is contained in:
@@ -17,6 +17,7 @@ from requests.exceptions import RequestException
|
||||
# loggly
|
||||
import traceback
|
||||
|
||||
from django.conf import settings
|
||||
from requests_futures.sessions import FuturesSession
|
||||
|
||||
# AWX
|
||||
@@ -304,6 +305,33 @@ HANDLER_MAPPING = {
|
||||
}
|
||||
|
||||
|
||||
ColorHandler = logging.StreamHandler
|
||||
|
||||
if settings.COLOR_LOGS is True:
|
||||
try:
|
||||
from logutils.colorize import ColorizingStreamHandler
|
||||
|
||||
class ColorHandler(ColorizingStreamHandler):
|
||||
|
||||
def format(self, record):
|
||||
message = logging.StreamHandler.format(self, record)
|
||||
return '\n'.join([
|
||||
self.colorize(line, record)
|
||||
for line in message.splitlines()
|
||||
])
|
||||
|
||||
level_map = {
|
||||
logging.DEBUG: (None, 'green', True),
|
||||
logging.INFO: (None, None, True),
|
||||
logging.WARNING: (None, 'yellow', True),
|
||||
logging.ERROR: (None, 'red', True),
|
||||
logging.CRITICAL: (None, 'red', True),
|
||||
}
|
||||
except ImportError:
|
||||
# logutils is only used for colored logs in the dev environment
|
||||
pass
|
||||
|
||||
|
||||
def _add_or_remove_logger(address, instance):
|
||||
specific_logger = logging.getLogger(address)
|
||||
for i, handler in enumerate(specific_logger.handlers):
|
||||
|
||||
Reference in New Issue
Block a user