Revize d78aa613
Přidáno uživatelem Jan Pašek před téměř 4 roky(ů)
app.py | ||
---|---|---|
5 | 5 |
from flask_injector import FlaskInjector |
6 | 6 |
|
7 | 7 |
from src.config import configuration |
8 |
from src.config.configuration import Configuration |
|
8 | 9 |
from src.config.connection_provider import ConnectionProvider |
9 | 10 |
from src.controllers.certificates_controller import CertController |
10 | 11 |
from src.controllers.crl_ocsp_controller import CrlOcspController |
... | ... | |
92 | 93 |
:param application Flask Application to be initialized. |
93 | 94 |
:return: boolean flag indicating whether initialization was successful or not |
94 | 95 |
""" |
95 |
|
|
96 |
configuration.configure_logging() |
|
97 |
|
|
98 | 96 |
modules = [configuration.configure_env_variable, ConnectionProvider] |
99 | 97 |
injector = Injector(modules) |
100 | 98 |
FlaskInjector(app=application, modules=modules) |
101 | 99 |
|
100 |
config = injector.get(Configuration) |
|
101 |
configuration.configure_logging(config) |
|
102 |
|
|
102 | 103 |
# There's a little dependency on the CryptoService, which is not a pretty thing from |
103 | 104 |
# architectural point of view. However it is only a minimal piece of code and |
104 | 105 |
# it makes sense to do it in this way instead of trying to run openssl via subprocess here |
105 | 106 |
cryptography_service = injector.get(CryptographyService) |
106 | 107 |
try: |
107 | 108 |
# if version string is returned, OpenSSL is present on the system |
108 |
print(f"Using {cryptography_service.get_openssl_version()}") |
|
109 | 109 |
Logger.info(f"Using {cryptography_service.get_openssl_version()}") |
110 |
# TODO log the version instead of prining it out |
|
111 | 110 |
return True |
112 | 111 |
except CryptographyException: |
113 | 112 |
# If getting the version string throws an exception the OpenSSL is not available |
114 | 113 |
print("OpenSSL was not located on the system. Application will now exit.") |
115 | 114 |
Logger.error(f"OpenSSL was not located on the system. Application will now exit.") |
116 |
# TODO add logging here |
|
117 | 115 |
return False |
118 | 116 |
|
119 | 117 |
|
120 | 118 |
# app initialization must follow endpoint declaration (after all Flask decoration) |
121 | 119 |
with app.app_context(): |
122 | 120 |
if not initialize_app(app): |
123 |
# TODO log this |
|
124 | 121 |
print("Failed to initialize app, aborting...") |
125 | 122 |
Logger.error(f"Failed to initialize app, aborting...") |
126 | 123 |
exit(-1) |
Také k dispozici: Unified diff
Re #8707 - Enhanced logging to set log level based on config file