Skip to content

Commit 1151aa0

Browse files
author
Matthias Koeppe
committed
build/bin/sage-logger: Refactor with bash function report_time
1 parent 735cd38 commit 1151aa0

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

build/bin/sage-logger

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@ else
6969
TIME=""
7070
fi
7171

72+
report_time ()
73+
{
74+
if grep -q 'real [1-9][0-9]' $timefile 2>/dev/null; then
75+
# at least 10 seconds
76+
echo $(echo $(cat $timefile));
77+
fi;
78+
}
79+
7280
mkdir -p "$logdir"
7381

7482
# Do all logging of child processes with V=1 to ensure that no
@@ -90,10 +98,13 @@ if [ -n "$SAGE_SILENT_BUILD" -a ${use_prefix} = true ]; then
9098
echo " [$logname] error installing, exit status $status. End of log file:"
9199
tail -n 120 "$logfile" | sed "/Please email sage-devel/,$ d;s;^; [$logname] ;" >&2
92100
echo " [$logname] Full log file: $logfile"
93-
elif grep -q 'real [1-9][0-9]' $timefile 2>/dev/null; then # at least 10 seconds
94-
echo " [$logname] successfully installed ($(echo $(cat $timefile)))."
95101
else
96-
echo " [$logname] successfully installed."
102+
time=$(report_time)
103+
if [ -n "$time" ]; then
104+
echo " [$logname] successfully installed ($time)."
105+
else
106+
echo " [$logname] successfully installed."
107+
fi
97108
fi
98109
exit $status
99110
else
@@ -102,8 +113,7 @@ else
102113
# run, not the logging.
103114

104115
( exec 2>&1;
105-
$TIME sh -c "$cmd"; status=$?;
106-
if grep -q 'real [1-9][0-9]' $timefile 2>/dev/null; then echo $(echo $(cat $timefile)); fi;
116+
$TIME sh -c "$cmd"; status=$?; report_time;
107117
exit $status ) | \
108118
( trap '' SIGINT; if [ -n "$GITHUB_ACTIONS" -a -n "$prefix" ]; then echo "::group::${logname}"; fi; tee -a "$logfile" | $SED; if [ -n "$GITHUB_ACTIONS" -a -n "$prefix" ]; then echo "::endgroup::"; fi )
109119

0 commit comments

Comments
 (0)