编写应用程序时的调试级别 [英] Debug Levels when writing an application
问题描述
我想到了4个级别:
0:无调试
1:所有输入和输出
2:我在这里主要参数的重要功能的通知
3:所有变量详细
这是我在一个项目中所做的工作。这不是记录级别的圣经,只是一种可能性。记录应适合您的情况。
- LOG_SEVERE,需要程序退出的严重错误(例如,在应用程序中,您已经用完磁盘空格)。
- LOG_ERROR,无法恢复的错误消息,但程序可以继续运行(例如,在服务器应用程序中,客户端通过不良数据发送但其他客户端可以继续
- LOG_WARNING,您应该收到通知的可恢复问题(例如,配置文件中的无效值,因此您将返回到默认值)。
- LOG_INFO,信息性消息。
- LOG_ENTRY,所有功能的日志输入和退出。
- LOG_PARM,日志输入和退出所有具有参数传递和返回值的函数(包括全局效果(如果有的话))。
- LOG_DEBUG,一般调试消息,基本上可以在一行上输出的有用信息。
- LOG_HIDEBUG,更详细的调试信息,如十六进制转储缓冲区。
每个级别还记录较低级别的邮件。有一个问题是调试消息是否应该是LOG_DEBUG或LOG_HIDEBUG,但是我们主要是基于它将推出到日志文件的行数。
I would like to know if you guys have any suggestions about debug levels when writing an application.
I thought about 4 levels:
0 : No Debug
1 : All inputs and outputs
2 : "I am here" notification from significant functions with main parameters
3 : All variables verbose
Here's what we did in one project I worked on. It's not the bible of logging levels, just one possibility. Logging should be fitted to your situation.
- LOG_SEVERE, severe errors that require program exit (e.g., in an application, you ran out of disk space).
- LOG_ERROR, error messages that can't be recovered from but the program can continue to run (e.g., in a server application, client sent through bad data but other clients can continue to run).
- LOG_WARNING, recoverable problem that you should be notified about (e.g., invalid value in a configuration file, so you fell back to the default).
- LOG_INFO, informational messages.
- LOG_ENTRY, log entry and exit to all functions.
- LOG_PARM, log entry and exit to all functions with parameters passed and values returned (including global effects if any).
- LOG_DEBUG, general debugging messages, basically useful information that can be output on a single line.
- LOG_HIDEBUG, far more detailed debugging messages such as hex dumps of buffers.
Each level also logged messages in 'lower' levels. There was sometimes a question as to whether a debug message should be LOG_DEBUG or LOG_HIDEBUG but we mostly based it on the number of lines it would push out to the log file.
这篇关于编写应用程序时的调试级别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!