Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #17153

Re: logging issues

Date 2011-12-13 17:03 +0000
From Andrea Crotti <andrea.crotti.0@gmail.com>
Subject Re: logging issues
References <4EE77279.10104@gmail.com> <4EE77933.2060705@sequans.com> <4EE77B7B.9090408@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.3606.1323795786.27778.python-list@python.org> (permalink)

Show all headers | View raw


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)

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: logging issues Andrea Crotti <andrea.crotti.0@gmail.com> - 2011-12-13 17:03 +0000
  Re: logging issues Vinay Sajip <vinay_sajip@yahoo.co.uk> - 2011-12-17 12:44 -0800

csiph-web