Skip to content

Commit

Permalink
Remove local log_file var; add global LOG_LEVEL env var
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Scavo committed May 1, 2017
1 parent d214d76 commit 65ba9d4
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions bin/cget.sh
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ fi
# Process command-line options and arguments
#######################################################################

# default to INFO logging
if [ -z "$LOG_LEVEL" ]; then
LOG_LEVEL=3
fi

help_mode=false; verbose_mode=false; quiet_mode=false; local_opts=
while getopts ":hvqFC" opt; do
case $opt in
Expand All @@ -161,11 +166,13 @@ while getopts ":hvqFC" opt; do
v)
verbose_mode=true
quiet_mode=false
LOG_LEVEL=4
local_opts="$local_opts -$opt"
;;
q)
verbose_mode=false
quiet_mode=true
LOG_LEVEL=0
;;
F)
local_opts="$local_opts -$opt"
Expand Down Expand Up @@ -201,22 +208,14 @@ location="$1"
# Initialization
#######################################################################

# determine the log file
if $quiet_mode; then
log_file=/dev/null
else
log_file="$CACHE_DIR/cget_log.txt"
local_opts="$local_opts -L $log_file"
fi

# create temporary subdirectory
/bin/mkdir "$tmp_dir"
status_code=$?
if [ $status_code -ne 0 ]; then
echo "ERROR: $script_name failed to create tmp dir ($status_code) $tmp_dir" >&2
exit 2
fi
$verbose_mode && print_log_message -D "$script_name creating temp dir: $tmp_dir" "$log_file"
$verbose_mode && print_log_message -D "$script_name creating temp dir: $tmp_dir"

# temporary file
tmp_file="${tmp_dir}/http_resource_$$"
Expand All @@ -228,7 +227,7 @@ tmp_file="${tmp_dir}/http_resource_$$"
# Functions print_log_message and clean_up_and_exit defined in core_lib.sh
# Function conditional_get defined in http_tools.sh

print_log_message "$script_name requesting resource: $location" "$log_file"
print_log_message "$script_name requesting resource: $location"

# get the resource
conditional_get $local_opts -d "$CACHE_DIR" -T "$tmp_dir" "$location" > "$tmp_file"
Expand Down

0 comments on commit 65ba9d4

Please sign in to comment.