refactoring: extracted function determine_log_level.