log to stdout/stderr appropriately
parent
71b0138a74
commit
e5bb648c80
|
@ -1,6 +1,9 @@
|
|||
# Lines starting with '##' are intended for usage documentation
|
||||
# Does nothing if not using stdout
|
||||
function usage() {
|
||||
grep '^##' "$prog" | sed -e 's/^##\s\?//' -e "s/__PROG__/$me/" 1>&2
|
||||
if [ -t 1 ]; then
|
||||
grep '^##' "$prog" | sed -e 's/^##\s\?//' -e "s/__PROG__/$me/" 1>&2
|
||||
fi
|
||||
}
|
||||
|
||||
function nowstr() {
|
||||
|
@ -17,8 +20,8 @@ function log() {
|
|||
|
||||
function logerr() {
|
||||
if [ -t 2 ]; then
|
||||
printf "$(tput setaf 1)[${me}]$(tput sgr0) ${1}\n" ${@:2}
|
||||
printf "$(tput setaf 1)[${me}] ERROR:$(tput sgr0) ${1}\n" ${@:2} 1>&2
|
||||
else
|
||||
printf "$(nowstr) [${me}] ${1}\n" ${@:2}
|
||||
printf "$(nowstr) [${me}] ERROR: ${1}\n" ${@:2} 1>&2
|
||||
fi
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue