From fe2edd3e1b456e00ea6e85daa571f102de5a1bbe Mon Sep 17 00:00:00 2001 From: Tom Scavo Date: Wed, 26 Apr 2017 13:16:03 -0400 Subject: [PATCH] Add DEBUG prefix to log messages --- bin/cget.sh | 2 +- lib/http_tools.sh | 26 +++++++++++++------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/bin/cget.sh b/bin/cget.sh index a30d344..10149db 100755 --- a/bin/cget.sh +++ b/bin/cget.sh @@ -216,7 +216,7 @@ 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 "$script_name creating temp dir: $tmp_dir" "$log_file" +$verbose_mode && print_log_message -D "$script_name creating temp dir: $tmp_dir" "$log_file" # temporary file tmp_file="${tmp_dir}/http_resource_$$" diff --git a/lib/http_tools.sh b/lib/http_tools.sh index c4f08fe..7575ea1 100755 --- a/lib/http_tools.sh +++ b/lib/http_tools.sh @@ -178,7 +178,7 @@ conditional_get () { echo "ERROR: $FUNCNAME: directory does not exist: $tmp_dir" >&2 return 2 fi - $verbose_mode && print_log_message "$FUNCNAME using temporary directory $tmp_dir" "$log_file" + $verbose_mode && print_log_message -D "$FUNCNAME using temporary directory $tmp_dir" "$log_file" # a cache directory is required if [ -z "$cache_dir" ]; then @@ -189,7 +189,7 @@ conditional_get () { echo "ERROR: $FUNCNAME: directory does not exist: $cache_dir" >&2 return 2 fi - $verbose_mode && print_log_message "$FUNCNAME using cache directory $cache_dir" "$log_file" + $verbose_mode && print_log_message -D "$FUNCNAME using cache directory $cache_dir" "$log_file" # determine the URL location shift $(( OPTIND - 1 )) @@ -202,7 +202,7 @@ conditional_get () { echo "ERROR: $FUNCNAME: empty URL argument" >&2 return 2 fi - $verbose_mode && print_log_message "$FUNCNAME using location $location" "$log_file" + $verbose_mode && print_log_message -D "$FUNCNAME using location $location" "$log_file" ####################################################################### # @@ -228,8 +228,8 @@ conditional_get () { cached_content_file="$cache_dir/${hash}_content" if $verbose_mode; then - print_log_message "$FUNCNAME using cached header file: ${cached_header_file}" "$log_file" - print_log_message "$FUNCNAME using cached content file: ${cached_content_file}" "$log_file" + print_log_message -D "$FUNCNAME using cached header file: ${cached_header_file}" "$log_file" + print_log_message -D "$FUNCNAME using cached content file: ${cached_content_file}" "$log_file" fi # check if the resource is cached @@ -265,9 +265,9 @@ conditional_get () { tmp_stderr_file="$tmp_dir/${FUNCNAME}_curl_stderr" if $verbose_mode; then - print_log_message "$FUNCNAME using temp header file: ${tmp_header_file}" "$log_file" - print_log_message "$FUNCNAME using temp content file: ${tmp_content_file}" "$log_file" - print_log_message "$FUNCNAME using temp stderr file: ${tmp_stderr_file}" "$log_file" + print_log_message -D "$FUNCNAME using temp header file: ${tmp_header_file}" "$log_file" + print_log_message -D "$FUNCNAME using temp content file: ${tmp_content_file}" "$log_file" + print_log_message -D "$FUNCNAME using temp stderr file: ${tmp_stderr_file}" "$log_file" fi ####################################################################### @@ -321,7 +321,7 @@ conditional_get () { # invoke curl cmd="/usr/bin/curl $curl_opts $location" - $verbose_mode && print_log_message "$FUNCNAME issuing curl command: $cmd" "$log_file" + $verbose_mode && print_log_message -D "$FUNCNAME issuing curl command: $cmd" "$log_file" eval $cmd exit_code=$? if [ $exit_code -ne 0 ]; then @@ -375,11 +375,11 @@ conditional_get () { fi if $verbose_mode; then - print_log_message "$FUNCNAME downloaded ${actual_content_length} bytes" "$log_file" + print_log_message -D "$FUNCNAME downloaded ${actual_content_length} bytes" "$log_file" if $do_conditional_get; then - print_log_message "$FUNCNAME refreshing cache files" "$log_file" + print_log_message -D "$FUNCNAME refreshing cache files" "$log_file" else - print_log_message "$FUNCNAME initializing cache files" "$log_file" + print_log_message -D "$FUNCNAME initializing cache files" "$log_file" fi fi @@ -407,7 +407,7 @@ conditional_get () { return 1 fi - $verbose_mode && print_log_message "$FUNCNAME downloaded 0 bytes (cache is up-to-date)" "$log_file" + $verbose_mode && print_log_message -D "$FUNCNAME downloaded 0 bytes (cache is up-to-date)" "$log_file" else echo "ERROR: $FUNCNAME failed with HTTP response code $response_code" >&2 return 9