commit ca436714b3b82882cb7f2d2d45d10ea7f042c88a
Author: David Friesecký <frieseck@students.zcu.cz>
Date:   Fri Apr 23 08:30:36 2021 +0200

    Re #8570 - Logger configuration
    - implemented dictionary to string in utils
    - implemented log functions with parameter message only (name of file, name of class and name of function
    are getting automaticaly)

diff --git a/app.py b/app.py
index a937df6..7eb5815 100644
--- a/app.py
+++ b/app.py
@@ -9,6 +9,7 @@ from src.config.connection_provider import ConnectionProvider
 from src.controllers.certificates_controller import CertController
 from src.controllers.crl_ocsp_controller import CrlOcspController
 from src.services.cryptography import CryptographyService, CryptographyException
+from src.utils.logger import Logger
 
 app = Flask(__name__)
 
@@ -92,12 +93,12 @@ def initialize_app(application) -> bool:
     :return: boolean flag indicating whether initialization was successful or not
     """
 
+    configuration.configure_logging()
+
     modules = [configuration.configure_env_variable, ConnectionProvider]
     injector = Injector(modules)
     FlaskInjector(app=application, modules=modules)
 
-    configuration.configure_logging()
-
     # There's a little dependency on the CryptoService, which is not a pretty thing from
     # architectural point of view. However it is only a minimal piece of code and
     # it makes sense to do it in this way instead of trying to run openssl via subprocess here
@@ -105,11 +106,13 @@ def initialize_app(application) -> bool:
     try:
         # if version string is returned, OpenSSL is present on the system
         print(f"Using {cryptography_service.get_openssl_version()}")
+        Logger.info(f"Using {cryptography_service.get_openssl_version()}")
         # TODO log the version instead of prining it out
         return True
     except CryptographyException:
         # If getting the version string throws an exception the OpenSSL is not available
         print("OpenSSL was not located on the system. Application will now exit.")
+        Logger.error(f"OpenSSL was not located on the system. Application will now exit.")
         # TODO add logging here
         return False
 
@@ -119,6 +122,7 @@ with app.app_context():
     if not initialize_app(app):
         # TODO log this
         print("Failed to initialize app, aborting...")
+        Logger.error(f"Failed to initialize app, aborting...")
         exit(-1)
 
 if __name__ == '__main__':
diff --git a/src/constants.py b/src/constants.py
index 33b2347..ad8f0ec 100644
--- a/src/constants.py
+++ b/src/constants.py
@@ -62,12 +62,6 @@ CERTIFICATE_STATES = {"valid", "revoked"}
 CERTIFICATE_REVOCATION_REASONS = {"unspecified", "keyCompromise",
                                   "CACompromise", "affiliationChanged",
                                   "superseded", "cessationOfOperation",
-<<<<<<< HEAD
-                                  "certificateHold", "removeFromCRL",
-                                  "privilegeWithdrawn", "aACompromise"}
-
-LAYER_REPOSITORY = "Repository";
-=======
                                   "certificateHold", "removeFromCRL"}
 
 
@@ -94,5 +88,3 @@ organizationName = optional
 organizationalUnitName = optional
 
 """
-
->>>>>>> master
diff --git a/src/utils/logger.py b/src/utils/logger.py
index 0462a35..19419c1 100644
--- a/src/utils/logger.py
+++ b/src/utils/logger.py
@@ -8,8 +8,11 @@ class Logger:
     @staticmethod
     def get_names():
         stack = inspect.stack()
-        file_name = inspect.getfile(stack[2][0].f_locals["self"].__class__)
-        class_name = stack[2][0].f_locals["self"].__class__.__name__
+
+        file_name = inspect.getmodule(inspect.stack()[2][0]).__file__
+        class_name = ""
+        if "self" in stack[2][0].f_locals:
+            class_name = stack[2][0].f_locals["self"].__class__.__name__ + "."
         function_name = stack[2][0].f_code.co_name
 
         return file_name, class_name, function_name
@@ -17,17 +20,17 @@ class Logger:
     @staticmethod
     def debug(message: str):
         names = Logger.get_names()
-        logging.debug(f'{Path(names[0]).name}[{names[1]}.{names[2]}()]: {message}')
+        logging.debug(f'{Path(names[0]).name}[{names[1]}{names[2]}()]: {message}')
 
     @staticmethod
     def info(message: str):
         names = Logger.get_names()
-        logging.info(f'{Path(names[0]).name}[{names[1]}.{names[2]}()]: {message}')
+        logging.info(f'{Path(names[0]).name}[{names[1]}{names[2]}()]: {message}')
 
     @staticmethod
     def warning(message: str):
         names = Logger.get_names()
-        logging.warning(f'{Path(names[0]).name}[{names[1]}.{names[2]}()]: {message}')
+        logging.warning(f'{Path(names[0]).name}[{names[1]}{names[2]}()]: {message}')
 
     @staticmethod
     def error(message: str):
diff --git a/src/utils/util.py b/src/utils/util.py
index edb2251..e08cbbe 100644
--- a/src/utils/util.py
+++ b/src/utils/util.py
@@ -1,7 +1,6 @@
 import datetime
 
 import six
-import typing
 
 
 def _deserialize(data, klass):
@@ -139,3 +138,18 @@ def _deserialize_dict(data, boxed_type):
     """
     return {k: _deserialize(v, boxed_type)
             for k, v in six.iteritems(data)}
+
+
+def dict_to_string(data):
+    data_str = ""
+    for key, value in data.items():
+        data_str += f"\t\t{key}"
+
+        if type(value) is dict:
+            data_str += " --\n"
+            for subkey, subvalue in value.items():
+                data_str += f"\t\t\t{subkey} : {subvalue}\n"
+        else:
+            data_str += f" : {value}\n"
+
+    return data_str
