【发布时间】:2017-09-06 22:20:26
【问题描述】:
我有一个使用模块'logging'的python应用程序,我用pysintaller打包它。
我正在使用以下格式字符串:
%(asctime)s %(levelname)s [%(threadName)s:%(module)s.%(funcName)s()] %(message)s
如果我将应用程序作为 python 脚本运行,它可以正常工作,'%(module)s.%(funcName)s' 会被调用模块和函数的实际值替换:
2014-06-19 18:46:10,373 DEBUG [MainThread:subcommands.exec_cmd()] Executing `service iptables stop` on server centos6root
2014-06-19 18:46:10,373 DEBUG [MainThread:ssh._connect()] Trying to connect to server centos6root
2014-06-19 18:46:10,945 DEBUG [MainThread:ssh._connect()] Established connection with root@192.168.122.57:22
2014-06-19 18:46:11,533 DEBUG [MainThread:subcommands.exec_cmd()] exitstatus = 0
2014-06-19 18:46:11,648 DEBUG [MainThread:ssh.cleanup()] Closed connection to server centos6root
2014-06-19 18:46:11,649 DEBUG [MainThread:hwswa2.main()] Application finished
但是,如果我使用 pyinstaller 打包我的应用程序,它现在会用 'logging.debug' 替换 '%(module)s.%(funcName)s':
2014-06-19 19:04:05,577 DEBUG [MainThread:logging.debug()] Executing `echo hello` on server centos6root
2014-06-19 19:04:05,577 DEBUG [MainThread:logging.debug()] Trying to connect to server centos6root
2014-06-19 19:04:06,293 DEBUG [MainThread:logging.debug()] Established connection with root@192.168.122.57:22
2014-06-19 19:04:06,705 DEBUG [MainThread:logging.debug()] exitstatus = 0
2014-06-19 19:04:06,707 DEBUG [MainThread:logging.debug()] Closed connection to server centos6root
2014-06-19 19:04:06,707 DEBUG [MainThread:logging.debug()] Application finished
可能是什么原因以及如何解决此行为?
【问题讨论】:
标签: python logging pyinstaller