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