
It is possible now, use just have to move a resource consuming operations to the __str__ or __repr__ class methods and use logging.log feature, that it doesn't format string with specified format and arguments if the logging level is greater than the specified message level. For example: class Factorial: def __init__(self, n): self.n = n def calculate(self): return factorial(n) def __str__(self): return str(self.calculate) logging.debug("Factorial of %d is %s", 2**15, Factorial(2**15)) 25.12.2012 12:28, anatoly techtonik ?????:
For the logging module it will be extremely useful if Python included a way to disactivate processing certain blocks to avoid making sacrifices between extensive logging harness and performance. For example, instead of writing:
if log.DEBUG==True: log(factorial(2**15))
It should be possible to just write: log(factorial(2**15))
if if log() is an instance of some Nopable class, the statement in log's braces is not executed. -- anatoly t.
_______________________________________________ Python-ideas mailing list Python-ideas@python.org http://mail.python.org/mailman/listinfo/python-ideas
-- Andrew