summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/mail/smtp/gateway.py
diff options
context:
space:
mode:
authorKali Kaneko (leap communications) <kali@leap.se>2016-10-05 12:28:14 -0400
committerKali Kaneko (leap communications) <kali@leap.se>2016-10-07 10:22:36 -0400
commit99b53c1714d302d7f0884e03b5c102081c483504 (patch)
tree82ac74e776a330338bf94563273aa4d33f578877 /src/leap/bitmask/mail/smtp/gateway.py
parent4a471fb8b434d3df07c5de42fc41590b5d9fc5f5 (diff)
[refactor] use new logger infrastructure
Diffstat (limited to 'src/leap/bitmask/mail/smtp/gateway.py')
-rw-r--r--src/leap/bitmask/mail/smtp/gateway.py22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/leap/bitmask/mail/smtp/gateway.py b/src/leap/bitmask/mail/smtp/gateway.py
index 16e1af97..b1fafadd 100644
--- a/src/leap/bitmask/mail/smtp/gateway.py
+++ b/src/leap/bitmask/mail/smtp/gateway.py
@@ -39,7 +39,7 @@ from twisted.cred.portal import Portal, IRealm
from twisted.mail import smtp
from twisted.mail.imap4 import LOGINCredentials, PLAINCredentials
from twisted.internet import defer, protocol
-from twisted.python import log
+from twisted.logger import Logger
from leap.common.check import leap_assert_type
from leap.common.events import emit_async, catalog
@@ -56,6 +56,8 @@ generator.Generator = RFC3156CompliantGenerator
LOCAL_FQDN = "bitmask.local"
+logger = Logger()
+
@implementer(IRealm)
class LocalSMTPRealm(object):
@@ -296,7 +298,7 @@ class SMTPDelivery(object):
# verify if recipient key is available in keyring
def found(_):
- log.msg("Accepting mail for %s..." % user.dest.addrstr)
+ logger.debug("Accepting mail for %s..." % user.dest.addrstr)
emit_async(catalog.SMTP_RECIPIENT_ACCEPTED_ENCRYPTED,
self._userid, user.dest.addrstr)
@@ -308,8 +310,9 @@ class SMTPDelivery(object):
emit_async(catalog.SMTP_RECIPIENT_REJECTED, self._userid,
user.dest.addrstr)
raise smtp.SMTPBadRcpt(user.dest.addrstr)
- log.msg("Warning: will send an unencrypted message (because "
- "encrypted_only' is set to False).")
+ logger.warn(
+ 'Warning: will send an unencrypted message (because '
+ '"encrypted_only" is set to False).')
emit_async(
catalog.SMTP_RECIPIENT_ACCEPTED_UNENCRYPTED,
self._userid, user.dest.addrstr)
@@ -341,8 +344,9 @@ class SMTPDelivery(object):
# accept mail from anywhere. To reject an address, raise
# smtp.SMTPBadSender here.
if str(origin) != str(self._userid):
- log.msg("Rejecting sender {0}, expected {1}".format(origin,
- self._userid))
+ logger.error(
+ "Rejecting sender {0}, expected {1}".format(origin,
+ self._userid))
raise smtp.SMTPBadSender(origin)
self._origin = origin
return origin
@@ -392,7 +396,7 @@ class EncryptedMessage(object):
:returns: a deferred
"""
- log.msg("Message data complete.")
+ logger.debug("Message data complete.")
self._lines.append('') # add a trailing newline
raw_mail = '\r\n'.join(self._lines)
@@ -402,8 +406,8 @@ class EncryptedMessage(object):
"""
Log an error when the connection is lost.
"""
- log.msg("Connection lost unexpectedly!")
- log.err()
+ logger.error("Connection lost unexpectedly!")
+ logger.error()
emit_async(catalog.SMTP_CONNECTION_LOST, self._userid,
self._user.dest.addrstr)
# unexpected loss of connection; don't save