2 * Copyright (c) 2007, Novell Inc.
4 * This program is licensed under the BSD license, read LICENSE.BSD
5 * for further information
8 * general logging function
13 #include <sat_debug.h>
18 #define MAX_OUTPUT_LEN 200
20 // debug level which can be set
21 static DebugLevel debug_level = ERROR;
22 // log file,function,line too
23 static int sat_log_lineNr = 0;
24 // Callback for logging
25 SatDebugFn debugCallback = NULL;
28 sat_set_debugCallback (SatDebugFn callback)
30 debugCallback = callback;
34 sat_set_debug (DebugLevel level, int log_line_nr)
37 sat_log_lineNr = log_line_nr;
40 DebugLevel sat_debug_level ()
46 sat_debug (DebugLevel level, const char *format, ...)
49 char str[MAX_OUTPUT_LEN];
51 va_start (args, format);
52 vsnprintf (str, MAX_OUTPUT_LEN, format, args);
55 if (sat_debug_level() >= level) {
57 char pre[MAX_OUTPUT_LEN];
58 snprintf (pre, MAX_OUTPUT_LEN, "(%s, %s:%d) ", __FUNCTION__, __FILE__, __LINE__);
59 if (debugCallback == NULL)
64 if (debugCallback == NULL)