Merge "Restore log colors under devstack/systemd"

This commit is contained in:
Jenkins
2017-05-17 20:10:30 +00:00
committed by Gerrit Code Review
3 changed files with 17 additions and 18 deletions

View File

@@ -109,6 +109,17 @@ Use higher precision time stamps::
journalctl -f -o short-precise --unit devstack@n-cpu.service journalctl -f -o short-precise --unit devstack@n-cpu.service
By default, journalctl strips out "unprintable" characters, including
ASCII color codes. To keep the color codes (which can be interpreted by
an appropriate terminal/pager - e.g. ``less``, the default)::
journalctl -a --unit devstack@n-cpu.service
When outputting to the terminal using the default pager, long lines
appear to be truncated, but horizontal scrolling is supported via the
left/right arrow keys.
See ``man 1 journalctl`` for more.
Known Issues Known Issues
============ ============
@@ -137,13 +148,6 @@ system units.
Future Work Future Work
=========== ===========
log colorizing
--------------
We lose log colorization through this process. We might want to build
a custom colorizer that we could run journalctl output through
optionally for people.
user units user units
---------- ----------

View File

@@ -616,21 +616,18 @@ function setup_systemd_logging {
# request-id. However, there may be an eventlet interaction here, # request-id. However, there may be an eventlet interaction here,
# so going off for now. # so going off for now.
USE_JOURNAL=$(trueorfalse USE_JOURNAL False) USE_JOURNAL=$(trueorfalse USE_JOURNAL False)
local pidstr=""
if [[ "$USE_JOURNAL" == "True" ]]; then if [[ "$USE_JOURNAL" == "True" ]]; then
iniset $conf_file $conf_section use_journal "True" iniset $conf_file $conf_section use_journal "True"
# if we are using the journal directly, our process id is already correct # if we are using the journal directly, our process id is already correct
iniset $conf_file $conf_section logging_debug_format_suffix \
"{{%(funcName)s %(pathname)s:%(lineno)d}}"
else else
iniset $conf_file $conf_section logging_debug_format_suffix \ pidstr="(pid=%(process)d) "
"{{(pid=%(process)d) %(funcName)s %(pathname)s:%(lineno)d}}"
fi fi
iniset $conf_file $conf_section logging_debug_format_suffix "{{${pidstr}%(funcName)s %(pathname)s:%(lineno)d}}"
iniset $conf_file $conf_section logging_context_format_string \ iniset $conf_file $conf_section logging_context_format_string "%(color)s%(levelname)s %(name)s [%(request_id)s %(project_name)s %(user_name)s%(color)s] %(instance)s%(color)s%(message)s"
"%(levelname)s %(name)s [%(request_id)s %(project_name)s %(user_name)s] %(instance)s%(message)s" iniset $conf_file $conf_section logging_default_format_string "%(color)s%(levelname)s %(name)s [-%(color)s] %(instance)s%(color)s%(message)s"
iniset $conf_file $conf_section logging_default_format_string \ iniset $conf_file $conf_section logging_exception_prefix "ERROR %(name)s %(instance)s"
"%(levelname)s %(name)s [-] %(instance)s%(color)s%(message)s"
iniset $conf_file $conf_section logging_exception_prefix "ERROR %(name)s %(instance)s"
} }
function setup_standard_logging_identity { function setup_standard_logging_identity {

View File

@@ -100,11 +100,9 @@ USER_UNITS=$(trueorfalse False USER_UNITS)
if [[ "$USER_UNITS" == "True" ]]; then if [[ "$USER_UNITS" == "True" ]]; then
SYSTEMD_DIR="$HOME/.local/share/systemd/user" SYSTEMD_DIR="$HOME/.local/share/systemd/user"
SYSTEMCTL="systemctl --user" SYSTEMCTL="systemctl --user"
JOURNALCTL_F="journalctl -f -o short-precise --user-unit"
else else
SYSTEMD_DIR="/etc/systemd/system" SYSTEMD_DIR="/etc/systemd/system"
SYSTEMCTL="sudo systemctl" SYSTEMCTL="sudo systemctl"
JOURNALCTL_F="journalctl -f -o short-precise --unit"
fi fi