Rename screen logfiles

This renames the log files in logs/screen that contain timestamps to put
the timestamp after '.log' and '.log.summary' in the names.  This will
simplify devstack-gate's search for log files to copy to '*.log'.

dstat.txt is also renamed to dstat.log

Make LOGDIR and LOGFILE local

bp:devstack-logging-and-service-names
Change-Id: I02aba9ca82c117a1186dafc1d3c07aa04ecd1dde
This commit is contained in:
Dean Troyer 2014-12-10 16:35:32 -06:00
parent 116f9f826e
commit ad5cc986d8
3 changed files with 17 additions and 18 deletions

View File

@ -1244,8 +1244,8 @@ function _run_process {
exec 6>&- exec 6>&-
if [[ -n ${SCREEN_LOGDIR} ]]; then if [[ -n ${SCREEN_LOGDIR} ]]; then
exec 1>&${SCREEN_LOGDIR}/screen-${service}.${CURRENT_LOG_TIME}.log 2>&1 exec 1>&${SCREEN_LOGDIR}/screen-${service}.log.${CURRENT_LOG_TIME} 2>&1
ln -sf ${SCREEN_LOGDIR}/screen-${service}.${CURRENT_LOG_TIME}.log ${SCREEN_LOGDIR}/screen-${service}.log ln -sf ${SCREEN_LOGDIR}/screen-${service}.log.${CURRENT_LOG_TIME} ${SCREEN_LOGDIR}/screen-${service}.log
# TODO(dtroyer): Hack to get stdout from the Python interpreter for the logs. # TODO(dtroyer): Hack to get stdout from the Python interpreter for the logs.
export PYTHONUNBUFFERED=1 export PYTHONUNBUFFERED=1
@ -1329,9 +1329,9 @@ function screen_process {
screen -S $SCREEN_NAME -X screen -t $name screen -S $SCREEN_NAME -X screen -t $name
if [[ -n ${SCREEN_LOGDIR} ]]; then if [[ -n ${SCREEN_LOGDIR} ]]; then
screen -S $SCREEN_NAME -p $name -X logfile ${SCREEN_LOGDIR}/screen-${name}.${CURRENT_LOG_TIME}.log screen -S $SCREEN_NAME -p $name -X logfile ${SCREEN_LOGDIR}/screen-${name}.log.${CURRENT_LOG_TIME}
screen -S $SCREEN_NAME -p $name -X log on screen -S $SCREEN_NAME -p $name -X log on
ln -sf ${SCREEN_LOGDIR}/screen-${name}.${CURRENT_LOG_TIME}.log ${SCREEN_LOGDIR}/screen-${name}.log ln -sf ${SCREEN_LOGDIR}/screen-${name}.log.${CURRENT_LOG_TIME} ${SCREEN_LOGDIR}/screen-${name}.log
fi fi
# sleep to allow bash to be ready to be send the command - we are # sleep to allow bash to be ready to be send the command - we are
@ -1377,7 +1377,7 @@ function screen_rc {
echo "stuff \"$2$NL\"" >> $SCREENRC echo "stuff \"$2$NL\"" >> $SCREENRC
if [[ -n ${SCREEN_LOGDIR} ]]; then if [[ -n ${SCREEN_LOGDIR} ]]; then
echo "logfile ${SCREEN_LOGDIR}/screen-${1}.${CURRENT_LOG_TIME}.log" >>$SCREENRC echo "logfile ${SCREEN_LOGDIR}/screen-${1}.log.${CURRENT_LOG_TIME}" >>$SCREENRC
echo "log on" >>$SCREENRC echo "log on" >>$SCREENRC
fi fi
fi fi
@ -1489,8 +1489,8 @@ function _old_run_process {
exec 6>&- exec 6>&-
if [[ -n ${SCREEN_LOGDIR} ]]; then if [[ -n ${SCREEN_LOGDIR} ]]; then
exec 1>&${SCREEN_LOGDIR}/screen-${1}.${CURRENT_LOG_TIME}.log 2>&1 exec 1>&${SCREEN_LOGDIR}/screen-${1}.log.${CURRENT_LOG_TIME} 2>&1
ln -sf ${SCREEN_LOGDIR}/screen-${1}.${CURRENT_LOG_TIME}.log ${SCREEN_LOGDIR}/screen-${1}.log ln -sf ${SCREEN_LOGDIR}/screen-${1}.log.${CURRENT_LOG_TIME} ${SCREEN_LOGDIR}/screen-${1}.log
# TODO(dtroyer): Hack to get stdout from the Python interpreter for the logs. # TODO(dtroyer): Hack to get stdout from the Python interpreter for the logs.
export PYTHONUNBUFFERED=1 export PYTHONUNBUFFERED=1

View File

@ -20,7 +20,7 @@ set +o xtrace
# Defaults # Defaults
# -------- # --------
# for DSTAT logging # for DSTAT logging
DSTAT_FILE=${DSTAT_FILE:-"dstat.txt"} DSTAT_FILE=${DSTAT_FILE:-"dstat.log"}
# start_dstat() - Start running processes, including screen # start_dstat() - Start running processes, including screen

View File

@ -370,15 +370,14 @@ if [[ -n "$LOGFILE" || -n "$SCREEN_LOGDIR" ]]; then
fi fi
if [[ -n "$LOGFILE" ]]; then if [[ -n "$LOGFILE" ]]; then
# First clean up old log files. Use the user-specified ``LOGFILE`` # Clean up old log files. Append '.*' to the user-specified
# as the template to search for, appending '.*' to match the date # ``LOGFILE`` to match the date in the search template.
# we added on earlier runs. local logfile_dir="${LOGFILE%/*}" # dirname
LOGDIR=$(dirname "$LOGFILE") local logfile_name="${LOGFILE##*/}" # basename
LOGFILENAME=$(basename "$LOGFILE") mkdir -p $logfile_dir
mkdir -p $LOGDIR find $logfile_dir -maxdepth 1 -name $logfile_name.\* -mtime +$LOGDAYS -exec rm {} \;
find $LOGDIR -maxdepth 1 -name $LOGFILENAME.\* -mtime +$LOGDAYS -exec rm {} \;
LOGFILE=$LOGFILE.${CURRENT_LOG_TIME} LOGFILE=$LOGFILE.${CURRENT_LOG_TIME}
SUMFILE=$LOGFILE.${CURRENT_LOG_TIME}.summary SUMFILE=$LOGFILE.summary.${CURRENT_LOG_TIME}
# Redirect output according to config # Redirect output according to config
@ -399,8 +398,8 @@ if [[ -n "$LOGFILE" ]]; then
echo_summary "stack.sh log $LOGFILE" echo_summary "stack.sh log $LOGFILE"
# Specified logfile name always links to the most recent log # Specified logfile name always links to the most recent log
ln -sf $LOGFILE $LOGDIR/$LOGFILENAME ln -sf $LOGFILE $logfile_dir/$logfile_name
ln -sf $SUMFILE $LOGDIR/$LOGFILENAME.summary ln -sf $SUMFILE $logfile_dir/$logfile_name.summary
else else
# Set up output redirection without log files # Set up output redirection without log files
# Set fd 3 to a copy of stdout. So we can set fd 1 without losing # Set fd 3 to a copy of stdout. So we can set fd 1 without losing