<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_messenger(config):
 """Return an appropriate Messenger. If we're in debug mode, or email settings aren't set, return a debug version which logs the message instead of attempting to send a real email. """

    email_settings = EmailConfig(config)
    if config.get("mode") == "debug":
        return DebugMessenger(email_settings)
    problems = email_settings.validate()
    if problems:
        logger.info(problems + " Will log errors instead of emailing them.")
        return DebugMessenger(email_settings)
    return EmailingMessenger(email_settings)