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
This commit is contained in:
Sean Dague 2016-04-05 11:52:44 -04:00
parent df09c43386
commit b6753cea8c
6 changed files with 11 additions and 11 deletions

View File

@ -578,11 +578,11 @@ function vercmp {
# setup_colorized_logging something.conf SOMESECTION # setup_colorized_logging something.conf SOMESECTION
function setup_colorized_logging { function setup_colorized_logging {
local conf_file=$1 local conf_file=$1
local conf_section=$2 local conf_section="DEFAULT"
local project_var=${3:-"project_name"} local project_var="project_name"
local user_var=${4:-"user_name"} local user_var="user_name"
# Add color to logging output # Add color to logging output
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" 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"
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" 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"
iniset $conf_file $conf_section logging_debug_format_suffix "from (pid=%(process)d) %(funcName)s %(pathname)s:%(lineno)d" iniset $conf_file $conf_section logging_debug_format_suffix "from (pid=%(process)d) %(funcName)s %(pathname)s:%(lineno)d"
iniset $conf_file $conf_section logging_exception_prefix "%(color)s%(asctime)s.%(msecs)03d TRACE %(name)s %(instance)s" iniset $conf_file $conf_section logging_exception_prefix "%(color)s%(asctime)s.%(msecs)03d TRACE %(name)s %(instance)s"

View File

@ -334,7 +334,7 @@ function configure_cinder {
# Format logging # Format logging
if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ] && [ "$CINDER_USE_MOD_WSGI" == "False" ]; then if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ] && [ "$CINDER_USE_MOD_WSGI" == "False" ]; then
setup_colorized_logging $CINDER_CONF DEFAULT "project_id" "user_id" setup_colorized_logging $CINDER_CONF
else else
# Set req-id, project-name and resource in log format # 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" 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"

View File

@ -230,8 +230,8 @@ function configure_glance {
# Format logging # Format logging
if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ]; then if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ]; then
setup_colorized_logging $GLANCE_API_CONF DEFAULT tenant user setup_colorized_logging $GLANCE_API_CONF
setup_colorized_logging $GLANCE_REGISTRY_CONF DEFAULT tenant user setup_colorized_logging $GLANCE_REGISTRY_CONF
fi fi
cp -p $GLANCE_DIR/etc/glance-registry-paste.ini $GLANCE_REGISTRY_PASTE_INI cp -p $GLANCE_DIR/etc/glance-registry-paste.ini $GLANCE_REGISTRY_PASTE_INI
@ -273,7 +273,7 @@ function configure_glance {
if is_service_enabled g-glare; then if is_service_enabled g-glare; then
local dburl local dburl
dburl=`database_connection_url glance` dburl=`database_connection_url glance`
setup_colorized_logging $GLANCE_GLARE_CONF DEFAULT tenant user setup_colorized_logging $GLANCE_GLARE_CONF
iniset $GLANCE_GLARE_CONF DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL 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_host $GLANCE_SERVICE_LISTEN_ADDRESS
iniset $GLANCE_GLARE_CONF DEFAULT bind_port $GLANCE_GLARE_PORT iniset $GLANCE_GLARE_CONF DEFAULT bind_port $GLANCE_GLARE_PORT

View File

@ -284,7 +284,7 @@ function configure_keystone {
# Format logging # Format logging
if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ] && [ "$KEYSTONE_DEPLOY" != "mod_wsgi" ] ; then if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ] && [ "$KEYSTONE_DEPLOY" != "mod_wsgi" ] ; then
setup_colorized_logging $KEYSTONE_CONF DEFAULT setup_colorized_logging $KEYSTONE_CONF
fi fi
iniset $KEYSTONE_CONF DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL iniset $KEYSTONE_CONF DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL

View File

@ -733,7 +733,7 @@ function _configure_neutron_common {
# Format logging # Format logging
if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ]; then if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ]; then
setup_colorized_logging $NEUTRON_CONF DEFAULT project_id setup_colorized_logging $NEUTRON_CONF
else else
# Show user_name and project_name by default like in nova # 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" iniset $NEUTRON_CONF DEFAULT logging_user_identity_format "%(user_name)s %(project_name)s"

View File

@ -520,7 +520,7 @@ function create_nova_conf {
fi fi
# Format logging # Format logging
if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ] && [ "$NOVA_USE_MOD_WSGI" == "False" ] ; then if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ] && [ "$NOVA_USE_MOD_WSGI" == "False" ] ; then
setup_colorized_logging $NOVA_CONF DEFAULT setup_colorized_logging $NOVA_CONF
else else
# Show user_name and project_name instead of user_id and project_id # 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" iniset $NOVA_CONF DEFAULT logging_user_identity_format "%(user_name)s %(project_name)s"