Debug Levels when writing an application

前端 未结 8 1340
别那么骄傲
别那么骄傲 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 13:01

    I have normally used more than just four levels, though they don't necessarily have names. You might look at the levels provided by the 'syslog' daemon process.

    0 - Emergency (emerg)
    1 - Alerts (alert)
    2 - Critical (crit)
    3 - Errors (err)
    4 - Warnings (warn)
    5 - Notification (notice)
    6 - Information (info)
    7 - Debug (debug) 
    

    (The log4j package adds a level below 'debug' called 'Trace', but provides just 'Fatal' where syslog and syslogd provide Emergency, Alerts and Critical.) These are not directly relevant, but should give you some pause for thought. The list provided by Pax is pretty reasonable.

    One thing that I've often found useful is segmentation of the debugging - different levels of debugging settable for different components of the system. For example, depending on where the trouble is, I might need heavy debugging in the input section and macro management section, while not needing any debugging in the main processing code. A single debugging level across the whole program is considerably better than nothing, but for complex programs, differentiation is invaluable.

    You can find the source I use on GitHub in my SOQ (Stack Overflow Questions) repository as files debug.h, debug.c, mddebug.c in the src/libsoq sub-directory.

提交回复
热议问题