Implement log truncation, now ready for testing

What (should) work):

 - LIBRETRO_DEVELOPER (default 1) to output all build progress

 - LIBRETRO_LOG_DIR (default $WORKDIR/log) to change WHERE logs get
   written.  Useful for buildbots that have multiple WORKDIRs to put
   logs in roughly the same place.

 - LIBRETRO_LOG_SUPER (default libretro-super.log) to change the name of
   libretro-build.sh's log file.  No log would be written if unset, but
   script-modules/log.sh sets it if unset for now.

 - LIBRETRO_LOG_CORE (default %s.log) to change the name pattern for a
   core log file.  The %s is replaced with the "safe" core name used by
   libretro-super's rules.

 - LIBRETRO_LOG_APPEND (default ""), if set, would not clobber the log
   files the next time you ran libretro-super.  Caution: mame's output
   is 34 megabytes on its own for a single successful build

What doesn't work yet:

 - You should be able to unset LIBRETRO_LOG_SUPER and LIBRETRO_LOG_CORE
   and have your decision mean something.  This is the #1 thing I must
   change, and I will do so in the next day or so.

 - We assume that if you want output to screen and log, you'll have the
   tee command.  What if you don't?  We choose log over screen in that
   case, but tee is such a trivial tool to implement, perhaps we should?

 - Currently logs lack date stamps.  Bash's built-in printf has a way to
   do this, but Apple STUPIDLY disables it because Apple.  Turns out
   that bash 2.05a didn't have the feature anyway.  You may not have the
   UNIX date command on Windows if you're somehow running bash from
   cmd.exe.  Worse, you have a command of the same name that requires a
   /t argument to do half of what date does on UNIX.  Running into
   limits of bash here, easily solved using most anything else.
This commit is contained in:
T. Joseph Carter 2015-03-27 19:31:19 -07:00
parent a395d977b1
commit 1a30a6a1a1
3 changed files with 26 additions and 10 deletions

View File

@ -243,8 +243,10 @@ build_makefile() {
libretro_build_core() {
local opengl_type
# Set log_core only if LIBRETRO_LOG_CORE is set
printf -v log_core "${LIBRETRO_LOG_CORE:+$LIBRETRO_LOG_DIR/$LIBRETRO_LOG_CORE}" "$1"
if [ -n "${LIBRETRO_LOG_CORE}" ]; then
printf -v log_core "$LIBRETRO_LOG_DIR/$LIBRETRO_LOG_CORE" "$1"
[ -z "$LIBRETRO_LOG_APPEND" ] && : > $log_core
fi
eval "core_name=\${libretro_${1}_name:-$1}"
echo "$(color 34)=== $(color 1)$core_name$(color)"
@ -363,10 +365,10 @@ summary() {
local num_fail="$(numwords $build_fail)"
local fmt_fail="${fmt_output:+$(echo " $build_fail" | $fmt_output)}"
for output in "" ${LIBRETRO_LOG_SUPER:+$super_log}; do
for output in "" ${LIBRETRO_LOG_SUPER:+$log_super}; do
if [ -n "$output" ]; then
exec 6>&1
exec > $output
exec >> $output
use_color=""
fi
{

View File

@ -271,21 +271,34 @@ fi
# OUTPUT AND LOGGING
# ==================
#
# This is kind of an inline design document that'll be changed for basic user
# instructions when the logging system is finished and tested.
#
# libretro-super has two kinds of output, the basic kind showing what the
# script is doing in a big-picture sense, and the commands and output from
# individual commands. End-users don't necessarily need to see this more
# detailed output, except when we're talking about huge cores like mame.
#
# If each can be directed to null, to the screen, to a log file, or to both
# the screen and a log file, you end up with the following truth table, along
# with my assessment of the usefulness of each combination:
# the screen and a log file, you end up with a matrix os 16 possibilities. Of
# those, only a few are truly useful:
#
# Basic Detailed Usefulness
# screen screen developer
# Basic Detailed Useful to
# screen screen developer/end-user w/ space issues
# screen both developer
# both both developer
# screen log end-user
# log log buildbot
#
# What this tells me is that we need to log by default, as long as we kill
# old logfiles to avoid filling your HD with gigabytes of mame build logs.
# Output should go to both screen and log for developers, but users don't need
# to see the make commands, etc. Being able to disable both would be useful,
# but that a near-term TODO item. That just leaves being able to squelch the
# screen output for buildbot usage, and that's just > /dev/null on the command
# line, so not our problem here.
#
# Again, the ability to turn OFF these logs will be wanted very soon.
# Uncomment this to avoid clobbering logs
#LIBRETRO_LOG_APPEND=1

View File

@ -6,7 +6,7 @@ color() {
lecho() {
if [ -n "$LIBRETRO_LOG_SUPER" ]; then
echo "$@" >> $super_log
echo "$@" >> $log_super
fi
}
@ -15,7 +15,8 @@ LIBRETRO_LOG_DIR="${LIBRETRO_LOG_DIR:-$WORKDIR/log}"
LIBRETRO_LOG_CORE="${LIBRETRO_LOG_CORE:-%s.log}"
LIBRETRO_LOG_SUPER="${LIBRETRO_LOG_SUPER:-libretro-super.log}"
if [ -n "$LIBRETRO_LOG_SUPER" ]; then
super_log="$LIBRETRO_LOG_DIR/$LIBRETRO_LOG_SUPER"
log_super="$LIBRETRO_LOG_DIR/$LIBRETRO_LOG_SUPER"
[ -z "$LIBRETRO_LOG_APPEND" ] && : > $log_super
fi
# Core log can't be handled here