I have added logging to a Python program I have been working on by putting this in the module's __init__.py file:
########## import logging logger = logging.getLogger('ranking_factors') formatter = logging.Formatter('[%(asctime)s] %(levelname)s in %(module)s:%(funcName)s@%(lineno)s => %(message)s') handler = logging.FileHandler('ranking_factors.log') handler.setLevel(logging.DEBUG) handler.setFormatter(formatter) logger.addHandler(handler) logger.setLevel(logging.INFO) ########## I would like to provide a way for different users to specify the directory where the log files are written, and perhaps also the log file names, through command line arguments. Is there a way that I can do that? I can access the logger variable in the files of the application with from . import logger logger.info("Some message") Could I import logger in the file where the command line arguments are processed and change its handler to use a different filename? If I can do that, will that change logger globally, so that logging statements in other files of the application also write logging to the new file location? If this wouldn't work, is there a different way that I could accomplish this task? Thanks, Mike
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor