cdebug 1.3

cdebug 1.3

TestsTested
LangLanguage Obj-CObjective C
License NOASSERTION
ReleasedLast Release Oct 2019

Maintained by Jeong YunWon.



cdebug 1.3

  • By
  • Jeong YunWon

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)

How to setup

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

functions

dprintf

dprintf is shallow wrapper for printf.

dprintf insert filename, line number, timestamp, newline by options

dlog

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

dassert is shallow wrapper for assert.

dassert is triggered only in debug mode. For release mode, use raw 'assert'.

dassertlog

dassertlog is dassert + dprintf When condition is false, both dprintf and dassert triggered.

options

Define options if you don't like default

  1. DEBUG_WITH_FILE to enable __FILE__ macro (default: enabled)
  2. DEBUG_WITH_LINE to enable __LINE__ macro (default: enabled)
  3. DEBUG_WITH_TIME to enable runtime timestamp (default: enabled)
  4. DEBUG_NEWLINE to enable newline insertion (default: enabled)
  5. DEBUG_LOGLEVEL to define dlog trigger level (default: enabled)
  6. DEBUG_LOGTEST(LV) to define dlog trigger test. (default: LV >= DEBUG_LOGLEVEL)
  7. DEBUG_ASSERT to enable real assert in dassert (default: enabled)
  8. DEBUG_PRINTF to define printf function (default: printf in stdio.h)
  9. DEBUG_USE_NSLOG to enable automated NSLog flag for objective-c context (default: enabled)