mirror of
https://github.com/openkmip/pykmip
synced 2025-12-17 08:43:46 +00:00
Removing default log configuration and usage
This change removes the use of default logging settings in kmip.__init__.py as well as the bundled logconfig.ini file. Logging settings should be set by applications, not by underlying software libraries. All demos have been updated to set their own logging settings and to log at appropriate levels.
This commit is contained in:
@@ -37,11 +37,12 @@ from kmip.core.objects import Attribute
|
||||
from kmip.services.kmip_client import KMIPProxy
|
||||
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
logger = utils.build_console_logger(logging.INFO)
|
||||
|
||||
# Build and parse arguments
|
||||
parser = utils.build_cli_parser(Operation.CREATE_KEY_PAIR)
|
||||
opts, args = parser.parse_args(sys.argv[1:])
|
||||
@@ -55,28 +56,22 @@ if __name__ == '__main__':
|
||||
|
||||
# Exit early if the arguments are not specified
|
||||
if algorithm is None:
|
||||
logging.error('No algorithm provided, exiting early from demo')
|
||||
logger.error('No algorithm provided, exiting early from demo')
|
||||
sys.exit()
|
||||
if length is None:
|
||||
logging.error("No key length provided, exiting early from demo")
|
||||
logger.error("No key length provided, exiting early from demo")
|
||||
sys.exit()
|
||||
if name is None:
|
||||
logging.error("No key name provided, exiting early from demo")
|
||||
logger.error("No key name provided, exiting early from demo")
|
||||
sys.exit()
|
||||
|
||||
attribute_type = AttributeType.CRYPTOGRAPHIC_ALGORITHM
|
||||
algorithm_enum = getattr(CryptographicAlgorithm, algorithm, None)
|
||||
|
||||
if algorithm_enum is None:
|
||||
logging.error("Invalid algorithm specified; exiting early from demo")
|
||||
logger.error("Invalid algorithm specified; exiting early from demo")
|
||||
sys.exit()
|
||||
|
||||
# Build and setup logging and needed factories
|
||||
f_log = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir,
|
||||
'logconfig.ini')
|
||||
logging.config.fileConfig(f_log)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
attribute_factory = AttributeFactory()
|
||||
credential_factory = CredentialFactory()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user