unify logging setup on all services

This provides a single setup_logging function which builds consistent
colorization if the config supports it, otherwise builds the identity
strings that we need to actually keep track of requests.

Change-Id: Iffe30326a5b974ad141aed6288f61e0d6fd18ca9
This commit is contained in:
Sean Dague 2016-04-05 12:08:57 -04:00
parent b6753cea8c
commit 9751be66fa
5 changed files with 25 additions and 23 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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