libretro-super/script-modules/log.sh

40 lines
857 B
Bash
Raw Normal View History

2015-03-27 23:45:38 +00:00
# vim: set ts=3 sw=3 noet ft=sh : bash
color() {
[ -n "$use_color" ] && echo -n "[0;${1:-0}m"
}
lecho() {
if [ -n "$LIBRETRO_LOG_SUPER" ]; then
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.
2015-03-28 02:31:19 +00:00
echo "$@" >> $log_super
2015-03-27 23:45:38 +00:00
fi
}
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}"
2015-03-28 01:31:51 +00:00
libretro_log_init() {
if [ -z "$LIBRETRO_LOG_SUPER" -a -z "$LIBRETRO_LOG_CORE" ]; then
return
fi
mkdir -p "$LIBRETRO_LOG_DIR"
if [ -n "$LIBRETRO_LOG_SUPER" ]; then
log_super="$LIBRETRO_LOG_DIR/$LIBRETRO_LOG_SUPER"
[ -z "$LIBRETRO_LOG_APPEND" ] && : > $log_super
fi
# Core log can't be truncated here
}
2015-03-27 23:45:38 +00:00
# TODO: Move this into libretro_log_init once libretro-fetch is fixed
2015-03-28 01:31:51 +00:00
if [[ -n $FORCE_COLOR || -t 1 && -z "$NO_COLOR" ]]; then
2015-03-27 23:45:38 +00:00
want_color=1
use_color=1
else
want_color=""
use_color=""
fi