Browse code

Merge "Make the log output pretty and more useful"

Jenkins authored on 2012/06/15 03:41:39
Showing 1 changed files
... ...
@@ -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
 
... ...
@@ -1762,6 +1765,16 @@ fi
1762 1762
 if [ "$API_RATE_LIMIT" != "True" ]; then
1763 1763
     add_nova_opt "api_rate_limit=False"
1764 1764
 fi
1765
+if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ]; then
1766
+    # Add color to logging output
1767
+    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"
1768
+    add_nova_opt "logging_default_format_string=%(asctime)s %(color)s%(levelname)s %(name)s [-%(color)s] %(instance)s%(color)s%(message)s"
1769
+    add_nova_opt "logging_debug_format_suffix=from (pid=%(process)d) %(funcName)s %(pathname)s:%(lineno)d"
1770
+    add_nova_opt "logging_exception_prefix=%(color)s%(asctime)s TRACE %(name)s %(instance)s"
1771
+else
1772
+    # Show user_name and project_name instead of user_id and project_id
1773
+    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"
1774
+fi
1765 1775
 
1766 1776
 
1767 1777
 # Provide some transition from EXTRA_FLAGS to EXTRA_OPTS