fsfe-website/build/logging.sh
delliott bb45fc85ba
All checks were successful
continuous-integration/drone/push Build is passing
feat/build-improvements-2 (#4553)
Another attempt at #4516

Adds a small fix for tag map generation

#4516 introduces build failures, but testing indicates that those failures would have been resolved by a full rebuild.

Hence this pr.

Co-authored-by: Darragh Elliott <me@delliott.xyz>
Reviewed-on: #4553
Co-authored-by: delliott <delliott@fsfe.org>
Co-committed-by: delliott <delliott@fsfe.org>
2024-10-29 14:56:41 +00:00

44 lines
933 B
Bash
Executable File

#!/usr/bin/env bash
inc_logging=true
logname() {
name="$1"
if [ -w "$statusdir" ] && touch "$statusdir/$name"; then
echo "$statusdir/$name"
elif echo "$forcedlog" | egrep -q "^${name}=.+"; then
echo "$forcedlog" |
sed -rn "s;^${name}=;;p"
else
echo /dev/null
fi
}
forcelog() {
name="$1"
[ "$(logname "$name")" = "/dev/null" ] &&
forcedlog="$forcedlog\n${name}=$(mktemp -t w3bldXXXXXXXXX --suffix $$)"
}
[ -z "$USER" ] && USER="$(whoami)"
trap "trap - 0 2 3 6 9 15; find \"${TMPDIR:-/tmp}/\" -maxdepth 1 -user \"$USER\" -name \"w3bld*$$\" -delete" 0 2 3 6 9 15
logstatus() {
# pipeline atom to write data streams into a log file
tee "$(logname "$1")"
}
t_logstatus() {
# pipeline atom to write data streams into a log file
while read line; do
printf "[$(date +%T)] %s\n" "$line"
done | logstatus "$@"
}
logappend() {
# pipeline atom to write data streams into a log file
tee -a "$(logname "$1")"
}