PAGE2GO2 HOME | INTERNET NEWS

LeighExchange - Free Advertising Network Stock Research at Internet Speed Need Money Easy and Quick?

Re: fine grain logging cotrol

 List
Subject: Re: fine grain logging cotrol
Poster: Gabriel Genellina
Date: Fri, 23 Mar 2007 19:51:42 -0300
Related Postings: 1 2 3 4 5 6 7 8 9 10
En Fri, 23 Mar 2007 19:34:31 -0300, Eric S. Johansson escribió:


> class LoggedType(type):
> def __new__(mcl, name, bases, classdict):
> def get_logger(self):
> tag = "%s.%s" % (name,sys._getframe(1).f_code.co_name)
> lgr = logging.getLogger(tag)
> lgr.addFilter(filter_test)
> return lgr
>
> classdict["_%s__logger" % name] = property(get_logger)
> return type.__new__(mcl, name, bases, classdict)
>
> It's probably real obvious but I keep getting a:
>
> File "C:\Python24\lib\logging\__init__.py", line 539, in filter
> if not f.filter(record):
> TypeError: unbound method filter() must be called with filter_test
> instance as first argument (got LogRecord instance instead)

I don't get all the details of what's all that stuff for, but from the error and traceback, I think you forgot to create the filter_test instance. That is, change lgr.addFilter(filter_test) to lgr.addFilter(filter_test())

-- Gabriel Genellina

 

Page2Go2.com is not responsible for content of this message.