logging in omniORB for python
f
francois at a.a
Wed Dec 15 05:04:41 EST 2004
Birgit Rahm wrote:
> Hello newsgroup,
Hello Birgit,
I haven't found any way to do logging in a standard way.
The solution i've implemented is to decorate each method you want to log
the call, using the logging module (included in python since 2.3)
For example :
import logging
def loggedmethod(method):
logger = logging.getLogger('mylogger')
def _loggedmethod(self, *args, **kw):
logger.debug('## %s was called ##' % method.func_name)
return method(self, *args, **kw)
return _loggedmethod
# imagine A is your corba object
class A:
def foo(self):
return 'foo'
foo = loggedmethod(foo)
if __name__ == '__main__':
logger = logging.getLogger("mylogger")
logger.addHandler(logging.StreamHandler())
logger.setLevel(logging.DEBUG)
a = A()
print a.foo()
when running :
bash-2.05b$ python plop.py
## foo was called ##
foo
More information about the Python-list
mailing list