summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
Diffstat (limited to 'service')
-rw-r--r--service/pixelated/adapter/listeners/mailbox_indexer_listener.py5
-rw-r--r--service/pixelated/adapter/mailstore/body_parser.py7
-rw-r--r--service/pixelated/adapter/mailstore/maintenance/__init__.py4
-rw-r--r--service/pixelated/adapter/model/mail.py12
-rw-r--r--service/pixelated/application.py1
-rw-r--r--service/pixelated/bitmask_libraries/keymanager.py8
-rw-r--r--service/pixelated/config/leap.py7
-rw-r--r--service/pixelated/config/services.py8
-rw-r--r--service/pixelated/config/sessions.py10
-rw-r--r--service/pixelated/maintenance.py13
-rw-r--r--service/pixelated/register.py11
-rw-r--r--service/pixelated/resources/__init__.py6
-rw-r--r--service/pixelated/resources/attachments_resource.py5
-rw-r--r--service/pixelated/resources/auth.py6
-rw-r--r--service/pixelated/resources/login_resource.py5
-rw-r--r--service/pixelated/resources/mails_resource.py21
-rw-r--r--service/pixelated/support/__init__.py4
-rw-r--r--service/test/functional/features/environment.py23
-rw-r--r--service/test/perf/contacts/test_Contacts.py2
-rw-r--r--service/test/unit/adapter/mailstore/maintenance/test_soledad_maintenance.py3
-rw-r--r--service/test/unit/resources/test_attachments_resource.py4
-rw-r--r--service/test/unit/resources/test_tags_resource.py4
-rw-r--r--service/twisted/plugins/logger.py15
23 files changed, 88 insertions, 96 deletions
diff --git a/service/pixelated/adapter/listeners/mailbox_indexer_listener.py b/service/pixelated/adapter/listeners/mailbox_indexer_listener.py
index 97a887f4..9cc522cf 100644
--- a/service/pixelated/adapter/listeners/mailbox_indexer_listener.py
+++ b/service/pixelated/adapter/listeners/mailbox_indexer_listener.py
@@ -13,11 +13,10 @@
#
# You should have received a copy of the GNU Affero General Public License
# along with Pixelated. If not, see <http://www.gnu.org/licenses/>.
-import logging
from twisted.internet import defer
+from twisted.logger import Logger
-
-logger = logging.getLogger(__name__)
+logger = Logger()
class MailboxIndexerListener(object):
diff --git a/service/pixelated/adapter/mailstore/body_parser.py b/service/pixelated/adapter/mailstore/body_parser.py
index 7fb084af..5408bd9d 100644
--- a/service/pixelated/adapter/mailstore/body_parser.py
+++ b/service/pixelated/adapter/mailstore/body_parser.py
@@ -14,11 +14,12 @@
# You should have received a copy of the GNU Affero General Public License
# along with Pixelated. If not, see <http://www.gnu.org/licenses/>.
-from email.parser import Parser
import re
-import logging
+from email.parser import Parser
+
+from twisted.logger import Logger
-logger = logging.getLogger(__name__)
+logger = Logger()
def _parse_charset_header(content_type_and_charset_header, default_charset='us-ascii'):
diff --git a/service/pixelated/adapter/mailstore/maintenance/__init__.py b/service/pixelated/adapter/mailstore/maintenance/__init__.py
index 5dbe57ad..9a1007cc 100644
--- a/service/pixelated/adapter/mailstore/maintenance/__init__.py
+++ b/service/pixelated/adapter/mailstore/maintenance/__init__.py
@@ -17,7 +17,7 @@ from leap.bitmask.keymanager import documents as leap_doc
from leap.bitmask.keymanager.keys import OpenPGPKey
from twisted.internet import defer
-import logging
+from twisted.logger import Logger
TYPE_OPENPGP_KEY = 'OpenPGPKey'
@@ -25,7 +25,7 @@ TYPE_OPENPGP_ACTIVE = 'OpenPGPKey-active'
KEY_DOC_TYPES = {TYPE_OPENPGP_ACTIVE, TYPE_OPENPGP_KEY}
-logger = logging.getLogger(__name__)
+logger = Logger()
def _is_key_doc(doc):
diff --git a/service/pixelated/adapter/model/mail.py b/service/pixelated/adapter/model/mail.py
index 86f2642a..b6a8beb0 100644
--- a/service/pixelated/adapter/model/mail.py
+++ b/service/pixelated/adapter/model/mail.py
@@ -14,20 +14,22 @@
# You should have received a copy of the GNU Affero General Public License
# along with Pixelated. If not, see <http://www.gnu.org/licenses/>.
import re
-import logging
+import binascii
from email.mime.text import MIMEText
from email.header import Header
from hashlib import sha256
-
-import binascii
from email.MIMEMultipart import MIMEMultipart
from email.mime.nonmultipart import MIMENonMultipart
-import leap.bitmask.mail.walk as walk
+
+from twisted.logger import Logger
+
+from leap.bitmask.mail import walk
+
from pixelated.adapter.model.status import Status
from pixelated.support import date
-logger = logging.getLogger(__name__)
+logger = Logger()
class Mail(object):
diff --git a/service/pixelated/application.py b/service/pixelated/application.py
index ad13e7b6..2b97f5b3 100644
--- a/service/pixelated/application.py
+++ b/service/pixelated/application.py
@@ -140,7 +140,6 @@ def add_top_level_system_callbacks(deferred, services_factory):
def _start_mode(args, resource, services_factory):
- log.debug('_start_mode')
if services_factory.mode.is_single_user:
deferred = _start_in_single_user_mode(args, resource, services_factory)
else:
diff --git a/service/pixelated/bitmask_libraries/keymanager.py b/service/pixelated/bitmask_libraries/keymanager.py
index 56b7d944..e9868662 100644
--- a/service/pixelated/bitmask_libraries/keymanager.py
+++ b/service/pixelated/bitmask_libraries/keymanager.py
@@ -13,12 +13,14 @@
#
# You should have received a copy of the GNU Affero General Public License
# along with Pixelated. If not, see <http://www.gnu.org/licenses/>.
+from twisted.internet import defer
+from twisted.logger import Logger
+
from leap.bitmask.keymanager import KeyManager, KeyNotFound
+
from pixelated.config import leap_config
-from twisted.internet import defer
-import logging
-logger = logging.getLogger(__name__)
+logger = Logger()
class UploadKeyError(Exception):
diff --git a/service/pixelated/config/leap.py b/service/pixelated/config/leap.py
index e9e4a796..b060170f 100644
--- a/service/pixelated/config/leap.py
+++ b/service/pixelated/config/leap.py
@@ -1,13 +1,16 @@
from __future__ import absolute_import
-import logging
from collections import namedtuple
+
from twisted.cred.error import UnauthorizedLogin
from twisted.internet import defer, threads
+from twisted.logger import Logger
+
from leap.common.events import (server as events_server)
from leap.soledad.common.errors import InvalidAuthTokenError
from leap.bitmask.bonafide._srp import SRPAuthError
from leap.bitmask.bonafide.session import Session
from leap.bitmask.bonafide.provider import Api
+
from pixelated.config import credentials
from pixelated.config import leap_config
from pixelated.config.authentication import Authentication
@@ -15,7 +18,7 @@ from pixelated.bitmask_libraries.certs import LeapCertificate
from pixelated.bitmask_libraries.provider import LeapProvider
from pixelated.config.sessions import LeapSessionFactory
-log = logging.getLogger(__name__)
+log = Logger()
Credentials = namedtuple('Credentials', 'username, password')
diff --git a/service/pixelated/config/services.py b/service/pixelated/config/services.py
index 116e903a..1f59c255 100644
--- a/service/pixelated/config/services.py
+++ b/service/pixelated/config/services.py
@@ -1,5 +1,7 @@
import os
-import logging
+
+from twisted.internet import defer, reactor
+from twisted.logger import Logger
from pixelated.adapter.mailstore.leap_attachment_store import LeapAttachmentStore
from pixelated.adapter.mailstore.searchable_mailstore import SearchableMailStore
@@ -9,11 +11,11 @@ from pixelated.adapter.services.mail_sender import MailSender
from pixelated.adapter.search import SearchEngine
from pixelated.adapter.services.draft_service import DraftService
from pixelated.adapter.listeners.mailbox_indexer_listener import listen_all_mailboxes
-from twisted.internet import defer, reactor
from pixelated.adapter.search.index_storage_key import SearchIndexStorageKey
from pixelated.adapter.services.feedback_service import FeedbackService
from pixelated.config import leap_config
-logger = logging.getLogger(__name__)
+
+logger = Logger()
class Services(object):
diff --git a/service/pixelated/config/sessions.py b/service/pixelated/config/sessions.py
index 2d186da5..ec5e1c0e 100644
--- a/service/pixelated/config/sessions.py
+++ b/service/pixelated/config/sessions.py
@@ -3,15 +3,14 @@ from __future__ import absolute_import
import os
import errno
import traceback
-
import requests
-import logging
-
import sys
+
from twisted.internet import defer, threads, reactor
+from twisted.logger import Logger
+
from leap.soledad.common.crypto import WrongMacError, UnknownMacMethodError
from leap.soledad.client import Soledad
-from pixelated.bitmask_libraries.keymanager import Keymanager
from leap.bitmask.mail.incoming.service import IncomingMail
from leap.bitmask.mail.mail import Account
import leap.common.certs as leap_certs
@@ -20,12 +19,13 @@ from leap.common.events import (
catalog as events
)
+from pixelated.bitmask_libraries.keymanager import Keymanager
from pixelated.adapter.mailstore import LeapMailStore
from pixelated.config import leap_config
from pixelated.bitmask_libraries.certs import LeapCertificate
from pixelated.bitmask_libraries.smtp import LeapSMTPConfig
-logger = logging.getLogger(__name__)
+logger = Logger()
class LeapSessionFactory(object):
diff --git a/service/pixelated/maintenance.py b/service/pixelated/maintenance.py
index 6807d9bc..74b5a369 100644
--- a/service/pixelated/maintenance.py
+++ b/service/pixelated/maintenance.py
@@ -14,26 +14,27 @@
# You should have received a copy of the GNU Affero General Public License
# along with Pixelated. If not, see <http://www.gnu.org/licenses/>.
+import random
from os.path import isfile
from mailbox import Maildir, mbox, MaildirMessage
-import random
-from leap.bitmask.mail.adaptors.soledad import MetaMsgDocWrapper
from twisted.internet import reactor, defer
from twisted.internet.threads import deferToThread
+from twisted.logger import Logger
+
+from leap.bitmask.mail.adaptors.soledad import MetaMsgDocWrapper
+from leap.bitmask.mail.constants import MessageFlags
+
from pixelated.adapter.mailstore.maintenance import SoledadMaintenance
from pixelated.config.leap import initialize_leap_single_user
from pixelated.config import logger, arguments
-import logging
-
-from leap.bitmask.mail.constants import MessageFlags
from pixelated.support.mail_generator import MailGenerator
REPAIR_COMMAND = 'repair'
INTEGRITY_CHECK_COMMAND = 'integrity-check'
-log = logging.getLogger(__name__)
+log = Logger()
def initialize():
diff --git a/service/pixelated/register.py b/service/pixelated/register.py
index 1b01fc0c..0269c832 100644
--- a/service/pixelated/register.py
+++ b/service/pixelated/register.py
@@ -15,19 +15,20 @@
# along with Pixelated. If not, see <http://www.gnu.org/licenses/>.
import re
import getpass
-import logging
import sys
+from twisted.logger import Logger
+
+from leap.auth import SRPAuth
+from leap.common.events import server as events_server
+
from pixelated.config import arguments
from pixelated.config import logger as logger_config
from pixelated.bitmask_libraries.certs import LeapCertificate
from pixelated.bitmask_libraries.provider import LeapProvider
from pixelated.config.sessions import LeapSessionFactory
-from leap.auth import SRPAuth
-from leap.common.events import server as events_server
-
-logger = logging.getLogger(__name__)
+logger = Logger()
def register(
diff --git a/service/pixelated/resources/__init__.py b/service/pixelated/resources/__init__.py
index 0bd34619..11611f0b 100644
--- a/service/pixelated/resources/__init__.py
+++ b/service/pixelated/resources/__init__.py
@@ -15,16 +15,16 @@
# along with Pixelated. If not, see <http://www.gnu.org/licenses/>.
import json
-import logging
from twisted.web.http import UNAUTHORIZED
from twisted.web.resource import Resource
+from twisted.logger import Logger
-# from pixelated.resources.login_resource import LoginResource
from pixelated.resources.session import IPixelatedSession
from twisted.web.http import INTERNAL_SERVER_ERROR, SERVICE_UNAVAILABLE
-log = logging.getLogger(__name__)
+
+log = Logger()
class SetEncoder(json.JSONEncoder):
diff --git a/service/pixelated/resources/attachments_resource.py b/service/pixelated/resources/attachments_resource.py
index 0149dfe2..1081b4b8 100644
--- a/service/pixelated/resources/attachments_resource.py
+++ b/service/pixelated/resources/attachments_resource.py
@@ -16,7 +16,6 @@
import cgi
import io
import re
-import logging
from twisted.internet import defer
from twisted.protocols.basic import FileSender
@@ -24,10 +23,12 @@ from twisted.python.log import msg
from twisted.web import server
from twisted.web.resource import Resource
from twisted.web.server import NOT_DONE_YET
+from twisted.logger import Logger
from pixelated.resources import respond_json_deferred, BaseResource
-logger = logging.getLogger(__name__)
+
+logger = Logger()
class AttachmentResource(Resource):
diff --git a/service/pixelated/resources/auth.py b/service/pixelated/resources/auth.py
index 6d675eb3..3afbbc36 100644
--- a/service/pixelated/resources/auth.py
+++ b/service/pixelated/resources/auth.py
@@ -14,27 +14,27 @@
# You should have received a copy of the GNU Affero General Public License
# along with Pixelated. If not, see <http://www.gnu.org/licenses/>.
-import logging
import re
+from zope.interface import implements, implementer, Attribute
from twisted.cred.checkers import ANONYMOUS
from twisted.cred.credentials import ICredentials
from twisted.cred.error import UnauthorizedLogin
from twisted.internet import defer
from twisted.web._auth.wrapper import UnauthorizedResource
from twisted.web.error import UnsupportedMethod
-from zope.interface import implements, implementer, Attribute
from twisted.cred import portal, checkers, credentials
from twisted.web import util
from twisted.cred import error
from twisted.web.resource import IResource, ErrorPage
+from twisted.logger import Logger
from leap.bitmask.bonafide._srp import SRPAuthError
from pixelated.config.leap import create_leap_session, authenticate
from pixelated.resources import IPixelatedSession
-log = logging.getLogger(__name__)
+log = Logger()
@implementer(checkers.ICredentialsChecker)
diff --git a/service/pixelated/resources/login_resource.py b/service/pixelated/resources/login_resource.py
index e19f9038..4c4d58c0 100644
--- a/service/pixelated/resources/login_resource.py
+++ b/service/pixelated/resources/login_resource.py
@@ -14,7 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with Pixelated. If not, see <http://www.gnu.org/licenses/>.
-import logging
import os
from xml.sax import SAXParseException
@@ -27,11 +26,13 @@ from twisted.web.resource import IResource, NoResource
from twisted.web.server import NOT_DONE_YET
from twisted.web.static import File
from twisted.web.template import Element, XMLFile, renderElement, renderer
+from twisted.logger import Logger
+
from pixelated.resources import handle_error_deferred
from pixelated.adapter.welcome_mail import add_welcome_mail
from pixelated.resources import BaseResource, UnAuthorizedResource, IPixelatedSession
-log = logging.getLogger(__name__)
+log = Logger()
def _get_startup_folder():
diff --git a/service/pixelated/resources/mails_resource.py b/service/pixelated/resources/mails_resource.py
index 0077ce57..78826126 100644
--- a/service/pixelated/resources/mails_resource.py
+++ b/service/pixelated/resources/mails_resource.py
@@ -1,20 +1,21 @@
import time
import json
-import logging
-from pixelated.adapter.services.mail_sender import SMTPDownException
-from pixelated.adapter.model.mail import InputMail
+
+from twisted.internet import defer
+from twisted.logger import Logger
from twisted.web.server import NOT_DONE_YET
-from pixelated.resources import respond_json_deferred, BaseResource
from twisted.web.resource import Resource
from twisted.web import server
-from twisted.internet import defer
-from twisted.python.log import err
+
from leap.common import events
+from pixelated.adapter.model.mail import InputMail
+from pixelated.resources import respond_json_deferred, BaseResource
+from pixelated.adapter.services.mail_sender import SMTPDownException
from pixelated.support.functional import to_unicode
-log = logging.getLogger(__name__)
+log = Logger()
class MailsUnreadResource(Resource):
@@ -66,7 +67,7 @@ class MailsDeleteResource(Resource):
def render_POST(self, request):
def response_failed(failure):
- err(failure, 'something failed')
+ logger.error(failure, 'something failed')
request.finish()
idents = json.loads(request.content.read())['idents']
@@ -174,7 +175,7 @@ class MailsResource(BaseResource):
if isinstance(error.value, SMTPDownException):
respond_json_deferred({'message': str(error.value)}, request, status_code=503)
else:
- err(error, 'error occurred while sending')
+ logger.error(error, 'error occurred while sending')
respond_json_deferred({'message': 'an error occurred while sending'}, request, status_code=422)
deferred = self._handle_post(request)
@@ -184,7 +185,7 @@ class MailsResource(BaseResource):
def render_PUT(self, request):
def onError(error):
- err(error, 'error saving draft')
+ logger.error(error, 'error saving draft')
respond_json_deferred("", request, status_code=422)
deferred = self._handle_put(request)
diff --git a/service/pixelated/support/__init__.py b/service/pixelated/support/__init__.py
index 9ac52fe0..0685f48d 100644
--- a/service/pixelated/support/__init__.py
+++ b/service/pixelated/support/__init__.py
@@ -14,12 +14,12 @@
# You should have received a copy of the GNU Affero General Public License
# along with Pixelated. If not, see <http://www.gnu.org/licenses/>.
import time
-import logging
from functools import wraps
from twisted.internet import defer
+from twisted.logger import Logger
-log = logging.getLogger(__name__)
+log = Logger()
def _start_stopwatch():
diff --git a/service/test/functional/features/environment.py b/service/test/functional/features/environment.py
index 41f2c8c7..77efc499 100644
--- a/service/test/functional/features/environment.py
+++ b/service/test/functional/features/environment.py
@@ -13,24 +13,32 @@
#
# You should have received a copy of the GNU Affero General Public License
# along with Pixelated. If not, see <http://www.gnu.org/licenses/>.
-import logging
import uuid
+import os
+from selenium import webdriver
from crochet import setup, wait_for
-from leap.common.events.server import ensure_server
+
from twisted.internet import defer
+from twisted.logger import globalLogBeginner, textFileLogObserver, Logger
-from pixelated.application import UserAgentMode
-from pixelated.config.site import PixelatedSite
from test.support.integration import AppTestClient
-from selenium import webdriver
+from steps.common import *
+from leap.common.events.server import ensure_server
+
+from pixelated.application import UserAgentMode
+from pixelated.config.site import PixelatedSite
from pixelated.resources.features_resource import FeaturesResource
-from steps.common import *
-import os
setup()
+observers = [textFileLogObserver(open(os.devnull, 'w'))]
+
+globalLogBeginner.beginLoggingTo(observers)
+
+Logger('twisted')
+
@wait_for(timeout=5.0)
def start_app_test_client(client, mode):
@@ -39,7 +47,6 @@ def start_app_test_client(client, mode):
def before_all(context):
ensure_server()
- logging.disable('INFO')
PixelatedSite.disable_csp_requests()
client = AppTestClient()
start_app_test_client(client, UserAgentMode(is_single_user=True))
diff --git a/service/test/perf/contacts/test_Contacts.py b/service/test/perf/contacts/test_Contacts.py
index 967e9eb1..ade97591 100644
--- a/service/test/perf/contacts/test_Contacts.py
+++ b/service/test/perf/contacts/test_Contacts.py
@@ -14,7 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with Pixelated. If not, see <http://www.gnu.org/licenses/>.
import unittest
-import logging
from funkload.FunkLoadTestCase import FunkLoadTestCase
from test.support.integration import AppTestClient
@@ -33,7 +32,6 @@ def start_app_test_client(client):
class Contacts(FunkLoadTestCase):
def setUpBench(self):
- logging.disable('INFO')
client = AppTestClient()
start_app_test_client(client)
client.listenTCP()
diff --git a/service/test/unit/adapter/mailstore/maintenance/test_soledad_maintenance.py b/service/test/unit/adapter/mailstore/maintenance/test_soledad_maintenance.py
index 2aaa969c..f0e1e8c9 100644
--- a/service/test/unit/adapter/mailstore/maintenance/test_soledad_maintenance.py
+++ b/service/test/unit/adapter/mailstore/maintenance/test_soledad_maintenance.py
@@ -20,9 +20,6 @@ from twisted.trial import unittest
from mockito import mock, when, verify, never
from pixelated.adapter.mailstore.maintenance import SoledadMaintenance
from leap.bitmask.keymanager.openpgp import OpenPGPKey
-import logging
-
-logging.getLogger('pixelated.adapter.mailstore.maintenance').addHandler(logging.NullHandler())
SOME_EMAIL_ADDRESS = 'foo@example.tld'
diff --git a/service/test/unit/resources/test_attachments_resource.py b/service/test/unit/resources/test_attachments_resource.py
index 0424c481..06ae765f 100644
--- a/service/test/unit/resources/test_attachments_resource.py
+++ b/service/test/unit/resources/test_attachments_resource.py
@@ -1,6 +1,5 @@
import json
import unittest
-import logging
from mock import patch, MagicMock
from mockito import mock, when, verify, any as ANY
@@ -11,9 +10,6 @@ from pixelated.application import UserAgentMode
from pixelated.resources.attachments_resource import AttachmentsResource
from test.unit.resources import DummySite
-logging.basicConfig(level=logging.CRITICAL)
-logging.getLogger('pixelated.resources.attachments_resource').addHandler(logging.NullHandler())
-
class AttachmentsResourceTest(unittest.TestCase):
diff --git a/service/test/unit/resources/test_tags_resource.py b/service/test/unit/resources/test_tags_resource.py
index 684e95f2..a05da7a7 100644
--- a/service/test/unit/resources/test_tags_resource.py
+++ b/service/test/unit/resources/test_tags_resource.py
@@ -1,13 +1,9 @@
-import logging
-
from mock import MagicMock
from twisted.trial import unittest
from twisted.web.test.requesthelper import DummyRequest
from pixelated.resources.tags_resource import TagsResource
from test.unit.resources import DummySite
-logging.getLogger('pixelated.resources').addHandler(logging.NullHandler())
-
class TestTagsResource(unittest.TestCase):
def setUp(self):
diff --git a/service/twisted/plugins/logger.py b/service/twisted/plugins/logger.py
deleted file mode 100644
index 6503bb13..00000000
--- a/service/twisted/plugins/logger.py
+++ /dev/null
@@ -1,15 +0,0 @@
-import gc
-import sys
-
-from zope.interface import implementer
-from twisted.plugin import IPlugin
-from pixelated.support.loglinegenerator import ILogLineGenerator
-
-
-@implementer(IPlugin, ILogLineGenerator)
-class GCLogger():
- def getLogLine(self):
- return '%010d' % sum(sys.getsizeof(o) for o in gc.get_objects())
-
-
-gcLogger = GCLogger()