diff --git a/functions b/functions index 3e0e0d5559..89ee3672d3 100644 --- a/functions +++ b/functions @@ -569,6 +569,19 @@ function vercmp { esac } +# This sets up defaults we like in devstack for logging for tracking +# down issues, and makes sure everything is done the same between +# projects. +function setup_logging { + local conf_file=$1 + local other_cond=${2:-"False"} + if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ] && [ "$other_cond" == "False" ]; then + setup_colorized_logging $conf_file + else + setup_standard_logging_identity $conf_file + fi +} + # This function sets log formatting options for colorizing log # output to stdout. It is meant to be called by lib modules. # The last two parameters are optional and can be used to specify @@ -588,6 +601,11 @@ function setup_colorized_logging { iniset $conf_file $conf_section logging_exception_prefix "%(color)s%(asctime)s.%(msecs)03d TRACE %(name)s %(instance)s" } +function setup_standard_logging_identity { + local conf_file=$1 + iniset $conf_file DEFAULT logging_user_identity_format "%(project_name)s %(user_name)s" +} + # These functions are provided for basic fall-back functionality for # projects that include parts of DevStack (Grenade). stack.sh will # override these with more specific versions for DevStack (with fancy diff --git a/lib/cinder b/lib/cinder index cf5bb25cfe..870ee0b905 100644 --- a/lib/cinder +++ b/lib/cinder @@ -333,12 +333,7 @@ function configure_cinder { iniset $CINDER_CONF DEFAULT volume_clear $CINDER_VOLUME_CLEAR # Format logging - if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ] && [ "$CINDER_USE_MOD_WSGI" == "False" ]; then - setup_colorized_logging $CINDER_CONF - else - # Set req-id, project-name and resource in log format - 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" - fi + setup_logging $CINDER_CONF $CINDER_USE_MOD_WSGI if [ "$CINDER_USE_MOD_WSGI" == "True" ]; then _cinder_config_apache_wsgi diff --git a/lib/glance b/lib/glance index 17361143df..26c41507ed 100644 --- a/lib/glance +++ b/lib/glance @@ -229,10 +229,8 @@ function configure_glance { fi # Format logging - if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ]; then - setup_colorized_logging $GLANCE_API_CONF - setup_colorized_logging $GLANCE_REGISTRY_CONF - fi + setup_logging $GLANCE_API_CONF + setup_logging $GLANCE_REGISTRY_CONF cp -p $GLANCE_DIR/etc/glance-registry-paste.ini $GLANCE_REGISTRY_PASTE_INI @@ -273,7 +271,7 @@ function configure_glance { if is_service_enabled g-glare; then local dburl dburl=`database_connection_url glance` - setup_colorized_logging $GLANCE_GLARE_CONF + setup_logging $GLANCE_GLARE_CONF iniset $GLANCE_GLARE_CONF DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL iniset $GLANCE_GLARE_CONF DEFAULT bind_host $GLANCE_SERVICE_LISTEN_ADDRESS iniset $GLANCE_GLARE_CONF DEFAULT bind_port $GLANCE_GLARE_PORT diff --git a/lib/neutron-legacy b/lib/neutron-legacy index cf59b2d6dd..5ec61f9645 100644 --- a/lib/neutron-legacy +++ b/lib/neutron-legacy @@ -732,12 +732,7 @@ function _configure_neutron_common { fi # Format logging - if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ]; then - setup_colorized_logging $NEUTRON_CONF - else - # Show user_name and project_name by default like in nova - iniset $NEUTRON_CONF DEFAULT logging_user_identity_format "%(user_name)s %(project_name)s" - fi + setup_logging $NEUTRON_CONF if is_service_enabled tls-proxy; then # Set the service port for a proxy to take the original diff --git a/lib/nova b/lib/nova index 617cf5c3aa..c47f81a530 100644 --- a/lib/nova +++ b/lib/nova @@ -519,12 +519,8 @@ function create_nova_conf { iniset $NOVA_CONF DEFAULT force_config_drive "$FORCE_CONFIG_DRIVE" fi # Format logging - if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ] && [ "$NOVA_USE_MOD_WSGI" == "False" ] ; then - setup_colorized_logging $NOVA_CONF - else - # Show user_name and project_name instead of user_id and project_id - iniset $NOVA_CONF DEFAULT logging_user_identity_format "%(user_name)s %(project_name)s" - fi + setup_logging $NOVA_CONF $NOVA_USE_MOD_WSGI + if [ "$NOVA_USE_MOD_WSGI" == "True" ]; then _config_nova_apache_wsgi fi