Add automatic logging of all operations
This commit is contained in:
parent
9f182d0a8b
commit
697f9cff21
@ -18,6 +18,9 @@
|
|||||||
|
|
||||||
# Written by Tom G. Christensen <tgc@jupiterrise.com>.
|
# Written by Tom G. Christensen <tgc@jupiterrise.com>.
|
||||||
|
|
||||||
|
# Automatic logging is enabled by default
|
||||||
|
autolog=1
|
||||||
|
|
||||||
# Define script functions and register them
|
# Define script functions and register them
|
||||||
METHODS=""
|
METHODS=""
|
||||||
reg() {
|
reg() {
|
||||||
@ -64,6 +67,39 @@ build_sh() {
|
|||||||
|
|
||||||
for METHOD in $*
|
for METHOD in $*
|
||||||
do
|
do
|
||||||
( $METHOD )
|
( log_start $METHOD; $METHOD; log_stop )
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Start a logfile
|
||||||
|
# Note this should only be used *after* the buildpkg.* libraries
|
||||||
|
# have been sourced, otherwise most of the variables used to construct
|
||||||
|
# the logfile name are undefined.
|
||||||
|
log_start()
|
||||||
|
{
|
||||||
|
local func=$1
|
||||||
|
build_sh_logfile=${topdir}-${version}_${pkgver}-${os}-${arch}-${func}-$(date +%Y%m%d%H%M%S).log
|
||||||
|
|
||||||
|
if [ $autolog -eq 1 ]; then
|
||||||
|
# save stdout and stderr to file descriptors 3 and 4
|
||||||
|
# then redirect them to $build_sh_logfile
|
||||||
|
echo "Opening logfile: $build_sh_logfile"
|
||||||
|
exec 3>&1 4>&2 >$build_sh_logfile 2>&1
|
||||||
|
# Log a timestamp
|
||||||
|
date +%Y%m%d%H%M%S
|
||||||
|
# Get information about the compiler into the logfile
|
||||||
|
identify_compiler log
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Stop logging
|
||||||
|
log_stop()
|
||||||
|
{
|
||||||
|
if [ $autolog -eq 1 ]; then
|
||||||
|
# Log a timestamp
|
||||||
|
date +%Y%m%d%H%M%S
|
||||||
|
# restore stdout and stderr
|
||||||
|
exec 1>&3 2>&4
|
||||||
|
echo "Closing logfile: $build_sh_logfile"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user