Created
October 1, 2014 14:31
-
-
Save jorge-lavin/321f474a28476cf4325e to your computer and use it in GitHub Desktop.
prepare_logger
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def prepare_logger(options, logging_config_file='logging.ini'): | |
"""Logging configuration, via logging configuration file and initialization. | |
@param options: a dictionary with the values of the variables reference in the logging configuration file. | |
@param logging_config_file: (Optional) If specified, its a full qualified path name to a logging configuration file | |
@raise IOError: If the logging configuration file is not accesible""" | |
if logging_config_file: | |
log_ini_path = logging_config_file | |
else: | |
log_ini_path = os.path.join(os.getcwd(), 'logging_config_file') | |
try: | |
f = open(log_ini_path,'r') | |
f.close() | |
except IOError as io_err: | |
raise io_err | |
logging.config.fileConfig(log_ini_path, defaults=options) | |
global logger | |
logger = logging.getLogger() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment