diff options
author | Kali Kaneko (leap communications) <kali@leap.se> | 2017-04-25 18:00:12 +0200 |
---|---|---|
committer | Kali Kaneko (leap communications) <kali@leap.se> | 2017-04-27 19:33:28 +0200 |
commit | 9f95446a55533c8cdceec7c4430be5cad752ecb1 (patch) | |
tree | 4265c127ee9b2c5f1e038836ad2e7b92ea0cad80 /src/leap/bitmask/vpn/_control.py | |
parent | 9a1548aa01996ce93febe0272f1f8e4dd5e130ff (diff) |
[bug] unify logging style using class attr
I changed most of the logger statements to use a class attribute, in
this way it's easier to identify which class it's logging them.
in some cases I leave a module-level logger, when we're either using
functions or when the module it's too small.
at the same time I did a general review and cleanup of the logging
statements.
Diffstat (limited to 'src/leap/bitmask/vpn/_control.py')
-rw-r--r-- | src/leap/bitmask/vpn/_control.py | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/leap/bitmask/vpn/_control.py b/src/leap/bitmask/vpn/_control.py index 6d4db965..85e4911c 100644 --- a/src/leap/bitmask/vpn/_control.py +++ b/src/leap/bitmask/vpn/_control.py @@ -8,7 +8,7 @@ from twisted.logger import Logger from .process import VPNProcess from .constants import IS_MAC -logger = Logger() +log = Logger() # NOTE: We need to set a bigger poll time in OSX because it seems # openvpn malfunctions when you ask it a lot of things in a short @@ -47,7 +47,7 @@ class VPNControl(object): self._port = socket_port def start(self): - logger.debug('VPN: start') + log.debug('VPN: start') self._user_stopped = False self._stop_pollers() @@ -58,13 +58,13 @@ class VPNControl(object): restartfun=self.restart) if vpnproc.get_openvpn_process(): - logger.info("Another vpn process is running. Will try to stop it.") + log.info('Another vpn process is running. Will try to stop it.') vpnproc.stop_if_already_running() try: cmd = vpnproc.getCommand() except Exception as e: - logger.error("Error while getting vpn command... {0!r}".format(e)) + log.error('Error while getting vpn command... {0!r}'.format(e)) raise env = os.environ @@ -118,7 +118,7 @@ class VPNControl(object): reactor.callLater( self.TERMINATE_WAIT, self._kill_if_left_alive) else: - logger.debug("VPN is not running.") + log.debug('VPN is not running.') return True @@ -153,7 +153,7 @@ class VPNControl(object): """ self._stop_pollers() if self._vpnproc is None: - logger.debug("There's no vpn process running to kill.") + log.debug("There's no vpn process running to kill.") else: self._vpnproc.aborted = True self._vpnproc.killProcess() @@ -168,10 +168,9 @@ class VPNControl(object): """ while tries < self.TERMINATE_MAXTRIES: if self._vpnproc.transport.pid is None: - logger.debug("Process has been happily terminated.") return else: - logger.debug("Process did not die, waiting...") + log.debug('Process did not die, waiting...') tries += 1 reactor.callLater(self.TERMINATE_WAIT, @@ -179,11 +178,11 @@ class VPNControl(object): return # after running out of patience, we try a killProcess - logger.debug("Process did not died. Sending a SIGKILL.") + log.debug('Process did not die. Sending a SIGKILL.') try: self._killit() except OSError: - logger.error("Could not kill process!") + log.error('Could not kill process!') def _start_pollers(self): """ |