Debug Levels when writing an application

前端 未结 8 1352
别那么骄傲
别那么骄傲 2020-12-23 12:11

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 inpu

8条回答
  •  忘掉有多难
    2020-12-23 12:50

    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.

提交回复
热议问题