Skip to content

Commit

Permalink
Add DEBUG prefix to log messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Scavo committed Apr 26, 2017
1 parent 89febc6 commit fe2edd3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion bin/cget.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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_$$"
Expand Down
26 changes: 13 additions & 13 deletions lib/http_tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 ))
Expand All @@ -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"

#######################################################################
#
Expand All @@ -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
Expand Down Expand Up @@ -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

#######################################################################
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit fe2edd3

Please sign in to comment.