redirect log messages to stderr
#!/bin/bash
# Function to perform an action, return a value, and log messages
my_function() {
local input_value="$1"
local result_value=$((input_value * 2))
# Emit log messages to stderr
echo "INFO: Processing input: $input_value" >&2
echo "DEBUG: Intermediate calculation: $result_value" >&2
# Echo the return value to stdout
echo "$result_value"
}
# Call the function using command substitution to capture the return value
returned_value=$(my_function 5)
# Log messages from the main script
echo "INFO: Function returned: $returned_value"