You can use a redirection around any command, including compound commands. For example:
some_function () {
  echo "This also $1 to the file"
}
{
  echo "This goes to the file"
  some_function "goes"
} >some_file
echo "This does not go to the file"
some_function "does not go"
You can do a permanent redirection (which applies until the end of the script or until overridden by another redirection) by calling the exec builtin with a redirection, but no command. For example:
foo () {
  echo "This does not go to the file"
  exec >some_file
  echo "This goes to the file"
}
foo
echo "This still goes to the file"
These features are available in all Bourne/POSIX-style shells including bash.
     
    
stdbuf(1)to make stdout line-buffered in that case.