title: Logging functions in bash and stdout
body: <p>I'd like to be able to put log messages in the middle of bash functions, without affecting the output of those very functions.  For example, consider the following functions <code>log()</code> and <code>get_animals()</code>:</p>
  
  <pre><code># print a log a message
  log ()
  {
      echo "Log message: $1"
  }
  
  get_animals()
  {
      log "Fetching animals"
      echo "cat dog mouse"
  }
  
  values=`get_animals`
  echo $values
  </code></pre>
  
  <p>After which <code>$values</code> contains the string <code>"Log message: Fetching animals cat dog mouse"</code>.</p>
  
  <p>How should I modify this script so that <code>"Log message: Fetching animals"</code> is outputted to the terminal, and <code>$values</code> contains <code>"cat dog mouse"</code>?</p>