Minor adjustment to _Logger
This commit is contained in:
parent
f14903cce5
commit
7e44139325
|
@ -1,7 +1,7 @@
|
||||||
#### MINIMAL-FUNCTION-SET BEGIN ####
|
#### MINIMAL-FUNCTION-SET BEGIN ####
|
||||||
|
|
||||||
_OFUNCTIONS_VERSION=2.0
|
_OFUNCTIONS_VERSION=2.0
|
||||||
_OFUNCTIONS_BUILD=2016120601
|
_OFUNCTIONS_BUILD=2016120701
|
||||||
## BEGIN Generic bash functions written in 2013-2016 by Orsiris de Jong - http://www.netpower.fr - ozy@netpower.fr
|
## BEGIN Generic bash functions written in 2013-2016 by Orsiris de Jong - http://www.netpower.fr - ozy@netpower.fr
|
||||||
|
|
||||||
## To use in a program, define the following variables:
|
## To use in a program, define the following variables:
|
||||||
|
@ -73,8 +73,10 @@ if [ -w /var/log ]; then
|
||||||
LOG_FILE="/var/log/$PROGRAM.log"
|
LOG_FILE="/var/log/$PROGRAM.log"
|
||||||
elif ([ "$HOME" != "" ] && [ -w "$HOME" ]); then
|
elif ([ "$HOME" != "" ] && [ -w "$HOME" ]); then
|
||||||
LOG_FILE="$HOME/$PROGRAM.log"
|
LOG_FILE="$HOME/$PROGRAM.log"
|
||||||
else
|
elif [ -w . ]; then
|
||||||
LOG_FILE="./$PROGRAM.log"
|
LOG_FILE="./$PROGRAM.log"
|
||||||
|
else
|
||||||
|
LOG_FILE="/tmp/$PROGRAM.log"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
## Default directory where to store temporary run files
|
## Default directory where to store temporary run files
|
||||||
|
@ -101,15 +103,18 @@ function Dummy {
|
||||||
sleep $SLEEP_TIME
|
sleep $SLEEP_TIME
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#### MINIMAL-FUNCTION-SET BEGIN ####
|
||||||
# Sub function of Logger
|
# Sub function of Logger
|
||||||
function _Logger {
|
function _Logger {
|
||||||
local logValue="${1}" # Log to file
|
local logValue="${1}" # Log to file
|
||||||
local stdValue="${2}" # Log to screeen
|
local stdValue="${2}" # Log to screeen
|
||||||
local toStderr="${3:-false}" # Log to stderr instead of stdout
|
local toStderr="${3:-false}" # Log to stderr instead of stdout
|
||||||
|
|
||||||
echo -e "$logValue" >> "$LOG_FILE"
|
if [ "$logValue" != "" ]; then
|
||||||
# Current log file
|
echo -e "$logValue" >> "$LOG_FILE"
|
||||||
echo -e "$logValue" >> "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID"
|
# Current log file
|
||||||
|
echo -e "$logValue" >> "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$stdValue" != "" ] && [ "$_LOGGER_SILENT" != true ]; then
|
if [ "$stdValue" != "" ] && [ "$_LOGGER_SILENT" != true ]; then
|
||||||
if [ $toStderr == true ]; then
|
if [ $toStderr == true ]; then
|
||||||
|
|
Loading…
Reference in New Issue