Skip to content

Commit ad5cc98

Browse files
author
Dean Troyer
committed
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
1 parent 116f9f8 commit ad5cc98

File tree

3 files changed

+17
-18
lines changed

3 files changed

+17
-18
lines changed

functions-common

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,8 +1244,8 @@ function _run_process {
12441244
exec 6>&-
12451245

12461246
if [[ -n ${SCREEN_LOGDIR} ]]; then
1247-
exec 1>&${SCREEN_LOGDIR}/screen-${service}.${CURRENT_LOG_TIME}.log 2>&1
1248-
ln -sf ${SCREEN_LOGDIR}/screen-${service}.${CURRENT_LOG_TIME}.log ${SCREEN_LOGDIR}/screen-${service}.log
1247+
exec 1>&${SCREEN_LOGDIR}/screen-${service}.log.${CURRENT_LOG_TIME} 2>&1
1248+
ln -sf ${SCREEN_LOGDIR}/screen-${service}.log.${CURRENT_LOG_TIME} ${SCREEN_LOGDIR}/screen-${service}.log
12491249

12501250
# TODO(dtroyer): Hack to get stdout from the Python interpreter for the logs.
12511251
export PYTHONUNBUFFERED=1
@@ -1329,9 +1329,9 @@ function screen_process {
13291329
screen -S $SCREEN_NAME -X screen -t $name
13301330

13311331
if [[ -n ${SCREEN_LOGDIR} ]]; then
1332-
screen -S $SCREEN_NAME -p $name -X logfile ${SCREEN_LOGDIR}/screen-${name}.${CURRENT_LOG_TIME}.log
1332+
screen -S $SCREEN_NAME -p $name -X logfile ${SCREEN_LOGDIR}/screen-${name}.log.${CURRENT_LOG_TIME}
13331333
screen -S $SCREEN_NAME -p $name -X log on
1334-
ln -sf ${SCREEN_LOGDIR}/screen-${name}.${CURRENT_LOG_TIME}.log ${SCREEN_LOGDIR}/screen-${name}.log
1334+
ln -sf ${SCREEN_LOGDIR}/screen-${name}.log.${CURRENT_LOG_TIME} ${SCREEN_LOGDIR}/screen-${name}.log
13351335
fi
13361336

13371337
# sleep to allow bash to be ready to be send the command - we are
@@ -1377,7 +1377,7 @@ function screen_rc {
13771377
echo "stuff \"$2$NL\"" >> $SCREENRC
13781378

13791379
if [[ -n ${SCREEN_LOGDIR} ]]; then
1380-
echo "logfile ${SCREEN_LOGDIR}/screen-${1}.${CURRENT_LOG_TIME}.log" >>$SCREENRC
1380+
echo "logfile ${SCREEN_LOGDIR}/screen-${1}.log.${CURRENT_LOG_TIME}" >>$SCREENRC
13811381
echo "log on" >>$SCREENRC
13821382
fi
13831383
fi
@@ -1489,8 +1489,8 @@ function _old_run_process {
14891489
exec 6>&-
14901490

14911491
if [[ -n ${SCREEN_LOGDIR} ]]; then
1492-
exec 1>&${SCREEN_LOGDIR}/screen-${1}.${CURRENT_LOG_TIME}.log 2>&1
1493-
ln -sf ${SCREEN_LOGDIR}/screen-${1}.${CURRENT_LOG_TIME}.log ${SCREEN_LOGDIR}/screen-${1}.log
1492+
exec 1>&${SCREEN_LOGDIR}/screen-${1}.log.${CURRENT_LOG_TIME} 2>&1
1493+
ln -sf ${SCREEN_LOGDIR}/screen-${1}.log.${CURRENT_LOG_TIME} ${SCREEN_LOGDIR}/screen-${1}.log
14941494

14951495
# TODO(dtroyer): Hack to get stdout from the Python interpreter for the logs.
14961496
export PYTHONUNBUFFERED=1

lib/dstat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ set +o xtrace
2020
# Defaults
2121
# --------
2222
# for DSTAT logging
23-
DSTAT_FILE=${DSTAT_FILE:-"dstat.txt"}
23+
DSTAT_FILE=${DSTAT_FILE:-"dstat.log"}
2424

2525

2626
# start_dstat() - Start running processes, including screen

stack.sh

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -370,15 +370,14 @@ if [[ -n "$LOGFILE" || -n "$SCREEN_LOGDIR" ]]; then
370370
fi
371371

372372
if [[ -n "$LOGFILE" ]]; then
373-
# First clean up old log files. Use the user-specified ``LOGFILE``
374-
# as the template to search for, appending '.*' to match the date
375-
# we added on earlier runs.
376-
LOGDIR=$(dirname "$LOGFILE")
377-
LOGFILENAME=$(basename "$LOGFILE")
378-
mkdir -p $LOGDIR
379-
find $LOGDIR -maxdepth 1 -name $LOGFILENAME.\* -mtime +$LOGDAYS -exec rm {} \;
373+
# Clean up old log files. Append '.*' to the user-specified
374+
# ``LOGFILE`` to match the date in the search template.
375+
local logfile_dir="${LOGFILE%/*}" # dirname
376+
local logfile_name="${LOGFILE##*/}" # basename
377+
mkdir -p $logfile_dir
378+
find $logfile_dir -maxdepth 1 -name $logfile_name.\* -mtime +$LOGDAYS -exec rm {} \;
380379
LOGFILE=$LOGFILE.${CURRENT_LOG_TIME}
381-
SUMFILE=$LOGFILE.${CURRENT_LOG_TIME}.summary
380+
SUMFILE=$LOGFILE.summary.${CURRENT_LOG_TIME}
382381

383382
# Redirect output according to config
384383

@@ -399,8 +398,8 @@ if [[ -n "$LOGFILE" ]]; then
399398

400399
echo_summary "stack.sh log $LOGFILE"
401400
# Specified logfile name always links to the most recent log
402-
ln -sf $LOGFILE $LOGDIR/$LOGFILENAME
403-
ln -sf $SUMFILE $LOGDIR/$LOGFILENAME.summary
401+
ln -sf $LOGFILE $logfile_dir/$logfile_name
402+
ln -sf $SUMFILE $logfile_dir/$logfile_name.summary
404403
else
405404
# Set up output redirection without log files
406405
# Set fd 3 to a copy of stdout. So we can set fd 1 without losing

0 commit comments

Comments
 (0)