Browse Source

Make the log output pretty and more useful

 * requires https://review.openstack.org/#/c/8067/

Change-Id: Ib26c1bd7e9ef933a7dbe2ee0c476e8d439e17574
tags/folsom-eol
Vishvananda Ishaya 7 years ago
parent
commit
6f13ba33d8
1 changed files with 13 additions and 0 deletions
  1. 13
    0
      stack.sh

+ 13
- 0
stack.sh View File

@@ -262,6 +262,9 @@ SYSLOG=`trueorfalse False $SYSLOG`
262 262
 SYSLOG_HOST=${SYSLOG_HOST:-$HOST_IP}
263 263
 SYSLOG_PORT=${SYSLOG_PORT:-516}
264 264
 
265
+# Use color for logging output
266
+LOG_COLOR=`trueorfalse True $LOG_COLOR`
267
+
265 268
 # Service startup timeout
266 269
 SERVICE_TIMEOUT=${SERVICE_TIMEOUT:-60}
267 270
 
@@ -1709,6 +1712,16 @@ fi
1709 1712
 if [ "$API_RATE_LIMIT" != "True" ]; then
1710 1713
     add_nova_opt "api_rate_limit=False"
1711 1714
 fi
1715
+if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ]; then
1716
+    # Add color to logging output
1717
+    add_nova_opt "logging_context_format_string=%(asctime)s %(color)s%(levelname)s %(name)s [%(request_id)s %(user_name)s %(project_name)s%(color)s] %(instance)s%(color)s%(message)s"
1718
+    add_nova_opt "logging_default_format_string=%(asctime)s %(color)s%(levelname)s %(name)s [-%(color)s] %(instance)s%(color)s%(message)s"
1719
+    add_nova_opt "logging_debug_format_suffix=from (pid=%(process)d) %(funcName)s %(pathname)s:%(lineno)d"
1720
+    add_nova_opt "logging_exception_prefix=%(color)s%(asctime)s TRACE %(name)s %(instance)s"
1721
+else
1722
+    # Show user_name and project_name instead of user_id and project_id
1723
+    add_nova_opt "logging_context_format_string=%(asctime)s %(levelname)s %(name)s [%(request_id)s %(user_name)s %(project_name)s] %(instance)s%(message)s"
1724
+fi
1712 1725
 
1713 1726
 
1714 1727
 # Provide some transition from EXTRA_FLAGS to EXTRA_OPTS

Loading…
Cancel
Save