summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/keymanager/keys.py
diff options
context:
space:
mode:
authorKali Kaneko (leap communications) <kali@leap.se>2017-04-25 18:00:12 +0200
committerKali Kaneko (leap communications) <kali@leap.se>2017-04-27 19:33:28 +0200
commit9f95446a55533c8cdceec7c4430be5cad752ecb1 (patch)
tree4265c127ee9b2c5f1e038836ad2e7b92ea0cad80 /src/leap/bitmask/keymanager/keys.py
parent9a1548aa01996ce93febe0272f1f8e4dd5e130ff (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/keymanager/keys.py')
-rw-r--r--src/leap/bitmask/keymanager/keys.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/leap/bitmask/keymanager/keys.py b/src/leap/bitmask/keymanager/keys.py
index 622c1c6..54609c0 100644
--- a/src/leap/bitmask/keymanager/keys.py
+++ b/src/leap/bitmask/keymanager/keys.py
@@ -30,7 +30,7 @@ from leap.bitmask.keymanager.wrapper import TempGPGWrapper
from leap.bitmask.keymanager.validation import ValidationLevels
from leap.bitmask.keymanager import documents as doc
-logger = Logger()
+log = Logger()
#
@@ -71,9 +71,9 @@ def build_key_from_dict(key, active=None):
try:
validation = ValidationLevels.get(active[doc.KEY_VALIDATION_KEY])
except ValueError:
- logger.error("Not valid validation level (%s) for key %s",
- (active[doc.KEY_VALIDATION_KEY],
- active[doc.KEY_FINGERPRINT_KEY]))
+ log.error('Not valid validation level (%s) for key %s',
+ (active[doc.KEY_VALIDATION_KEY],
+ active[doc.KEY_FINGERPRINT_KEY]))
last_audited_at = _to_datetime(active[doc.KEY_LAST_AUDITED_AT_KEY])
encr_used = active[doc.KEY_ENCR_USED_KEY]
sign_used = active[doc.KEY_SIGN_USED_KEY]
@@ -112,6 +112,7 @@ def _to_unix_time(date):
class OpenPGPKey(object):
+
"""
Base class for OpenPGP keys.
"""
@@ -120,6 +121,7 @@ class OpenPGPKey(object):
'private', 'length', 'expiry_date', 'validation',
'last_audited_at', 'refreshed_at',
'encr_used', 'sign_used', '_index', '_gpgbinary')
+ log = Logger()
def __init__(self, address=None, gpgbinary=None, uids=[], fingerprint="",
key_data="", private=False, length=0, expiry_date=None,
@@ -184,7 +186,7 @@ class OpenPGPKey(object):
def merge(self, newkey):
if newkey.fingerprint != self.fingerprint:
- logger.critical(
+ self.log.critical(
"Can't put a key whith the same key_id and different "
"fingerprint: %s, %s"
% (newkey.fingerprint, self.fingerprint))