Revision f2bdb9ab logic/email_send.py

b/logic/email_send.py
35 35
from django.conf import settings
36 36
import amqp_connection
37 37

  
38
from synnefo.logic import log
39

  
40
_logger = log.get_logger("synnefo.logic")
38 41

  
39 42
def send_async(frm = settings.SYSTEM_EMAIL_ADDR,
40 43
               to = None, subject = None, body = None):
......
55 58

  
56 59
def send (sender = settings.SYSTEM_EMAIL_ADDR,
57 60
          recipient = None, subject = None, body = None):
58
    import logging
59
    logger = logging.getLogger("synnefo.logic")
61

  
60 62
    attempts = 0
61 63

  
62 64
    while attempts < 3:
......
64 66
            send_mail(subject, body, sender, [recipient])
65 67
            return True
66 68
        except Exception as e:
67
            logger.error("Error sending email: %s", e)
69
            _logger.exception("Error sending email")
68 70
        finally:
69 71
            attempts += 1
70 72

  
71
    logger.warn("Failed all %d attempts to send email, aborting", attempts)
73
    _logger.warn("Failed all %d attempts to send email, aborting", attempts)
72 74
    return False
73 75

  

Also available in: Unified diff