2
0
mirror of https://github.com/openkmip/pykmip synced 2025-12-16 16:24:05 +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:
Peter
2016-03-31 12:40:47 -04:00
parent a3da0c6d46
commit 4bc27425be
24 changed files with 82 additions and 195 deletions

View File

@@ -35,11 +35,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)
opts, args = parser.parse_args(sys.argv[1:])
@@ -52,18 +53,12 @@ if __name__ == '__main__':
# Exit early if the arguments are not specified
if algorithm is None:
logging.debug('No algorithm provided, exiting early from demo')
logger.error('No algorithm provided, exiting early from demo')
sys.exit()
if length is None:
logging.debug("No key length provided, exiting early from demo")
logger.error("No key length provided, 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()
@@ -88,8 +83,8 @@ if __name__ == '__main__':
algorithm_enum = getattr(CryptographicAlgorithm, algorithm, None)
if algorithm_enum is None:
logging.debug("{0} not found".format(algorithm))
logging.debug("Invalid algorithm specified, exiting early from demo")
logger.debug("{0} not found".format(algorithm))
logger.debug("Invalid algorithm specified, exiting early from demo")
client.close()
sys.exit()