And by the way suppose I have a script which takes as input the log level and a list of possible filters. In another file I have a couple of functions as below which are called in that order.
Is that supposed to work? In theory I'm getting both times the same logger. The set_verbosity seems to do its job, the second is also called and the filters are added but I don't see the output formatted as it should.. Maybe I can only set it up once? def set_verbosity(log_level): """Set the desired log level """ root_logger = logging.getLogger() root_logger.setLevel(LOG_LEVELS[log_level]) def setup_logging(to_filter): root_logger = logging.getLogger() hdlr = logging.StreamHandler() formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s') hdlr.setFormatter(formatter) # a list of regular expressions to filter out? if to_filter: for f in to_filter: logger.debug("adding filter for name %s" % f) filt = logging.Filter(f) hdlr.addFilter(filt) root_logger.addHandler(hdlr) -- http://mail.python.org/mailman/listinfo/python-list