From e8e36b35c8753bedd92287b56a9fbcc655cd4851 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miha=20=C5=A0etina?= Date: Thu, 2 May 2024 18:44:09 +0200 Subject: [PATCH] Using getLogger and makeing Logger instance --- pkcs11_cryptography_keys/pkcs11_URI/pkcs11_URI.py | 6 +++--- pkcs11_cryptography_keys/sessions/PKCS11_session.py | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/pkcs11_cryptography_keys/pkcs11_URI/pkcs11_URI.py b/pkcs11_cryptography_keys/pkcs11_URI/pkcs11_URI.py index aef33dc..292cd4c 100644 --- a/pkcs11_cryptography_keys/pkcs11_URI/pkcs11_URI.py +++ b/pkcs11_cryptography_keys/pkcs11_URI/pkcs11_URI.py @@ -1,6 +1,6 @@ from __future__ import annotations -from logging import Logger +from logging import Logger, getLogger from re import compile from typing import Any from urllib.parse import unquote @@ -44,7 +44,7 @@ def __init__( self._location: dict[str, str] = location self._query: dict[str, str] = query self._operations: list[tuple[int, str]] = [] - self._logger = logger if logger is not None else Logger("PKCS11 uri") + self._logger = logger if logger is not None else getLogger("PKCS11 uri") def __get_object_value(self, value: str): return value @@ -90,7 +90,7 @@ def parse( uri: str, logger: Logger | None, ) -> PKCS11URI: - local_logger = logger if logger is not None else Logger("URI parser") + local_logger = logger if logger is not None else getLogger("URI parser") grob = compile("(.+?)(\?.+?)?(#.+)?$") m = grob.match(uri) if m is not None: diff --git a/pkcs11_cryptography_keys/sessions/PKCS11_session.py b/pkcs11_cryptography_keys/sessions/PKCS11_session.py index e54692e..53f8f71 100644 --- a/pkcs11_cryptography_keys/sessions/PKCS11_session.py +++ b/pkcs11_cryptography_keys/sessions/PKCS11_session.py @@ -1,10 +1,12 @@ -from logging import Logger +from logging import Logger, getLogger # contextmanager to facilitate connecting to card token class PKCS11Session(object): def __init__(self, logger: Logger | None): - self._logger = logger if logger is not None else Logger("PKCS11 sesion") + self._logger = ( + logger if logger is not None else getLogger("PKCS11 session") + ) # session for interacton with the card self._session = None # does user need to be logged in to use session