DEBUGMSG

From Net-SNMP Wiki
Revision as of 14:47, 22 June 2010 by Wes (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

If you want to add Debugging output statements to your own code, you can use the following conventions:

DEBUGMSGTL

DEBUGMSGTL(("token", "statement of some kind: %s\n", "with printf arguments"));

This actually outputs two lines:

  • A "trace" line showing where in the source it came from (that's what the T stands for)
  • Your debugging line (when -Dtoken is turned on)

This should be the most common debugging statement used. It should be used for complete debugging lines.

DEBUG

For creating lines a piece at a time, start with DEBUGMSGTL followed by DEBUGMSG macros until you hit the newline ("\n"). This is a stupid example but shows how it works:

 int total = 0;
 DEBUGMSGTL(("token", "Calculating something: "));
 for(int i = 0; i < 5; i++) {
    total = total + i;