Browse code

simplify colorized logging setup

This makes setup_colorized_logging be a thing which takes a single
parameter and doesn't let projects do things differently. It also
changes the order of values from user / project to project / user to
represent the hierachy more clearly.

Change-Id: I8c0ba7da54be588e3e068734feb4f78ed7c5a14a

Sean Dague authored on 2016/04/06 00:52:44
Showing 6 changed files
... ...
@@ -578,11 +578,11 @@ function vercmp {
578 578
 # setup_colorized_logging something.conf SOMESECTION
579 579
 function setup_colorized_logging {
580 580
     local conf_file=$1
581
-    local conf_section=$2
582
-    local project_var=${3:-"project_name"}
583
-    local user_var=${4:-"user_name"}
581
+    local conf_section="DEFAULT"
582
+    local project_var="project_name"
583
+    local user_var="user_name"
584 584
     # Add color to logging output
585
-    iniset $conf_file $conf_section logging_context_format_string "%(asctime)s.%(msecs)03d %(color)s%(levelname)s %(name)s [%(request_id)s %("$user_var")s %("$project_var")s%(color)s] %(instance)s%(color)s%(message)s"
585
+    iniset $conf_file $conf_section logging_context_format_string "%(asctime)s.%(msecs)03d %(color)s%(levelname)s %(name)s [%(request_id)s %("$project_var")s %("$user_var")s%(color)s] %(instance)s%(color)s%(message)s"
586 586
     iniset $conf_file $conf_section logging_default_format_string "%(asctime)s.%(msecs)03d %(color)s%(levelname)s %(name)s [-%(color)s] %(instance)s%(color)s%(message)s"
587 587
     iniset $conf_file $conf_section logging_debug_format_suffix "from (pid=%(process)d) %(funcName)s %(pathname)s:%(lineno)d"
588 588
     iniset $conf_file $conf_section logging_exception_prefix "%(color)s%(asctime)s.%(msecs)03d TRACE %(name)s %(instance)s"
... ...
@@ -334,7 +334,7 @@ function configure_cinder {
334 334
 
335 335
     # Format logging
336 336
     if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ] && [ "$CINDER_USE_MOD_WSGI" == "False" ]; then
337
-        setup_colorized_logging $CINDER_CONF DEFAULT "project_id" "user_id"
337
+        setup_colorized_logging $CINDER_CONF
338 338
     else
339 339
         # Set req-id, project-name and resource in log format
340 340
         iniset $CINDER_CONF DEFAULT logging_context_format_string "%(asctime)s.%(msecs)03d %(levelname)s %(name)s [%(request_id)s %(project_name)s] %(resource)s%(message)s"
... ...
@@ -230,8 +230,8 @@ function configure_glance {
230 230
 
231 231
     # Format logging
232 232
     if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ]; then
233
-        setup_colorized_logging $GLANCE_API_CONF DEFAULT tenant user
234
-        setup_colorized_logging $GLANCE_REGISTRY_CONF DEFAULT tenant user
233
+        setup_colorized_logging $GLANCE_API_CONF
234
+        setup_colorized_logging $GLANCE_REGISTRY_CONF
235 235
     fi
236 236
 
237 237
     cp -p $GLANCE_DIR/etc/glance-registry-paste.ini $GLANCE_REGISTRY_PASTE_INI
... ...
@@ -273,7 +273,7 @@ function configure_glance {
273 273
     if is_service_enabled g-glare; then
274 274
         local dburl
275 275
         dburl=`database_connection_url glance`
276
-        setup_colorized_logging $GLANCE_GLARE_CONF DEFAULT tenant user
276
+        setup_colorized_logging $GLANCE_GLARE_CONF
277 277
         iniset $GLANCE_GLARE_CONF DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL
278 278
         iniset $GLANCE_GLARE_CONF DEFAULT bind_host $GLANCE_SERVICE_LISTEN_ADDRESS
279 279
         iniset $GLANCE_GLARE_CONF DEFAULT bind_port $GLANCE_GLARE_PORT
... ...
@@ -284,7 +284,7 @@ function configure_keystone {
284 284
 
285 285
     # Format logging
286 286
     if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ] && [ "$KEYSTONE_DEPLOY" != "mod_wsgi" ] ; then
287
-        setup_colorized_logging $KEYSTONE_CONF DEFAULT
287
+        setup_colorized_logging $KEYSTONE_CONF
288 288
     fi
289 289
 
290 290
     iniset $KEYSTONE_CONF DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL
... ...
@@ -733,7 +733,7 @@ function _configure_neutron_common {
733 733
 
734 734
     # Format logging
735 735
     if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ]; then
736
-        setup_colorized_logging $NEUTRON_CONF DEFAULT project_id
736
+        setup_colorized_logging $NEUTRON_CONF
737 737
     else
738 738
         # Show user_name and project_name by default like in nova
739 739
         iniset $NEUTRON_CONF DEFAULT logging_user_identity_format "%(user_name)s %(project_name)s"
... ...
@@ -520,7 +520,7 @@ function create_nova_conf {
520 520
     fi
521 521
     # Format logging
522 522
     if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ] && [ "$NOVA_USE_MOD_WSGI" == "False" ]  ; then
523
-        setup_colorized_logging $NOVA_CONF DEFAULT
523
+        setup_colorized_logging $NOVA_CONF
524 524
     else
525 525
         # Show user_name and project_name instead of user_id and project_id
526 526
         iniset $NOVA_CONF DEFAULT logging_user_identity_format "%(user_name)s %(project_name)s"