Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Make sage-logger output to stdout the name(s) of log(s) a line is bei…
Browse files Browse the repository at this point in the history
…ng logged to.
  • Loading branch information
embray committed May 20, 2016
1 parent f76401f commit 632a6b3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion build/bin/sage-logger
Expand Up @@ -22,14 +22,16 @@

cmd="$1"
logfile="$2"
logname="$(basename $logfile .log)"
logdir=`dirname "$logfile"`

mkdir -p "$logdir"

# Redirect stdout and stderr to a subprocess running tee.
# We trap SIGINT such that SIGINT interrupts the main process being
# run, not the logging.
( exec 2>&1; eval "$cmd" ) | ( trap '' SIGINT; tee -a "$logfile" )
( exec 2>&1; eval "$cmd" ) | ( trap '' SIGINT; tee -a "$logfile" ) | \
(while read line; do echo [${logname}] $line; done)

pipestatus=(${PIPESTATUS[*]})

Expand Down

0 comments on commit 632a6b3

Please sign in to comment.