简体   繁体   English

在不使用python日志记录库的情况下记录所有错误

[英]Log ALL errors without using python logging library

I am trying to make a python program that others on my team can use without me having to make a GUI. 我正在尝试制作一个python程序,供我团队中的其他人使用,而无需创建GUI。 Thus, it is important that the code they interface is super simple and intuitive to the users. 因此,重要的是它们对接的代码对于用户而言超级简单和直观。 I don't want to put logging code in the main program because I think it would confuse them and I don't know what kind of errors they will produce in the main. 我不想将日志记录代码放在主程序中,因为我认为这会使它们感到困惑,而且我也不知道它们将在主程序中产生什么样的错误。 Is there a way to route ALL errors and warnings (that would be default be printed to STOUT) to a log file without using python logging module ? 有没有办法在不使用python日志记录模块的情况下将所有错误和警告(默认情况下会打印到STOUT)路由到日志文件?

You may want to check this question: Capture stdout from a script in Python 您可能需要检查以下问题: 从Python中的脚本捕获stdout

[edit]removed the code snippept, because it is all there (sorry missed the python 3 examples there) [edit]删除了代码片段,因为它就在那里(很抱歉,这里没有python 3示例)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM