summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/mail/imap
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap/bitmask/mail/imap')
-rw-r--r--src/leap/bitmask/mail/imap/account.py8
-rw-r--r--src/leap/bitmask/mail/imap/mailbox.py7
-rw-r--r--src/leap/bitmask/mail/imap/messages.py6
-rw-r--r--src/leap/bitmask/mail/imap/server.py20
-rw-r--r--src/leap/bitmask/mail/imap/service/__init__.py7
5 files changed, 24 insertions, 24 deletions
diff --git a/src/leap/bitmask/mail/imap/account.py b/src/leap/bitmask/mail/imap/account.py
index d885d591..8ee0cbfa 100644
--- a/src/leap/bitmask/mail/imap/account.py
+++ b/src/leap/bitmask/mail/imap/account.py
@@ -17,14 +17,14 @@
"""
Soledad Backed IMAP Account.
"""
-import logging
import os
import time
from functools import partial
from twisted.internet import defer
+from twisted.logger import Logger
from twisted.mail import imap4
-from twisted.python import log
+from twisted.logger import Logger
from zope.interface import implements
from leap.common.check import leap_assert, leap_assert_type
@@ -33,7 +33,7 @@ from leap.bitmask.mail.mail import Account
from leap.bitmask.mail.imap.mailbox import IMAPMailbox, normalize_mailbox
from leap.soledad.client import Soledad
-logger = logging.getLogger(__name__)
+logger = Logger()
PROFILE_CMD = os.environ.get('LEAP_PROFILE_IMAPCMD', False)
@@ -247,7 +247,7 @@ class IMAPAccount(object):
def check_it_exists(mailboxes):
if name not in mailboxes:
- logger.warning("SELECT: No such mailbox!")
+ logger.warn('SELECT: No such mailbox!')
return None
return name
diff --git a/src/leap/bitmask/mail/imap/mailbox.py b/src/leap/bitmask/mail/imap/mailbox.py
index b80280c6..10ac01e4 100644
--- a/src/leap/bitmask/mail/imap/mailbox.py
+++ b/src/leap/bitmask/mail/imap/mailbox.py
@@ -18,7 +18,6 @@
IMAP Mailbox.
"""
import re
-import logging
import os
import cStringIO
import StringIO
@@ -29,7 +28,7 @@ from email.utils import formatdate
from twisted.internet import defer
from twisted.internet import reactor
-from twisted.python import log
+from twisted.logger import Logger
from twisted.mail import imap4
from zope.interface import implements
@@ -39,7 +38,7 @@ from leap.common.check import leap_assert_type
from leap.bitmask.mail.constants import INBOX_NAME, MessageFlags
from leap.bitmask.mail.imap.messages import IMAPMessage
-logger = logging.getLogger(__name__)
+logger = Logger()
# TODO LIST
# [ ] Restore profile_cmd instrumentation
@@ -894,7 +893,7 @@ class IMAPMailbox(object):
return d
# nothing implemented for any other query
- logger.warning("Cannot process query: %s" % (query,))
+ logger.warn("Cannot process query: %s" % (query,))
return []
# IMessageCopier
diff --git a/src/leap/bitmask/mail/imap/messages.py b/src/leap/bitmask/mail/imap/messages.py
index 841ebb2f..98d64fe5 100644
--- a/src/leap/bitmask/mail/imap/messages.py
+++ b/src/leap/bitmask/mail/imap/messages.py
@@ -17,15 +17,15 @@
"""
IMAPMessage implementation.
"""
-import logging
from twisted.mail import imap4
from twisted.internet import defer
+from twisted.logger import Logger
from zope.interface import implements
from leap.bitmask.mail.utils import find_charset, CaseInsensitiveDict
-logger = logging.getLogger(__name__)
+logger = Logger()
# TODO
# [ ] Add ref to incoming message during add_msg.
@@ -213,7 +213,7 @@ def _format_headers(headers, negate, *names):
# some reason we do not have headers, we have to return at least that
# one
if not headers:
- logger.warning("No headers found")
+ logger.warn("No headers found")
return {str('content-type'): str('')}
names = map(lambda s: s.upper(), names)
diff --git a/src/leap/bitmask/mail/imap/server.py b/src/leap/bitmask/mail/imap/server.py
index 5a63af01..897e1f05 100644
--- a/src/leap/bitmask/mail/imap/server.py
+++ b/src/leap/bitmask/mail/imap/server.py
@@ -22,7 +22,7 @@ from copy import copy
from twisted.internet.defer import maybeDeferred
from twisted.mail import imap4
-from twisted.python import log
+from twisted.logger import Logger
# imports for LITERAL+ patch
from twisted.internet import defer, interfaces
@@ -32,6 +32,9 @@ from twisted.mail.imap4 import LiteralString, LiteralFile
from leap.common.events import emit_async, catalog
+logger = Logger()
+
+
def _getContentType(msg):
"""
Return a two-tuple of the main and subtype of the given message.
@@ -164,7 +167,7 @@ class LEAPIMAPServer(imap4.IMAP4Server):
msg = line[:7] + " [...]"
else:
msg = copy(line)
- log.msg('rcv (%s): %s' % (self.state, msg))
+ logger.debug('rcv (%s): %s' % (self.state, msg))
imap4.IMAP4Server.lineReceived(self, line)
def close_server_connection(self):
@@ -449,7 +452,7 @@ class LEAPIMAPServer(imap4.IMAP4Server):
def _subscribeEb(failure):
m = failure.value
- log.err()
+ logger.error()
if failure.check(imap4.MailboxException):
self.sendNegativeResponse(tag, str(m))
else:
@@ -474,7 +477,7 @@ class LEAPIMAPServer(imap4.IMAP4Server):
def _unsubscribeEb(failure):
m = failure.value
- log.err()
+ logger.error()
if failure.check(imap4.MailboxException):
self.sendNegativeResponse(tag, str(m))
else:
@@ -509,7 +512,7 @@ class LEAPIMAPServer(imap4.IMAP4Server):
elif failure.check(imap4.MailboxException):
self.sendNegativeResponse(tag, str(m))
else:
- log.err()
+ logger.error()
self.sendBadResponse(
tag,
"Server error encountered while "
@@ -536,7 +539,7 @@ class LEAPIMAPServer(imap4.IMAP4Server):
if failure.check(imap4.MailboxException):
self.sendNegativeResponse(tag, str(c))
else:
- log.err()
+ logger.error()
self.sendBadResponse(
tag, "Server error encountered while creating mailbox")
@@ -561,8 +564,7 @@ class LEAPIMAPServer(imap4.IMAP4Server):
if failure.check(imap4.MailboxException):
self.sendNegativeResponse(tag, str(m))
else:
- print "SERVER: other error"
- log.err()
+ logger.error()
self.sendBadResponse(
tag,
"Server error encountered while deleting mailbox")
@@ -598,7 +600,7 @@ class LEAPIMAPServer(imap4.IMAP4Server):
def _ebAppendGotMailbox(self, failure, tag):
self.sendBadResponse(
tag, "Server error encountered while opening mailbox.")
- log.err(failure)
+ logger.error(failure)
def __cbAppend(self, result, tag, mbox):
diff --git a/src/leap/bitmask/mail/imap/service/__init__.py b/src/leap/bitmask/mail/imap/service/__init__.py
index d9cd3359..b0ad05d2 100644
--- a/src/leap/bitmask/mail/imap/service/__init__.py
+++ b/src/leap/bitmask/mail/imap/service/__init__.py
@@ -17,18 +17,17 @@
"""
IMAP Service Initialization.
"""
-import logging
import os
from collections import defaultdict
from twisted.cred.portal import Portal, IRealm
-from twisted.mail.imap4 import IAccount
from twisted.internet import defer
from twisted.internet import reactor
from twisted.internet.error import CannotListenError
from twisted.internet.protocol import ServerFactory
-from twisted.python import log
+from twisted.logger import Logger
+from twisted.mail.imap4 import IAccount
from zope.interface import implementer
from leap.common.events import emit_async, catalog
@@ -38,7 +37,7 @@ from leap.bitmask.mail.imap.server import LEAPIMAPServer
# TODO: leave only an implementor of IService in here
-logger = logging.getLogger(__name__)
+logger = Logger()
DO_MANHOLE = os.environ.get("LEAP_MAIL_MANHOLE", None)
if DO_MANHOLE: