From 32658ae3108bc67a102cf6e0153d468b3a8ae1b0 Mon Sep 17 00:00:00 2001 From: Ivan Alejandro Date: Fri, 12 Jun 2015 14:34:18 -0300 Subject: [feat] replace old log handler with new one Replace logging.getLogger with custom get_logger. Remove some unneeded dependencies and reorder other. --- src/leap/bitmask/app.py | 13 ++++----- src/leap/bitmask/backend/backend.py | 7 ++--- src/leap/bitmask/backend/backend_proxy.py | 4 +-- src/leap/bitmask/backend/components.py | 7 ++--- src/leap/bitmask/backend/leapbackend.py | 5 ++-- src/leap/bitmask/backend/settings.py | 4 +-- src/leap/bitmask/backend/signaler.py | 4 +-- src/leap/bitmask/backend/signaler_qt.py | 4 +-- src/leap/bitmask/backend/utils.py | 4 +-- src/leap/bitmask/backend_app.py | 13 +++++---- src/leap/bitmask/config/leapsettings.py | 4 +-- src/leap/bitmask/config/providerconfig.py | 4 +-- src/leap/bitmask/crypto/certs.py | 4 +-- src/leap/bitmask/crypto/srpauth.py | 6 ++-- src/leap/bitmask/crypto/srpregister.py | 3 +- src/leap/bitmask/frontend_app.py | 4 +-- src/leap/bitmask/gui/advanced_key_management.py | 7 ++--- src/leap/bitmask/gui/app.py | 5 ++-- src/leap/bitmask/gui/eip_preferenceswindow.py | 5 ++-- src/leap/bitmask/gui/eip_status.py | 5 ++-- src/leap/bitmask/gui/login.py | 5 ++-- src/leap/bitmask/gui/mail_status.py | 5 ++-- src/leap/bitmask/gui/mainwindow.py | 32 ++++------------------ src/leap/bitmask/gui/passwordwindow.py | 8 +++--- src/leap/bitmask/gui/preferences_account_page.py | 6 ++-- src/leap/bitmask/gui/preferences_email_page.py | 6 ++-- src/leap/bitmask/gui/preferenceswindow.py | 5 ++-- src/leap/bitmask/gui/signaltracker.py | 6 ++-- src/leap/bitmask/gui/statemachines.py | 5 ++-- src/leap/bitmask/gui/wizard.py | 4 +-- src/leap/bitmask/logs/utils.py | 2 +- src/leap/bitmask/platform_init/initializers.py | 5 ++-- src/leap/bitmask/platform_init/locks.py | 4 +-- src/leap/bitmask/provider/pinned.py | 5 ++-- src/leap/bitmask/provider/providerbootstrapper.py | 4 +-- src/leap/bitmask/services/__init__.py | 4 +-- src/leap/bitmask/services/abstractbootstrapper.py | 5 ++-- src/leap/bitmask/services/eip/conductor.py | 5 ++-- src/leap/bitmask/services/eip/darwinvpnlauncher.py | 4 +-- src/leap/bitmask/services/eip/eipbootstrapper.py | 4 +-- src/leap/bitmask/services/eip/eipconfig.py | 3 +- src/leap/bitmask/services/eip/linuxvpnlauncher.py | 4 +-- src/leap/bitmask/services/eip/vpnlauncher.py | 4 +-- src/leap/bitmask/services/eip/vpnprocess.py | 9 +++--- .../bitmask/services/eip/windowsvpnlauncher.py | 5 ++-- src/leap/bitmask/services/mail/conductor.py | 5 ++-- src/leap/bitmask/services/mail/imap.py | 4 +-- src/leap/bitmask/services/mail/imapcontroller.py | 6 ++-- src/leap/bitmask/services/mail/plumber.py | 4 +-- src/leap/bitmask/services/mail/smtpbootstrapper.py | 4 +-- src/leap/bitmask/services/mail/smtpconfig.py | 4 +-- .../services/soledad/soledadbootstrapper.py | 4 +-- src/leap/bitmask/services/soledad/soledadconfig.py | 5 ++-- src/leap/bitmask/util/autostart.py | 4 +-- src/leap/bitmask/util/keyring_helpers.py | 5 ++-- src/leap/bitmask/util/polkit_agent.py | 4 +-- src/leap/bitmask/util/privilege_policies.py | 4 +-- src/leap/bitmask/util/requirement_checker.py | 6 ++-- 58 files changed, 139 insertions(+), 181 deletions(-) (limited to 'src') diff --git a/src/leap/bitmask/app.py b/src/leap/bitmask/app.py index adab8652..543fa03a 100644 --- a/src/leap/bitmask/app.py +++ b/src/leap/bitmask/app.py @@ -39,19 +39,18 @@ # M:::::::::::~NMMM7???7MMMM:::::::::::::::::::::::NMMMI??I7MMMM:::::::::::::M # M::::::::::::::7MMMMMMM+:::::::::::::::::::::::::::?MMMMMMMZ:::::::::::::::M # (thanks to: http://www.glassgiant.com/ascii/) + import atexit import multiprocessing import os import sys - -from leap.bitmask.backend.backend_proxy import BackendProxy - from leap.bitmask import __version__ as VERSION +from leap.bitmask.backend.backend_proxy import BackendProxy +from leap.bitmask.backend_app import run_backend from leap.bitmask.config import flags from leap.bitmask.frontend_app import run_frontend -from leap.bitmask.backend_app import run_backend -from leap.bitmask.logs.utils import create_logger +from leap.bitmask.logs.utils import get_logger from leap.bitmask.platform_init.locks import we_are_the_one_and_only from leap.bitmask.services.mail import plumber from leap.bitmask.util import leap_argparse, flags_to_dict @@ -171,8 +170,8 @@ def start_app(): check_requirements() logger.info('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~') - logger.info('Bitmask version %s', VERSION) - logger.info('leap.mail version %s', MAIL_VERSION) + logger.info('Bitmask version %s' % VERSION) + logger.info('leap.mail version %s' % MAIL_VERSION) logger.info('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~') logger.info('Starting app') diff --git a/src/leap/bitmask/backend/backend.py b/src/leap/bitmask/backend/backend.py index fcbb19dc..4a98d146 100644 --- a/src/leap/bitmask/backend/backend.py +++ b/src/leap/bitmask/backend/backend.py @@ -17,7 +17,6 @@ # FIXME this is missing module documentation. It would be fine to say a couple # of lines about the whole backend architecture. - import json import os import time @@ -34,12 +33,12 @@ except ImportError: pass from leap.bitmask.backend.api import API, PING_REQUEST +from leap.bitmask.backend.signaler import Signaler from leap.bitmask.backend.utils import get_backend_certificates from leap.bitmask.config import flags -from leap.bitmask.backend.signaler import Signaler +from leap.bitmask.logs.utils import get_logger -import logging -logger = logging.getLogger(__name__) +logger = get_logger() class TxZmqREPConnection(object): diff --git a/src/leap/bitmask/backend/backend_proxy.py b/src/leap/bitmask/backend/backend_proxy.py index 8d6930d6..30b7c5d1 100644 --- a/src/leap/bitmask/backend/backend_proxy.py +++ b/src/leap/bitmask/backend/backend_proxy.py @@ -34,9 +34,9 @@ from leap.bitmask.backend.settings import Settings from leap.bitmask.backend.utils import generate_zmq_certificates_if_needed from leap.bitmask.backend.utils import get_backend_certificates from leap.bitmask.config import flags +from leap.bitmask.logs.utils import get_logger -import logging -logger = logging.getLogger(__name__) +logger = get_logger() class ZmqREQConnection(threading.Thread): diff --git a/src/leap/bitmask/backend/components.py b/src/leap/bitmask/backend/components.py index d602156d..b833bf59 100644 --- a/src/leap/bitmask/backend/components.py +++ b/src/leap/bitmask/backend/components.py @@ -17,11 +17,9 @@ """ Backend components """ - # TODO [ ] Get rid of all this deferToThread mess, or at least contain # all of it into its own threadpool. -import logging import os import socket import time @@ -38,9 +36,10 @@ from leap.bitmask.backend.settings import Settings, GATEWAY_AUTOMATIC from leap.bitmask.config.providerconfig import ProviderConfig from leap.bitmask.crypto.srpauth import SRPAuth from leap.bitmask.crypto.srpregister import SRPRegister +from leap.bitmask.logs.utils import get_logger from leap.bitmask.platform_init import IS_LINUX -from leap.bitmask.provider.providerbootstrapper import ProviderBootstrapper from leap.bitmask.provider.pinned import PinnedProviders +from leap.bitmask.provider.providerbootstrapper import ProviderBootstrapper from leap.bitmask.services import get_supported from leap.bitmask.services.eip import eipconfig from leap.bitmask.services.eip import get_openvpn_management @@ -66,7 +65,7 @@ from leap.keymanager import openpgp from leap.soledad.client.secrets import PassphraseTooShort from leap.soledad.client.secrets import NoStorageSecret -logger = logging.getLogger(__name__) +logger = get_logger() class ILEAPComponent(zope.interface.Interface): diff --git a/src/leap/bitmask/backend/leapbackend.py b/src/leap/bitmask/backend/leapbackend.py index 3b023563..cf45c4f8 100644 --- a/src/leap/bitmask/backend/leapbackend.py +++ b/src/leap/bitmask/backend/leapbackend.py @@ -17,16 +17,15 @@ """ Backend for everything """ -import logging - import zope.interface import zope.proxy from leap.bitmask.backend import components from leap.bitmask.backend.backend import Backend from leap.bitmask.backend.settings import Settings +from leap.bitmask.logs.utils import get_logger -logger = logging.getLogger(__name__) +logger = get_logger() ERROR_KEY = "error" PASSED_KEY = "passed" diff --git a/src/leap/bitmask/backend/settings.py b/src/leap/bitmask/backend/settings.py index ed70ca6b..dedfc13d 100644 --- a/src/leap/bitmask/backend/settings.py +++ b/src/leap/bitmask/backend/settings.py @@ -18,13 +18,13 @@ Backend settings """ import ConfigParser -import logging import os +from leap.bitmask.logs.utils import get_logger from leap.bitmask.util import get_path_prefix from leap.common.check import leap_assert, leap_assert_type -logger = logging.getLogger(__name__) +logger = get_logger() # We need this one available for the default decorator GATEWAY_AUTOMATIC = "Automatic" diff --git a/src/leap/bitmask/backend/signaler.py b/src/leap/bitmask/backend/signaler.py index aec2f606..c5335eb8 100644 --- a/src/leap/bitmask/backend/signaler.py +++ b/src/leap/bitmask/backend/signaler.py @@ -27,9 +27,9 @@ import zmq from leap.bitmask.backend.api import SIGNALS from leap.bitmask.backend.utils import get_frontend_certificates from leap.bitmask.config import flags +from leap.bitmask.logs.utils import get_logger -import logging -logger = logging.getLogger(__name__) +logger = get_logger() class Signaler(object): diff --git a/src/leap/bitmask/backend/signaler_qt.py b/src/leap/bitmask/backend/signaler_qt.py index b7f48d21..e3244934 100644 --- a/src/leap/bitmask/backend/signaler_qt.py +++ b/src/leap/bitmask/backend/signaler_qt.py @@ -33,9 +33,9 @@ except ImportError: from leap.bitmask.backend.api import SIGNALS from leap.bitmask.backend.utils import get_frontend_certificates from leap.bitmask.config import flags +from leap.bitmask.logs.utils import get_logger -import logging -logger = logging.getLogger(__name__) +logger = get_logger() class SignalerQt(QtCore.QObject): diff --git a/src/leap/bitmask/backend/utils.py b/src/leap/bitmask/backend/utils.py index b2674330..3b5effc5 100644 --- a/src/leap/bitmask/backend/utils.py +++ b/src/leap/bitmask/backend/utils.py @@ -17,7 +17,6 @@ """ Backend utilities to handle ZMQ certificates. """ -import logging import os import shutil import stat @@ -30,11 +29,12 @@ except ImportError: pass from leap.bitmask.config import flags +from leap.bitmask.logs.utils import get_logger from leap.bitmask.util import get_path_prefix from leap.common.files import mkdir_p from leap.common.check import leap_assert -logger = logging.getLogger(__name__) +logger = get_logger() KEYS_DIR = os.path.join(get_path_prefix(), 'leap', 'zmq_certificates') diff --git a/src/leap/bitmask/backend_app.py b/src/leap/bitmask/backend_app.py index af71ba12..891575be 100644 --- a/src/leap/bitmask/backend_app.py +++ b/src/leap/bitmask/backend_app.py @@ -17,7 +17,6 @@ """ Start point for the Backend. """ -import logging import multiprocessing import signal @@ -26,11 +25,8 @@ from leap.common.events import server as event_server from leap.bitmask.backend.leapbackend import LeapBackend from leap.bitmask.backend.utils import generate_zmq_certificates from leap.bitmask.config import flags -from leap.bitmask.logs.utils import create_logger from leap.bitmask.util import dict_to_flags -logger = logging.getLogger(__name__) - def signal_handler(signum, frame): """ @@ -46,7 +42,7 @@ def signal_handler(signum, frame): # In the future we may need to do the stop in here when the frontend and # the backend are run separately (without multiprocessing) pname = multiprocessing.current_process().name - logger.debug("{0}: SIGNAL #{1} catched.".format(pname, signum)) + print "{0}: SIGNAL #{1} catched.".format(pname, signum) def run_backend(bypass_checks=False, flags_dict=None, frontend_pid=None): @@ -58,6 +54,12 @@ def run_backend(bypass_checks=False, flags_dict=None, frontend_pid=None): :param flags_dict: a dict containing the flag values set on app start. :type flags_dict: dict """ + # NOTE: this needs to be used here, within the call since this function is + # executed in a different process and it seems that the process/thread + # identification isn't working 100% + from leap.bitmask.logs.utils import get_logger + logger = get_logger() + # The backend is the one who always creates the certificates. Either if it # is run separately or in a process in the same app as the frontend. if flags.ZMQ_HAS_CURVE: @@ -84,5 +86,4 @@ def run_backend(bypass_checks=False, flags_dict=None, frontend_pid=None): if __name__ == '__main__': - logger = create_logger(debug=True) run_backend() diff --git a/src/leap/bitmask/config/leapsettings.py b/src/leap/bitmask/config/leapsettings.py index fd3e1592..484a8a25 100644 --- a/src/leap/bitmask/config/leapsettings.py +++ b/src/leap/bitmask/config/leapsettings.py @@ -18,14 +18,14 @@ QSettings abstraction. """ import os -import logging from PySide import QtCore from leap.common.check import leap_assert, leap_assert_type +from leap.bitmask.logs.utils import get_logger from leap.bitmask.util import get_path_prefix -logger = logging.getLogger(__name__) +logger = get_logger() def to_bool(val): diff --git a/src/leap/bitmask/config/providerconfig.py b/src/leap/bitmask/config/providerconfig.py index 386c697d..f454bb40 100644 --- a/src/leap/bitmask/config/providerconfig.py +++ b/src/leap/bitmask/config/providerconfig.py @@ -18,18 +18,18 @@ """ Provider configuration """ -import logging import os from leap.bitmask import provider from leap.bitmask.config import flags from leap.bitmask.config.provider_spec import leap_provider_spec +from leap.bitmask.logs.utils import get_logger from leap.bitmask.services import get_service_display_name from leap.bitmask.util import get_path_prefix from leap.common.check import leap_check from leap.common.config.baseconfig import BaseConfig, LocalizedKey -logger = logging.getLogger(__name__) +logger = get_logger() class MissingCACert(Exception): diff --git a/src/leap/bitmask/crypto/certs.py b/src/leap/bitmask/crypto/certs.py index c3ca4efb..4b669376 100644 --- a/src/leap/bitmask/crypto/certs.py +++ b/src/leap/bitmask/crypto/certs.py @@ -17,17 +17,17 @@ """ Utilities for dealing with client certs """ -import logging import os from leap.bitmask.crypto.srpauth import SRPAuth +from leap.bitmask.logs.utils import get_logger from leap.bitmask.util.constants import REQUEST_TIMEOUT from leap.common.files import check_and_fix_urw_only from leap.common.files import mkdir_p from leap.common import certs as leap_certs -logger = logging.getLogger(__name__) +logger = get_logger() def download_client_cert(provider_config, path, session): diff --git a/src/leap/bitmask/crypto/srpauth.py b/src/leap/bitmask/crypto/srpauth.py index 1e96030e..452bfa66 100644 --- a/src/leap/bitmask/crypto/srpauth.py +++ b/src/leap/bitmask/crypto/srpauth.py @@ -14,9 +14,7 @@ # # You should have received a copy of the GNU General Public License # along with this program. If not, see . - import binascii -import logging import threading import sys @@ -33,14 +31,14 @@ from twisted.internet import threads from twisted.internet.defer import CancelledError from leap.bitmask.backend.settings import Settings +from leap.bitmask.logs.utils import get_logger from leap.bitmask.util import request_helpers as reqhelper from leap.bitmask.util.compat import requests_has_max_retries from leap.bitmask.util.constants import REQUEST_TIMEOUT from leap.common.check import leap_assert from leap.common.events import emit, catalog - -logger = logging.getLogger(__name__) +logger = get_logger() class SRPAuthenticationError(Exception): diff --git a/src/leap/bitmask/crypto/srpregister.py b/src/leap/bitmask/crypto/srpregister.py index e3007b6c..baa15244 100644 --- a/src/leap/bitmask/crypto/srpregister.py +++ b/src/leap/bitmask/crypto/srpregister.py @@ -26,11 +26,12 @@ from PySide import QtCore from urlparse import urlparse from leap.bitmask.config.providerconfig import ProviderConfig +from leap.bitmask.logs.utils import get_logger from leap.bitmask.util.constants import SIGNUP_TIMEOUT from leap.bitmask.util.request_helpers import get_content from leap.common.check import leap_assert, leap_assert_type -logger = logging.getLogger(__name__) +logger = get_logger() class SRPRegisterImpl: diff --git a/src/leap/bitmask/frontend_app.py b/src/leap/bitmask/frontend_app.py index 55e188f7..fed24cfa 100644 --- a/src/leap/bitmask/frontend_app.py +++ b/src/leap/bitmask/frontend_app.py @@ -28,10 +28,10 @@ from PySide import QtCore, QtGui from leap.bitmask.config import flags from leap.bitmask.gui.mainwindow import MainWindow +from leap.bitmask.logs.utils import get_logger from leap.bitmask.util import dict_to_flags -import logging -logger = logging.getLogger(__name__) +logger = get_logger() def signal_handler(window, pid, signum, frame): diff --git a/src/leap/bitmask/gui/advanced_key_management.py b/src/leap/bitmask/gui/advanced_key_management.py index 7d147b7b..2e315d18 100644 --- a/src/leap/bitmask/gui/advanced_key_management.py +++ b/src/leap/bitmask/gui/advanced_key_management.py @@ -17,14 +17,13 @@ """ Advanced Key Management """ -import logging - -from PySide import QtCore, QtGui +from PySide import QtGui +from leap.bitmask.logs.utils import get_logger from leap.bitmask.services import get_service_display_name, MX_SERVICE from ui_advanced_key_management import Ui_AdvancedKeyManagement -logger = logging.getLogger(__name__) +logger = get_logger() class AdvancedKeyManagement(QtGui.QDialog): diff --git a/src/leap/bitmask/gui/app.py b/src/leap/bitmask/gui/app.py index 46f276e1..02357b2b 100644 --- a/src/leap/bitmask/gui/app.py +++ b/src/leap/bitmask/gui/app.py @@ -18,15 +18,14 @@ A single App instances holds the signals that are shared among different frontend UI components. The App also keeps a reference to the backend object and the signaler get signals from the backend. """ -import logging - from PySide import QtCore, QtGui from leap.bitmask.config.leapsettings import LeapSettings from leap.bitmask.backend.backend_proxy import BackendProxy from leap.bitmask.backend.leapsignaler import LeapSignaler +from leap.bitmask.logs.utils import get_logger -logger = logging.getLogger(__name__) +logger = get_logger() class App(QtGui.QWidget): diff --git a/src/leap/bitmask/gui/eip_preferenceswindow.py b/src/leap/bitmask/gui/eip_preferenceswindow.py index 8939c709..756e8adf 100644 --- a/src/leap/bitmask/gui/eip_preferenceswindow.py +++ b/src/leap/bitmask/gui/eip_preferenceswindow.py @@ -18,15 +18,14 @@ """ EIP Preferences window """ -import logging - from functools import partial from PySide import QtCore, QtGui from leap.bitmask.config.leapsettings import LeapSettings +from leap.bitmask.logs.utils import get_logger from leap.bitmask.gui.ui_eippreferences import Ui_EIPPreferences -logger = logging.getLogger(__name__) +logger = get_logger() class EIPPreferencesWindow(QtGui.QDialog): diff --git a/src/leap/bitmask/gui/eip_status.py b/src/leap/bitmask/gui/eip_status.py index 83490cac..8334c2ee 100644 --- a/src/leap/bitmask/gui/eip_status.py +++ b/src/leap/bitmask/gui/eip_status.py @@ -17,13 +17,12 @@ """ EIP Status Panel widget implementation """ -import logging - from datetime import datetime from functools import partial from PySide import QtCore, QtGui +from leap.bitmask.logs.utils import get_logger from leap.bitmask.services import get_service_display_name, EIP_SERVICE from leap.bitmask.platform_init import IS_LINUX from leap.bitmask.util.averages import RateMovingAverage @@ -32,7 +31,7 @@ from leap.common.check import leap_assert_type from ui_eip_status import Ui_EIPStatus QtDelayedCall = QtCore.QTimer.singleShot -logger = logging.getLogger(__name__) +logger = get_logger() class EIPStatusWidget(QtGui.QWidget): diff --git a/src/leap/bitmask/gui/login.py b/src/leap/bitmask/gui/login.py index 716a8609..756dd63c 100644 --- a/src/leap/bitmask/gui/login.py +++ b/src/leap/bitmask/gui/login.py @@ -30,8 +30,6 @@ The login sequence is the following: - on success: _authentication_finished """ -import logging - from keyring.errors import InitError as KeyringInitError from PySide import QtCore, QtGui from ui_login import Ui_LoginWidget @@ -41,6 +39,7 @@ from ui_login import Ui_LoginWidget from leap.bitmask.backend.leapbackend import ERROR_KEY, PASSED_KEY from leap.bitmask.config import flags from leap.bitmask.config.leapsettings import LeapSettings +from leap.bitmask.logs.utils import get_logger from leap.bitmask.gui.signaltracker import SignalTracker from leap.bitmask.util import make_address from leap.bitmask.util.credentials import USERNAME_REGEX @@ -48,7 +47,7 @@ from leap.bitmask.util.keyring_helpers import has_keyring from leap.bitmask.util.keyring_helpers import get_keyring from leap.common.check import leap_assert_type -logger = logging.getLogger(__name__) +logger = get_logger() class LoginState(object): diff --git a/src/leap/bitmask/gui/mail_status.py b/src/leap/bitmask/gui/mail_status.py index a3a1be37..b5d1df81 100644 --- a/src/leap/bitmask/gui/mail_status.py +++ b/src/leap/bitmask/gui/mail_status.py @@ -17,10 +17,9 @@ """ Mail Status Panel widget implementation """ -import logging - from PySide import QtCore, QtGui +from leap.bitmask.logs.utils import get_logger from leap.bitmask.platform_init import IS_LINUX from leap.bitmask.services import get_service_display_name, MX_SERVICE from leap.common.check import leap_assert, leap_assert_type @@ -29,7 +28,7 @@ from leap.common.events import catalog from ui_mail_status import Ui_MailStatusWidget -logger = logging.getLogger(__name__) +logger = get_logger() class MailStatusWidget(QtGui.QWidget): diff --git a/src/leap/bitmask/gui/mainwindow.py b/src/leap/bitmask/gui/mainwindow.py index 0df6ef84..a2cf7bca 100644 --- a/src/leap/bitmask/gui/mainwindow.py +++ b/src/leap/bitmask/gui/mainwindow.py @@ -17,7 +17,6 @@ """ Main window for Bitmask. """ -import logging import time from datetime import datetime @@ -34,10 +33,11 @@ from leap.bitmask import __version_hash__ as VERSION_HASH from leap.bitmask.backend.leapbackend import ERROR_KEY, PASSED_KEY from leap.bitmask.config import flags +from leap.bitmask.logs.utils import get_logger from leap.bitmask.gui.advanced_key_management import AdvancedKeyManagement from leap.bitmask.gui.eip_status import EIPStatusWidget -from leap.bitmask.gui.loggerwindow import LoggerWindow +from leap.bitmask.gui.logwindow import LoggerWindow from leap.bitmask.gui.login import LoginWidget from leap.bitmask.gui.mail_status import MailStatusWidget from leap.bitmask.gui.preferenceswindow import PreferencesWindow @@ -60,7 +60,6 @@ from leap.bitmask.services import EIP_SERVICE, MX_SERVICE from leap.bitmask.util import autostart, make_address from leap.bitmask.util.keyring_helpers import has_keyring -from leap.bitmask.logs.leap_log_handler import LeapLogHandler from leap.common.events import register from leap.common.events import catalog @@ -70,7 +69,8 @@ from leap.mail.imap.service.imap import IMAP_PORT from ui_mainwindow import Ui_MainWindow QtDelayedCall = QtCore.QTimer.singleShot -logger = logging.getLogger(__name__) + +logger = get_logger() class MainWindow(QtGui.QMainWindow, SignalTracker): @@ -492,21 +492,6 @@ class MainWindow(QtGui.QMainWindow, SignalTracker): self._wizard = None - def _get_leap_logging_handler(self): - """ - Gets the leap handler from the top level logger - - :return: a logging handler or None - :rtype: LeapLogHandler or None - """ - # TODO this can be a function, does not need - # to be a method. - leap_logger = logging.getLogger('leap') - for h in leap_logger.handlers: - if isinstance(h, LeapLogHandler): - return h - return None - def _show_logger_window(self): """ TRIGGERS: @@ -515,13 +500,8 @@ class MainWindow(QtGui.QMainWindow, SignalTracker): Display the window with the history of messages logged until now and displays the new ones on arrival. """ - leap_log_handler = self._get_leap_logging_handler() - if leap_log_handler is None: - logger.error('Leap logger handler not found') - return - else: - lw = LoggerWindow(self, handler=leap_log_handler) - lw.show() + lw = LoggerWindow(self) + lw.show() def _show_AKM(self): """ diff --git a/src/leap/bitmask/gui/passwordwindow.py b/src/leap/bitmask/gui/passwordwindow.py index 88565829..94cf25da 100644 --- a/src/leap/bitmask/gui/passwordwindow.py +++ b/src/leap/bitmask/gui/passwordwindow.py @@ -19,14 +19,14 @@ Change password dialog window """ -from PySide import QtCore, QtGui -from leap.bitmask.util.credentials import password_checks +from PySide import QtGui +from leap.bitmask.logs.utils import get_logger +from leap.bitmask.util.credentials import password_checks from leap.bitmask.gui.ui_password_change import Ui_PasswordChange from leap.bitmask.gui.flashable import Flashable -import logging -logger = logging.getLogger(__name__) +logger = get_logger() class PasswordWindow(QtGui.QDialog, Flashable): diff --git a/src/leap/bitmask/gui/preferences_account_page.py b/src/leap/bitmask/gui/preferences_account_page.py index cab90eec..5661fb66 100644 --- a/src/leap/bitmask/gui/preferences_account_page.py +++ b/src/leap/bitmask/gui/preferences_account_page.py @@ -16,16 +16,16 @@ """ Widget for "account" preferences """ -import logging - from functools import partial from PySide import QtCore, QtGui + +from leap.bitmask.logs.utils import get_logger from leap.bitmask.gui.ui_preferences_account_page import Ui_PreferencesAccountPage from leap.bitmask.gui.passwordwindow import PasswordWindow from leap.bitmask.services import get_service_display_name -logger = logging.getLogger(__name__) +logger = get_logger() class PreferencesAccountPage(QtGui.QWidget): diff --git a/src/leap/bitmask/gui/preferences_email_page.py b/src/leap/bitmask/gui/preferences_email_page.py index 80e8d93e..3087f343 100644 --- a/src/leap/bitmask/gui/preferences_email_page.py +++ b/src/leap/bitmask/gui/preferences_email_page.py @@ -16,12 +16,12 @@ """ Widget for "email" preferences """ -import logging +from PySide import QtGui -from PySide import QtCore, QtGui +from leap.bitmask.logs.utils import get_logger from leap.bitmask.gui.ui_preferences_email_page import Ui_PreferencesEmailPage -logger = logging.getLogger(__name__) +logger = get_logger() class PreferencesEmailPage(QtGui.QWidget): diff --git a/src/leap/bitmask/gui/preferenceswindow.py b/src/leap/bitmask/gui/preferenceswindow.py index daad08b0..a71f4e5c 100644 --- a/src/leap/bitmask/gui/preferenceswindow.py +++ b/src/leap/bitmask/gui/preferenceswindow.py @@ -18,18 +18,17 @@ """ Preferences window """ -import logging - from PySide import QtCore, QtGui from leap.bitmask.services import EIP_SERVICE, MX_SERVICE +from leap.bitmask.logs.utils import get_logger from leap.bitmask.gui.ui_preferences import Ui_Preferences from leap.bitmask.gui.preferences_account_page import PreferencesAccountPage from leap.bitmask.gui.preferences_vpn_page import PreferencesVpnPage from leap.bitmask.gui.preferences_email_page import PreferencesEmailPage -logger = logging.getLogger(__name__) +logger = get_logger() class PreferencesWindow(QtGui.QDialog): diff --git a/src/leap/bitmask/gui/signaltracker.py b/src/leap/bitmask/gui/signaltracker.py index 0e3b2dce..3dfcfe18 100644 --- a/src/leap/bitmask/gui/signaltracker.py +++ b/src/leap/bitmask/gui/signaltracker.py @@ -14,11 +14,11 @@ # # You should have received a copy of the GNU General Public License # along with this program. If not, see . -import logging - from PySide import QtCore -logger = logging.getLogger(__name__) +from leap.bitmask.logs.utils import get_logger + +logger = get_logger() class SignalTracker(QtCore.QObject): diff --git a/src/leap/bitmask/gui/statemachines.py b/src/leap/bitmask/gui/statemachines.py index 91f1f605..ab48b756 100644 --- a/src/leap/bitmask/gui/statemachines.py +++ b/src/leap/bitmask/gui/statemachines.py @@ -17,16 +17,15 @@ """ State machines for the Bitmask app. """ -import logging - from PySide import QtCore from PySide.QtCore import QStateMachine, QState, Signal from PySide.QtCore import QObject from leap.bitmask.services import connections from leap.common.check import leap_assert_type +from leap.bitmask.logs.utils import get_logger -logger = logging.getLogger(__name__) +logger = get_logger() _tr = QObject().tr diff --git a/src/leap/bitmask/gui/wizard.py b/src/leap/bitmask/gui/wizard.py index c66c6269..c60d967b 100644 --- a/src/leap/bitmask/gui/wizard.py +++ b/src/leap/bitmask/gui/wizard.py @@ -17,7 +17,6 @@ """ First run wizard """ -import logging import random from functools import partial @@ -30,6 +29,7 @@ from leap.bitmask.backend.leapbackend import ERROR_KEY, PASSED_KEY from leap.bitmask.config import flags from leap.bitmask.config.leapsettings import LeapSettings +from leap.bitmask.logs.utils import get_logger from leap.bitmask.gui.signaltracker import SignalTracker from leap.bitmask.services import get_service_display_name, get_supported from leap.bitmask.util.credentials import password_checks, username_checks @@ -39,7 +39,7 @@ from leap.bitmask.util.keyring_helpers import has_keyring from ui_wizard import Ui_Wizard QtDelayedCall = QtCore.QTimer.singleShot -logger = logging.getLogger(__name__) +logger = get_logger() class Wizard(QtGui.QWizard, SignalTracker): diff --git a/src/leap/bitmask/logs/utils.py b/src/leap/bitmask/logs/utils.py index 72efae97..e0a5fba3 100644 --- a/src/leap/bitmask/logs/utils.py +++ b/src/leap/bitmask/logs/utils.py @@ -12,7 +12,7 @@ import logbook from logbook.more import ColorizedStderrHandler -def get_logger(debug=True, logfile=None, replace_stdout=True): +def get_logger(): level = logbook.WARNING if flags.DEBUG: level = logbook.NOTSET diff --git a/src/leap/bitmask/platform_init/initializers.py b/src/leap/bitmask/platform_init/initializers.py index be8a7ab9..eb892cce 100644 --- a/src/leap/bitmask/platform_init/initializers.py +++ b/src/leap/bitmask/platform_init/initializers.py @@ -17,7 +17,6 @@ """ Platform-dependant initialization code. """ -import logging import os import platform import stat @@ -32,9 +31,9 @@ from leap.bitmask.services.eip import get_vpn_launcher from leap.bitmask.services.eip.darwinvpnlauncher import DarwinVPNLauncher from leap.bitmask.util import first from leap.bitmask.util.privilege_policies import LinuxPolicyChecker +from leap.bitmask.logs.utils import get_logger - -logger = logging.getLogger(__name__) +logger = get_logger() # NOTE we could use a deferToThread here, but should # be aware of this bug: http://www.themacaque.com/?p=1067 diff --git a/src/leap/bitmask/platform_init/locks.py b/src/leap/bitmask/platform_init/locks.py index eff900fa..203d367b 100644 --- a/src/leap/bitmask/platform_init/locks.py +++ b/src/leap/bitmask/platform_init/locks.py @@ -17,11 +17,11 @@ """ Utilities for handling multi-platform file locking mechanisms """ -import logging import errno import os import platform +from leap.bitmask.logs.utils import get_logger from leap.bitmask.platform_init import IS_WIN, IS_UNIX from leap.common.events import emit, catalog @@ -37,7 +37,7 @@ else: # WINDOWS from leap.bitmask.util import get_modification_ts, update_modification_ts -logger = logging.getLogger(__name__) +logger = get_logger() if IS_UNIX: diff --git a/src/leap/bitmask/provider/pinned.py b/src/leap/bitmask/provider/pinned.py index 09fcc52c..ea1788eb 100644 --- a/src/leap/bitmask/provider/pinned.py +++ b/src/leap/bitmask/provider/pinned.py @@ -17,13 +17,12 @@ """ Pinned Providers """ -import logging - +from leap.bitmask.logs.utils import get_logger from leap.bitmask.provider import pinned_calyx from leap.bitmask.provider import pinned_demobitmask from leap.bitmask.provider import pinned_riseup -logger = logging.getLogger(__name__) +logger = get_logger() class PinnedProviders(object): diff --git a/src/leap/bitmask/provider/providerbootstrapper.py b/src/leap/bitmask/provider/providerbootstrapper.py index efba29f9..28944d89 100644 --- a/src/leap/bitmask/provider/providerbootstrapper.py +++ b/src/leap/bitmask/provider/providerbootstrapper.py @@ -17,7 +17,6 @@ """ Provider bootstrapping """ -import logging import socket import os import sys @@ -28,6 +27,7 @@ from leap.bitmask import provider from leap.bitmask import util from leap.bitmask.config import flags from leap.bitmask.config.providerconfig import ProviderConfig, MissingCACert +from leap.bitmask.logs.utils import get_logger from leap.bitmask.provider import get_provider_path from leap.bitmask.provider.pinned import PinnedProviders from leap.bitmask.services.abstractbootstrapper import AbstractBootstrapper @@ -38,7 +38,7 @@ from leap.common.certs import get_digest from leap.common.check import leap_assert, leap_assert_type, leap_check from leap.common.files import check_and_fix_urw_only, get_mtime, mkdir_p -logger = logging.getLogger(__name__) +logger = get_logger() class UnsupportedProviderAPI(Exception): diff --git a/src/leap/bitmask/services/__init__.py b/src/leap/bitmask/services/__init__.py index ba12ba4e..54426669 100644 --- a/src/leap/bitmask/services/__init__.py +++ b/src/leap/bitmask/services/__init__.py @@ -17,7 +17,6 @@ """ Services module. """ -import logging import os import sys @@ -25,6 +24,7 @@ from PySide import QtCore from leap.bitmask.config import flags from leap.bitmask.crypto.srpauth import SRPAuth +from leap.bitmask.logs.utils import get_logger from leap.bitmask.util.constants import REQUEST_TIMEOUT from leap.bitmask.util.privilege_policies import is_missing_policy_permissions from leap.bitmask.util.request_helpers import get_content @@ -34,7 +34,7 @@ from leap.common.check import leap_assert from leap.common.config.baseconfig import BaseConfig from leap.common.files import get_mtime -logger = logging.getLogger(__name__) +logger = get_logger() EIP_SERVICE = u"openvpn" diff --git a/src/leap/bitmask/services/abstractbootstrapper.py b/src/leap/bitmask/services/abstractbootstrapper.py index 77929b75..6a08f475 100644 --- a/src/leap/bitmask/services/abstractbootstrapper.py +++ b/src/leap/bitmask/services/abstractbootstrapper.py @@ -18,8 +18,6 @@ """ Abstract bootstrapper implementation """ -import logging - import requests from functools import partial @@ -30,9 +28,10 @@ from twisted.python import log from twisted.internet import threads from twisted.internet.defer import CancelledError +from leap.bitmask.logs.utils import get_logger from leap.common.check import leap_assert, leap_assert_type -logger = logging.getLogger(__name__) +logger = get_logger() class AbstractBootstrapper(QtCore.QObject): diff --git a/src/leap/bitmask/services/eip/conductor.py b/src/leap/bitmask/services/eip/conductor.py index 3fc88724..3386dddf 100644 --- a/src/leap/bitmask/services/eip/conductor.py +++ b/src/leap/bitmask/services/eip/conductor.py @@ -20,10 +20,9 @@ EIP Conductor module. This handles Qt Signals and triggers the calls to the backend, where the VPNProcess has been initialized. """ -import logging - from PySide import QtCore +from leap.bitmask.logs.utils import get_logger from leap.bitmask.gui import statemachines from leap.bitmask.services import EIP_SERVICE from leap.bitmask.services import get_service_display_name @@ -31,7 +30,7 @@ from leap.bitmask.services.eip.connection import EIPConnection from leap.bitmask.platform_init import IS_MAC QtDelayedCall = QtCore.QTimer.singleShot -logger = logging.getLogger(__name__) +logger = get_logger() class EIPConductor(object): diff --git a/src/leap/bitmask/services/eip/darwinvpnlauncher.py b/src/leap/bitmask/services/eip/darwinvpnlauncher.py index f83e0170..17fc11c2 100644 --- a/src/leap/bitmask/services/eip/darwinvpnlauncher.py +++ b/src/leap/bitmask/services/eip/darwinvpnlauncher.py @@ -19,15 +19,15 @@ Darwin VPN launcher implementation. """ import commands import getpass -import logging import os import sys +from leap.bitmask.logs.utils import get_logger from leap.bitmask.services.eip.vpnlauncher import VPNLauncher from leap.bitmask.services.eip.vpnlauncher import VPNLauncherException from leap.bitmask.util import get_path_prefix -logger = logging.getLogger(__name__) +logger = get_logger() class EIPNoTunKextLoaded(VPNLauncherException): diff --git a/src/leap/bitmask/services/eip/eipbootstrapper.py b/src/leap/bitmask/services/eip/eipbootstrapper.py index f78113bc..7a331d71 100644 --- a/src/leap/bitmask/services/eip/eipbootstrapper.py +++ b/src/leap/bitmask/services/eip/eipbootstrapper.py @@ -17,11 +17,11 @@ """ EIP bootstrapping """ -import logging import os from leap.bitmask.config.providerconfig import ProviderConfig from leap.bitmask.crypto.certs import download_client_cert +from leap.bitmask.logs.utils import get_logger from leap.bitmask.services import download_service_config from leap.bitmask.services.abstractbootstrapper import AbstractBootstrapper from leap.bitmask.services.eip.eipconfig import EIPConfig @@ -29,7 +29,7 @@ from leap.common import certs as leap_certs from leap.common.check import leap_assert, leap_assert_type from leap.common.files import check_and_fix_urw_only -logger = logging.getLogger(__name__) +logger = get_logger() class EIPBootstrapper(AbstractBootstrapper): diff --git a/src/leap/bitmask/services/eip/eipconfig.py b/src/leap/bitmask/services/eip/eipconfig.py index d5947eb1..b1d08393 100644 --- a/src/leap/bitmask/services/eip/eipconfig.py +++ b/src/leap/bitmask/services/eip/eipconfig.py @@ -26,12 +26,13 @@ import ipaddr from leap.bitmask.config import flags from leap.bitmask.config.providerconfig import ProviderConfig +from leap.bitmask.logs.utils import get_logger from leap.bitmask.services import ServiceConfig from leap.bitmask.services.eip.eipspec import get_schema from leap.bitmask.util import get_path_prefix from leap.common.check import leap_assert, leap_assert_type -logger = logging.getLogger(__name__) +logger = get_logger() def get_eipconfig_path(domain, relative=True): diff --git a/src/leap/bitmask/services/eip/linuxvpnlauncher.py b/src/leap/bitmask/services/eip/linuxvpnlauncher.py index a3ab408b..cf14a8f9 100644 --- a/src/leap/bitmask/services/eip/linuxvpnlauncher.py +++ b/src/leap/bitmask/services/eip/linuxvpnlauncher.py @@ -18,11 +18,11 @@ Linux VPN launcher implementation. """ import commands -import logging import os import sys from leap.bitmask.config import flags +from leap.bitmask.logs.utils import get_logger from leap.bitmask.util.privilege_policies import LinuxPolicyChecker from leap.bitmask.util.privilege_policies import NoPolkitAuthAgentAvailable from leap.bitmask.util.privilege_policies import NoPkexecAvailable @@ -31,7 +31,7 @@ from leap.bitmask.services.eip.vpnlauncher import VPNLauncherException from leap.bitmask.util import get_path_prefix, force_eval from leap.bitmask.util import first -logger = logging.getLogger(__name__) +logger = get_logger() COM = commands diff --git a/src/leap/bitmask/services/eip/vpnlauncher.py b/src/leap/bitmask/services/eip/vpnlauncher.py index 7793d624..c48f857c 100644 --- a/src/leap/bitmask/services/eip/vpnlauncher.py +++ b/src/leap/bitmask/services/eip/vpnlauncher.py @@ -19,7 +19,6 @@ Platform independant VPN launcher interface. """ import getpass import hashlib -import logging import os import stat @@ -27,6 +26,7 @@ from abc import ABCMeta, abstractmethod from functools import partial from leap.bitmask.config import flags +from leap.bitmask.logs.utils import get_logger from leap.bitmask.backend.settings import Settings, GATEWAY_AUTOMATIC from leap.bitmask.config.providerconfig import ProviderConfig from leap.bitmask.platform_init import IS_LINUX @@ -35,7 +35,7 @@ from leap.bitmask.util import force_eval from leap.common.check import leap_assert, leap_assert_type -logger = logging.getLogger(__name__) +logger = get_logger() class VPNLauncherException(Exception): diff --git a/src/leap/bitmask/services/eip/vpnprocess.py b/src/leap/bitmask/services/eip/vpnprocess.py index 3e46418c..586b50f5 100644 --- a/src/leap/bitmask/services/eip/vpnprocess.py +++ b/src/leap/bitmask/services/eip/vpnprocess.py @@ -18,7 +18,6 @@ VPN Manager, spawned in a custom processProtocol. """ import commands -import logging import os import shutil import socket @@ -39,6 +38,7 @@ except ImportError: from leap.bitmask.config import flags from leap.bitmask.config.providerconfig import ProviderConfig +from leap.bitmask.logs.utils import get_logger from leap.bitmask.services.eip import get_vpn_launcher from leap.bitmask.services.eip import linuxvpnlauncher from leap.bitmask.services.eip.eipconfig import EIPConfig @@ -47,13 +47,12 @@ from leap.bitmask.util import first, force_eval from leap.bitmask.platform_init import IS_MAC, IS_LINUX from leap.common.check import leap_assert, leap_assert_type -logger = logging.getLogger(__name__) -vpnlog = logging.getLogger('leap.openvpn') - from twisted.internet import defer, protocol, reactor from twisted.internet import error as internet_error from twisted.internet.task import LoopingCall +logger = get_logger() + class VPNObserver(object): """ @@ -884,7 +883,7 @@ class VPNProcess(protocol.ProcessProtocol, VPNManager): """ # truncate the newline line = data[:-1] - vpnlog.info(line) + logger.info(line) self._vpn_observer.watch(line) def processExited(self, reason): diff --git a/src/leap/bitmask/services/eip/windowsvpnlauncher.py b/src/leap/bitmask/services/eip/windowsvpnlauncher.py index 3f1ed43b..aaa3e45f 100644 --- a/src/leap/bitmask/services/eip/windowsvpnlauncher.py +++ b/src/leap/bitmask/services/eip/windowsvpnlauncher.py @@ -17,12 +17,11 @@ """ Windows VPN launcher implementation. """ -import logging - +from leap.bitmask.logs.utils import get_logger from leap.bitmask.services.eip.vpnlauncher import VPNLauncher from leap.common.check import leap_assert -logger = logging.getLogger(__name__) +logger = get_logger() class WindowsVPNLauncher(VPNLauncher): diff --git a/src/leap/bitmask/services/mail/conductor.py b/src/leap/bitmask/services/mail/conductor.py index 2f1d20e6..68197d9d 100644 --- a/src/leap/bitmask/services/mail/conductor.py +++ b/src/leap/bitmask/services/mail/conductor.py @@ -17,9 +17,8 @@ """ Mail Services Conductor """ -import logging - from leap.bitmask.config import flags +from leap.bitmask.logs.utils import get_logger from leap.bitmask.gui import statemachines from leap.bitmask.services.mail import connection as mail_connection from leap.bitmask.services.mail.emailfirewall import get_email_firewall @@ -28,7 +27,7 @@ from leap.common.events import catalog from leap.common.events import register as leap_register -logger = logging.getLogger(__name__) +logger = get_logger() class IMAPControl(object): diff --git a/src/leap/bitmask/services/mail/imap.py b/src/leap/bitmask/services/mail/imap.py index 30646a63..5934756d 100644 --- a/src/leap/bitmask/services/mail/imap.py +++ b/src/leap/bitmask/services/mail/imap.py @@ -17,16 +17,16 @@ """ Initialization of imap service """ -import logging import os import sys +from leap.bitmask.logs.utils import get_logger from leap.mail.constants import INBOX_NAME from leap.mail.imap.service import imap from leap.mail.incoming.service import IncomingMail, INCOMING_CHECK_PERIOD from twisted.python import log -logger = logging.getLogger(__name__) +logger = get_logger() # The name of the environment variable that has to be # set to override the default time value, in seconds. diff --git a/src/leap/bitmask/services/mail/imapcontroller.py b/src/leap/bitmask/services/mail/imapcontroller.py index d374ac29..e5313477 100644 --- a/src/leap/bitmask/services/mail/imapcontroller.py +++ b/src/leap/bitmask/services/mail/imapcontroller.py @@ -17,12 +17,10 @@ """ IMAP service controller. """ -import logging - +from leap.bitmask.logs.utils import get_logger from leap.bitmask.services.mail import imap - -logger = logging.getLogger(__name__) +logger = get_logger() class IMAPController(object): diff --git a/src/leap/bitmask/services/mail/plumber.py b/src/leap/bitmask/services/mail/plumber.py index 58625db5..43203f0c 100644 --- a/src/leap/bitmask/services/mail/plumber.py +++ b/src/leap/bitmask/services/mail/plumber.py @@ -30,6 +30,7 @@ from twisted.internet import defer from leap.bitmask.backend.settings import Settings from leap.bitmask.config.providerconfig import ProviderConfig +from leap.bitmask.logs.utils import get_logger from leap.bitmask.provider import get_provider_path from leap.bitmask.services.soledad.soledadbootstrapper import get_db_paths from leap.bitmask.util import flatten, get_path_prefix @@ -37,8 +38,7 @@ from leap.bitmask.util import flatten, get_path_prefix from leap.mail.imap.account import IMAPAccount from leap.soledad.client import Soledad -logger = logging.getLogger(__name__) -logger.setLevel(logging.DEBUG) +logger = get_logger() def initialize_soledad(uuid, email, passwd, diff --git a/src/leap/bitmask/services/mail/smtpbootstrapper.py b/src/leap/bitmask/services/mail/smtpbootstrapper.py index 6f45469b..cd871803 100644 --- a/src/leap/bitmask/services/mail/smtpbootstrapper.py +++ b/src/leap/bitmask/services/mail/smtpbootstrapper.py @@ -17,11 +17,11 @@ """ SMTP bootstrapping """ -import logging import os from leap.bitmask.config.providerconfig import ProviderConfig from leap.bitmask.crypto.certs import download_client_cert +from leap.bitmask.logs.utils import get_logger from leap.bitmask.services import download_service_config from leap.bitmask.services.abstractbootstrapper import AbstractBootstrapper from leap.bitmask.services.mail.smtpconfig import SMTPConfig @@ -31,7 +31,7 @@ from leap.common import certs as leap_certs from leap.common.check import leap_assert from leap.common.files import check_and_fix_urw_only -logger = logging.getLogger(__name__) +logger = get_logger() class NoSMTPHosts(Exception): diff --git a/src/leap/bitmask/services/mail/smtpconfig.py b/src/leap/bitmask/services/mail/smtpconfig.py index 09f90314..2d8de411 100644 --- a/src/leap/bitmask/services/mail/smtpconfig.py +++ b/src/leap/bitmask/services/mail/smtpconfig.py @@ -17,16 +17,16 @@ """ SMTP configuration """ -import logging import os from leap.bitmask.config.providerconfig import ProviderConfig +from leap.bitmask.logs.utils import get_logger from leap.bitmask.services import ServiceConfig from leap.bitmask.services.mail.smtpspec import get_schema from leap.bitmask.util import get_path_prefix from leap.common.check import leap_assert, leap_assert_type -logger = logging.getLogger(__name__) +logger = get_logger() class SMTPConfig(ServiceConfig): diff --git a/src/leap/bitmask/services/soledad/soledadbootstrapper.py b/src/leap/bitmask/services/soledad/soledadbootstrapper.py index 9864e4e1..242bfb3d 100644 --- a/src/leap/bitmask/services/soledad/soledadbootstrapper.py +++ b/src/leap/bitmask/services/soledad/soledadbootstrapper.py @@ -17,7 +17,6 @@ """ Soledad bootstrapping """ -import logging import os import socket import sys @@ -32,6 +31,7 @@ from pysqlcipher.dbapi2 import ProgrammingError as sqlcipher_ProgrammingError from leap.bitmask.config import flags from leap.bitmask.config.providerconfig import ProviderConfig from leap.bitmask.crypto.srpauth import SRPAuth +from leap.bitmask.logs.utils import get_logger from leap.bitmask.services import download_service_config from leap.bitmask.services.abstractbootstrapper import AbstractBootstrapper from leap.bitmask.services.soledad.soledadconfig import SoledadConfig @@ -46,7 +46,7 @@ from leap.soledad.common.errors import InvalidAuthTokenError from leap.soledad.client import Soledad from leap.soledad.client.secrets import BootstrapSequenceError -logger = logging.getLogger(__name__) +logger = get_logger() """ These mocks are replicated from imap tests and the repair utility. diff --git a/src/leap/bitmask/services/soledad/soledadconfig.py b/src/leap/bitmask/services/soledad/soledadconfig.py index d3cc7da4..8052bcdb 100644 --- a/src/leap/bitmask/services/soledad/soledadconfig.py +++ b/src/leap/bitmask/services/soledad/soledadconfig.py @@ -17,12 +17,11 @@ """ Soledad configuration """ -import logging - +from leap.bitmask.logs.utils import get_logger from leap.bitmask.services import ServiceConfig from leap.bitmask.services.soledad.soledadspec import get_schema -logger = logging.getLogger(__name__) +logger = get_logger() class SoledadConfig(ServiceConfig): diff --git a/src/leap/bitmask/util/autostart.py b/src/leap/bitmask/util/autostart.py index d7a8afb8..2000b9f5 100644 --- a/src/leap/bitmask/util/autostart.py +++ b/src/leap/bitmask/util/autostart.py @@ -17,14 +17,14 @@ """ Helpers to enable/disable bitmask's autostart. """ -import logging import os from leap.bitmask.config import flags +from leap.bitmask.logs.utils import get_logger from leap.bitmask.platform_init import IS_LINUX from leap.common.files import mkdir_p -logger = logging.getLogger(__name__) +logger = get_logger() DESKTOP_ENTRY = """\ diff --git a/src/leap/bitmask/util/keyring_helpers.py b/src/leap/bitmask/util/keyring_helpers.py index 2b729b65..d81f39b1 100644 --- a/src/leap/bitmask/util/keyring_helpers.py +++ b/src/leap/bitmask/util/keyring_helpers.py @@ -17,8 +17,6 @@ """ Keyring helpers. """ -import logging - try: import keyring from keyring.backends.file import EncryptedKeyring, PlaintextKeyring @@ -35,7 +33,8 @@ except Exception: keyring = None -logger = logging.getLogger(__name__) +from leap.bitmask.logs.utils import get_logger +logger = get_logger() def _get_keyring_with_fallback(): diff --git a/src/leap/bitmask/util/polkit_agent.py b/src/leap/bitmask/util/polkit_agent.py index e512bffa..f6c7b4ca 100644 --- a/src/leap/bitmask/util/polkit_agent.py +++ b/src/leap/bitmask/util/polkit_agent.py @@ -17,14 +17,14 @@ """ Daemonizes polkit authentication agent. """ -import logging import os import subprocess import daemon # TODO --- logger won't work when daemoninzed. Log to syslog instead? -logger = logging.getLogger(__name__) +from leap.bitmask.logs.utils import get_logger +logger = get_logger() POLKIT_PATHS = ( '/usr/lib/lxpolkit/lxpolkit', diff --git a/src/leap/bitmask/util/privilege_policies.py b/src/leap/bitmask/util/privilege_policies.py index 2acc63cf..fd8c7c8e 100644 --- a/src/leap/bitmask/util/privilege_policies.py +++ b/src/leap/bitmask/util/privilege_policies.py @@ -19,7 +19,6 @@ Helpers to determine if the needed policies for privilege escalation are operative under this client run. """ import commands -import logging import os import subprocess import platform @@ -28,10 +27,11 @@ import time from abc import ABCMeta, abstractmethod from leap.bitmask.config import flags +from leap.bitmask.logs.utils import get_logger from leap.common.check import leap_assert from leap.common.files import which -logger = logging.getLogger(__name__) +logger = get_logger() class NoPolkitAuthAgentAvailable(Exception): diff --git a/src/leap/bitmask/util/requirement_checker.py b/src/leap/bitmask/util/requirement_checker.py index 37e8e693..99ef81b4 100644 --- a/src/leap/bitmask/util/requirement_checker.py +++ b/src/leap/bitmask/util/requirement_checker.py @@ -18,9 +18,7 @@ """ Utility to check the needed requirements. """ - import os -import logging from pkg_resources import (DistributionNotFound, get_distribution, @@ -28,7 +26,9 @@ from pkg_resources import (DistributionNotFound, resource_stream, VersionConflict) -logger = logging.getLogger(__name__) +from leap.bitmask.logs.utils import get_logger + +logger = get_logger() def get_requirements(): -- cgit v1.2.3