Setup terminal logging as soon as possible.

- Separate setup_logging(...) into setup_file_logging(...) and setup_terminal_logging()
- This change makes terminal logging work for handle_profiles(...).
- Why can't file logging work for handle_profiles(...) too? Files to log to reside in the particular profile's
directory and we can't know what the directory is before calling handle_profiles(...).