Merge "Colorize Neutron log output and refactor log setup code"
This commit is contained in:
commit
23033e0399
19
functions
19
functions
@ -1745,6 +1745,25 @@ function policy_add() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# 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
|
||||||
|
# non-default value for project and user format variables.
|
||||||
|
# Defaults are respectively 'project_name' and 'user_name'
|
||||||
|
#
|
||||||
|
# setup_colorized_logging something.conf SOMESECTION
|
||||||
|
function setup_colorized_logging() {
|
||||||
|
local conf_file=$1
|
||||||
|
local conf_section=$2
|
||||||
|
local project_var=${3:-"project_name"}
|
||||||
|
local user_var=${4:-"user_name"}
|
||||||
|
# Add color to logging output
|
||||||
|
iniset $conf_file $conf_section logging_context_format_string "%(asctime)s.%(msecs)03d %(color)s%(levelname)s %(name)s [[01;36m%(request_id)s [00;36m%("$user_var")s %("$project_var")s%(color)s] [01;35m%(instance)s%(color)s%(message)s[00m"
|
||||||
|
iniset $conf_file $conf_section logging_default_format_string "%(asctime)s.%(msecs)03d %(color)s%(levelname)s %(name)s [[00;36m-%(color)s] [01;35m%(instance)s%(color)s%(message)s[00m"
|
||||||
|
iniset $conf_file $conf_section logging_debug_format_suffix "[00;33mfrom (pid=%(process)d) %(funcName)s %(pathname)s:%(lineno)d[00m"
|
||||||
|
iniset $conf_file $conf_section logging_exception_prefix "%(color)s%(asctime)s.%(msecs)03d TRACE %(name)s [01;35m%(instance)s[00m"
|
||||||
|
}
|
||||||
|
|
||||||
# Restore xtrace
|
# Restore xtrace
|
||||||
$XTRACE
|
$XTRACE
|
||||||
|
|
||||||
|
@ -255,12 +255,9 @@ function configure_cinder() {
|
|||||||
iniset $CINDER_CONF DEFAULT volume_clear none
|
iniset $CINDER_CONF DEFAULT volume_clear none
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Format logging
|
||||||
if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ]; then
|
if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ]; then
|
||||||
# Add color to logging output
|
setup_colorized_logging $CINDER_CONF DEFAULT "project_id" "user_id"
|
||||||
iniset $CINDER_CONF DEFAULT logging_context_format_string "%(asctime)s.%(msecs)03d %(color)s%(levelname)s %(name)s [[01;36m%(request_id)s [00;36m%(user_id)s %(project_id)s%(color)s] [01;35m%(instance)s%(color)s%(message)s[00m"
|
|
||||||
iniset $CINDER_CONF DEFAULT logging_default_format_string "%(asctime)s.%(msecs)03d %(color)s%(levelname)s %(name)s [[00;36m-%(color)s] [01;35m%(instance)s%(color)s%(message)s[00m"
|
|
||||||
iniset $CINDER_CONF DEFAULT logging_debug_format_suffix "[00;33mfrom (pid=%(process)d) %(funcName)s %(pathname)s:%(lineno)d[00m"
|
|
||||||
iniset $CINDER_CONF DEFAULT logging_exception_prefix "%(color)s%(asctime)s.%(msecs)03d TRACE %(name)s [01;35m%(instance)s[00m"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$CINDER_DRIVER" == "XenAPINFS" ]; then
|
if [ "$CINDER_DRIVER" == "XenAPINFS" ]; then
|
||||||
|
7
lib/heat
7
lib/heat
@ -1,4 +1,4 @@
|
|||||||
# lib/heat
|
etup lib/heat
|
||||||
# Install and start **Heat** service
|
# Install and start **Heat** service
|
||||||
|
|
||||||
# To enable, add the following to localrc
|
# To enable, add the following to localrc
|
||||||
@ -86,10 +86,7 @@ function configure_heat() {
|
|||||||
iniset $HEAT_CONF DEFAULT use_syslog $SYSLOG
|
iniset $HEAT_CONF DEFAULT use_syslog $SYSLOG
|
||||||
if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ]; then
|
if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ]; then
|
||||||
# Add color to logging output
|
# Add color to logging output
|
||||||
iniset $HEAT_CONF DEFAULT logging_context_format_string "%(asctime)s.%(msecs)03d %(color)s%(levelname)s %(name)s [[01;36m%(request_id)s [00;36m%(user_name)s %(project_name)s%(color)s] [01;35m%(instance)s%(color)s%(message)s[00m"
|
setup_colorized_logging $HEAT_CONF DEFAULT
|
||||||
iniset $HEAT_CONF DEFAULT logging_default_format_string "%(asctime)s.%(msecs)03d %(color)s%(levelname)s %(name)s [[00;36m-%(color)s] [01;35m%(instance)s%(color)s%(message)s[00m"
|
|
||||||
iniset $HEAT_CONF DEFAULT logging_debug_format_suffix "[00;33mfrom (pid=%(process)d) %(funcName)s %(pathname)s:%(lineno)d[00m"
|
|
||||||
iniset $HEAT_CONF DEFAULT logging_exception_prefix "%(color)s%(asctime)s.%(msecs)03d TRACE %(name)s [01;35m%(instance)s[00m"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# keystone authtoken
|
# keystone authtoken
|
||||||
|
@ -534,6 +534,11 @@ function _configure_neutron_common() {
|
|||||||
iniset $NEUTRON_CONF quotas quota_security_group_rule -1
|
iniset $NEUTRON_CONF quotas quota_security_group_rule -1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Format logging
|
||||||
|
if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ]; then
|
||||||
|
setup_colorized_logging $NEUTRON_CONF DEFAULT
|
||||||
|
fi
|
||||||
|
|
||||||
_neutron_setup_rootwrap
|
_neutron_setup_rootwrap
|
||||||
}
|
}
|
||||||
|
|
||||||
|
7
lib/nova
7
lib/nova
@ -499,12 +499,9 @@ function create_nova_conf() {
|
|||||||
if [ "$API_RATE_LIMIT" != "True" ]; then
|
if [ "$API_RATE_LIMIT" != "True" ]; then
|
||||||
iniset $NOVA_CONF DEFAULT api_rate_limit "False"
|
iniset $NOVA_CONF DEFAULT api_rate_limit "False"
|
||||||
fi
|
fi
|
||||||
|
# Format logging
|
||||||
if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ]; then
|
if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ]; then
|
||||||
# Add color to logging output
|
setup_colorized_logging $NOVA_CONF DEFAULT
|
||||||
iniset $NOVA_CONF DEFAULT logging_context_format_string "%(asctime)s.%(msecs)03d %(color)s%(levelname)s %(name)s [[01;36m%(request_id)s [00;36m%(user_name)s %(project_name)s%(color)s] [01;35m%(instance)s%(color)s%(message)s[00m"
|
|
||||||
iniset $NOVA_CONF DEFAULT logging_default_format_string "%(asctime)s.%(msecs)03d %(color)s%(levelname)s %(name)s [[00;36m-%(color)s] [01;35m%(instance)s%(color)s%(message)s[00m"
|
|
||||||
iniset $NOVA_CONF DEFAULT logging_debug_format_suffix "[00;33mfrom (pid=%(process)d) %(funcName)s %(pathname)s:%(lineno)d[00m"
|
|
||||||
iniset $NOVA_CONF DEFAULT logging_exception_prefix "%(color)s%(asctime)s.%(msecs)03d TRACE %(name)s [01;35m%(instance)s[00m"
|
|
||||||
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_context_format_string "%(asctime)s.%(msecs)03d %(levelname)s %(name)s [%(request_id)s %(user_name)s %(project_name)s] %(instance)s%(message)s"
|
iniset $NOVA_CONF DEFAULT logging_context_format_string "%(asctime)s.%(msecs)03d %(levelname)s %(name)s [%(request_id)s %(user_name)s %(project_name)s] %(instance)s%(message)s"
|
||||||
|
Loading…
Reference in New Issue
Block a user