开发者

Function calls in logging configuration file

开发者 https://www.devze.com 2023-03-09 16:00 出处:网络
I had the following logging configuration in code that I now want to set through a configuration file.

I had the following logging configuration in code that I now want to set through a configuration file.

formatter = logging.Formatter('%s:'%getpass.getuser() + '%(asctime)s:%(levelname)s:%(module)s:%(lineno)d:%(message)s')

In the configuration file, I have

>     [formatter_frmtr]
>     format=getpass.getuser() + '%(asctime)s:%(levelname)s:%(module)s:%(lineno)d:%(message)s'

The function call getpass.getuser() is not getting c开发者_StackOverflowalled but is printed as is:

getpass.getuser() + '2011-06-01 11:56:53,924:ERROR:test:7:test'

How do I make get the username of the callee through the logging config file.

Thanks.


Use the techniques described in the logging documentation to add additional cobtext to your logging messages.

0

精彩评论

暂无评论...
验证码 换一张
取 消