cdebug
is tiny debug utility for C/Objective-C
cdebug
is designed to allow C/Objective-C developers to enable debug mode
log/assertion with a single file.
- Functions can be effortlessly enabled/disabled by debug macro '
DEBUG
' - Conditional log, assertion with log
See document on [Github] (http://youknowone.github.com/cdebug)
To take advantage of this feature, do one of below:
- Insert #define DEBUG 1
- Add compiler option -DDEBUG
To force disabling this function without eliminating 'DEBUG' macro, set NO_DEBUG
dprintf is shallow wrapper for printf.
dprintf insert filename, line number, timestamp, newline by options
dlog is dprintf with test.
dlog is triggered only if first parameter condition passes test. For example:
- #define LOG_ERROR 3
- #define LOG_WARNING 2
- #define LOG_INFO 1
- dlog(LOG_WARNING, "Warn!");
This would be triggered only if DEBUG_LOGLEVEL is lesser than DEBUG_WARNING.
You can redefine test. See DEBUG_LOGTEST in options.
dassert is shallow wrapper for assert.
dassert is triggered only in debug mode. For release mode, use raw 'assert'.
dassertlog is dassert + dprintf When condition is false, both dprintf and dassert triggered.
Define options if you don't like default
- DEBUG_WITH_FILE to enable __FILE__ macro (default: enabled)
- DEBUG_WITH_LINE to enable __LINE__ macro (default: enabled)
- DEBUG_WITH_TIME to enable runtime timestamp (default: enabled)
- DEBUG_NEWLINE to enable newline insertion (default: enabled)
- DEBUG_LOGLEVEL to define dlog trigger level (default: enabled)
- DEBUG_LOGTEST(LV) to define dlog trigger test. (default: LV >= DEBUG_LOGLEVEL)
- DEBUG_ASSERT to enable real assert in dassert (default: enabled)
- DEBUG_PRINTF to define printf function (default: printf in stdio.h)
- DEBUG_USE_NSLOG to enable automated NSLog flag for objective-c context (default: enabled)