ref_t slfe_no_trace(ref_t args, ref_t assoc) { if (trace_fl) { ref_t result; trace_level_t tl = get_trace_level(); set_trace_level(TRACE_NONE); result = slfe_do(args, assoc); set_trace_level(tl); return result; } else return slfe_do(args, assoc); }
/* * Function: write_debug * Description: * Print a standardly formatted debug output line. * There is a standard 'header' line format that can be generated * that will look something like: * Debug LIBSPMITTY -- "util.c", line 80 * Debug LIBSPMITTY -- "util.c", line 95 * And you can print just data lines like: * x = 32 * Scope: PUBLIC * Parameters: * dest - [RO] * [LOG - write only to the log file * SCR - write only to the display * LOGSCR - write to both the file and display] * debug_flag - Is debug actually turned on? If not - nothing is * printed. * who_called - A caller can use this to identify where this * debug output is coming from (e.g. each library and app * can have its own tag to easily distinguish where output * is coming from). * If who_called is NULL, then the header line of * output is not printed, and only the data line from the * format/var args is printed. * file_name - name of file the debug output request was called from. * Use macro __FILE__. * line_number - line number the debug output request was called from. * Use macro __LINE__. * format - [RO] * [LEVEL0 - base level message * LEVEL1 - first level message * LEVEL2 - second level message * LEVEL3 - third level message * CONTINUE - message continuation from preceding message * LISTITEM - item type message * FMTPARTIAL - part of a message (more to come)] * format of the message (used by the formatting routine) * fmtstr - format string to print any message you want. * Used to pass to vfprintf. * ... - var args to be used with format above to pass to vfprintf. * Return: none * Globals: none * Notes: * The defines, DEBUG_LOC and DEBUG_LOC_NOHD may be useful * to use as parameters when calling this routine. */ void write_debug(u_char dest, int debug_flag, char *who_called, char *file_name, int line_number, u_int format, char *fmtstr, ...) { va_list ap; char buf[MAXPATHLEN + 1] = ""; int old_trace_level; if (!debug_flag) return; old_trace_level = get_trace_level(); (void) set_trace_level(1); /* * if they specified a 'who_called', then * print first debug info line with who_called, function name, * file name, line number, etc... * * if no 'who_called', then * don't print first line with debug info. * i.e. so we can end up with debug output like: * Debug LIBSPMITTY -- "util.c", line 80: main() * x = 32 * y = 32 */ if (who_called) { (void) write_status(dest, LEVEL0, "Debug %s -- \"%s\", line %d", who_called, file_name ? file_name : "", line_number); } if (fmtstr) { va_start(ap, fmtstr); (void) vsprintf(buf, fmtstr, ap); _write_message(dest, STATMSG, format, buf); va_end(ap); } (void) set_trace_level(old_trace_level); }
static void init_trace(int verbose) { set_trace_level(verbose ? 99 : 0); }