Files | |
file | qoflog.h |
QOF error logging and tracing facility. | |
Defines | |
#define | QOF_MOD_ENGINE "qof-engine" |
#define | LOG_LEVEL_LIST(_) |
#define | FUNK qof_log_prettify(__FUNCTION__) |
#define | FATAL(format, args...) |
#define | PERR(format, args...) |
#define | PWARN(format, args...) |
#define | PINFO(format, args...) |
#define | DEBUG(format, args...) |
#define | ENTER(format, args...) |
#define | LEAVE(format, args...) |
#define | TRACE(format, args...) |
#define | DEBUGCMD(x) |
#define | START_CLOCK(clockno, format, args...) |
#define | REPORT_CLOCK(clockno, format, args...) |
#define | REPORT_CLOCK_TOTAL(clockno, format, args...) |
Typedefs | |
typedef void(* | QofLogCB )(QofLogModule log_module, QofLogLevel *log_level, gpointer user_data) |
Enumerations | |
enum | QofLogLevel { QOF_LOG_FATAL = 0, QOF_LOG_ERROR = 1, QOF_LOG_WARNING = 2, QOF_LOG_INFO = 3, QOF_LOG_DEBUG = 4, QOF_LOG_DETAIL = 5, QOF_LOG_TRACE = 6 } |
Functions | |
const gchar * | QofLogLevelasString (QofLogLevel n) |
QofLogLevel | QofLogLevelfromString (const gchar *str) |
void | qof_log_add_indent (void) |
gint | qof_log_get_indent (void) |
void | qof_log_drop_indent (void) |
void | qof_log_init (void) |
void | qof_log_set_level (QofLogModule module, QofLogLevel level) |
void | qof_log_set_level_registered (QofLogLevel level) |
void | qof_log_set_file (FILE *outfile) |
void | qof_log_init_filename (const gchar *logfilename) |
void | qof_log_shutdown (void) |
const gchar * | qof_log_prettify (const gchar *name) |
gboolean | qof_log_check (QofLogModule log_module, QofLogLevel log_level) |
void | qof_log_set_default (QofLogLevel log_level) |
void | qof_log_module_foreach (QofLogCB cb, gpointer data) |
gint | qof_log_module_count (void) |
void | qof_start_clock (gint clockno, QofLogModule log_module, QofLogLevel log_level, const gchar *function_name, const gchar *format,...) |
void | qof_report_clock (gint clockno, QofLogModule log_module, QofLogLevel log_level, const gchar *function_name, const gchar *format,...) |
void | qof_report_clock_total (gint clockno, QofLogModule log_module, QofLogLevel log_level, const gchar *function_name, const gchar *format,...) |
|
Value: do { \ if (qof_log_check (log_module, QOF_LOG_DEBUG)) { \ g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, \ "Debug: %s(): " format, \ FUNK , ## args); \ } \ } while (0) |
|
Value: do { \ if (qof_log_check (log_module, QOF_LOG_DEBUG)) { \ (x); \ } \ } while (0) |
|
Value: do { \ if (qof_log_check (log_module, QOF_LOG_DEBUG)) { \ g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, \ "Enter in %s: %s()" format, __FILE__, \ FUNK , ## args); \ qof_log_add_indent(); \ } \ } while (0) |
|
Value: do { \ g_log (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, \ "Fatal Error: %s(): " format, FUNK , ## args); \ } while (0) |
|
Value: do { \ if (qof_log_check (log_module, QOF_LOG_DEBUG)) { \ qof_log_drop_indent(); \ g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, \ "Leave: %s()" format, \ FUNK , ## args); \ } \ } while (0) |
|
Value: |
|
Value: do { \ if (qof_log_check (log_module, QOF_LOG_ERROR)) { \ g_log (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, \ "Error: %s(): " format, FUNK , ## args); \ } \ } while (0) |
|
Value: do { \ if (qof_log_check (log_module, QOF_LOG_INFO)) { \ g_log (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, \ "Info: %s(): " format, \ FUNK , ## args); \ } \ } while (0) |
|
Value: do { \ if (qof_log_check (log_module, QOF_LOG_WARNING)) { \ g_log (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, \ "Warning: %s(): " format, FUNK , ## args); \ } \ } while (0) |
|
Value: do { \ if (qof_log_check (log_module, QOF_LOG_INFO)) \ qof_report_clock (clockno, log_module, QOF_LOG_INFO, \ __FUNCTION__, format , ## args); \ } while (0) |
|
Value: do { \ if (qof_log_check (log_module, QOF_LOG_INFO)) \ qof_report_clock_total (clockno, log_module, QOF_LOG_INFO, \ __FUNCTION__, format , ## args); \ } while (0) |
|
Value: do { \ if (qof_log_check (log_module, QOF_LOG_INFO)) \ qof_start_clock (clockno, log_module, QOF_LOG_INFO, \ __FUNCTION__, format , ## args); \ } while (0) |
|
Value: do { \ if (qof_log_check (log_module, QOF_LOG_TRACE)) { \ g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, \ "Trace: %s(): " format, FUNK , ## args); \ } \ } while (0) |
|
indents once for each ENTER macro Definition at line 59 of file qoflog.c.
|
|
Do not log log_modules that have not been enabled. Definition at line 310 of file qoflog.c. 00311 { 00312 gchar* log_string; 00313 QofLogLevel maximum; /* Any positive log_level less than this will be logged. */ 00314 00315 log_string = NULL; 00316 if (log_level > QOF_LOG_TRACE) log_level = QOF_LOG_TRACE; 00317 if(!log_table || log_module == NULL || log_level < 0) { return FALSE; } 00318 log_string = (gchar*)g_hash_table_lookup(log_table, log_module); 00319 /* if log_module not found, do not log. */ 00320 if(!log_string) { return FALSE; } 00321 maximum = QofLogLevelfromString(log_string); 00322 if(log_level <= maximum) { return TRUE; } 00323 return FALSE; 00324 }
|
|
drops back one indent for each LEAVE macro indent is reset to zero if less than a single indent would exist. Definition at line 71 of file qoflog.c. 00072 { 00073 qof_log_num_spaces = (qof_log_num_spaces < QOF_LOG_INDENT_WIDTH) ? 00074 0 : qof_log_num_spaces - QOF_LOG_INDENT_WIDTH; 00075 }
|
|
gets the running total of the indent Definition at line 65 of file qoflog.c.
|
|
Initialize the error logging subsystem
Definition at line 89 of file qoflog.c. 00090 { 00091 if(!fout) /* allow qof_log_set_file */ 00092 { 00093 fout = fopen ("/tmp/qof.trace", "w"); 00094 } 00095 00096 if(!fout && (filename = (gchar *)g_malloc(MAX_TRACE_FILENAME))) { 00097 snprintf(filename, MAX_TRACE_FILENAME-1, "/tmp/qof.trace.%d", 00098 getpid()); 00099 fout = fopen (filename, "w"); 00100 g_free(filename); 00101 } 00102 00103 if(!fout) 00104 fout = stderr; 00105 00106 g_log_set_handler (G_LOG_DOMAIN, G_LOG_LEVEL_MASK, fh_printer, fout); 00107 }
|
|
Specify a filename for log output. Calls qof_log_init() for you. Definition at line 147 of file qoflog.c. 00148 { 00149 if(!logfilename) 00150 { 00151 fout = stderr; 00152 } 00153 else 00154 { 00155 filename = g_strdup(logfilename); 00156 fout = fopen(filename, "w"); 00157 } 00158 qof_log_init(); 00159 }
|
|
Number of log_modules registered Definition at line 365 of file qoflog.c.
|
|
Iterate over each known log_module Only log_modules with log_levels set will be available. Definition at line 355 of file qoflog.c. 00356 { 00357 struct hash_s iter; 00358 00359 if(!cb) { return; } 00360 iter.cb = cb; 00361 iter.data = data; 00362 g_hash_table_foreach(log_table, hash_cb, (gpointer)&iter); 00363 }
|
|
qof_log_prettify() cleans up subroutine names. AIX/xlC has the habit of printing signatures not names; clean this up. On other operating systems, truncate name to QOF_LOG_MAX_CHARS chars. |
|
Set the default QOF log_modules to the log level. Definition at line 326 of file qoflog.c. 00327 { 00328 qof_log_set_level(QOF_MOD_BACKEND, log_level); 00329 qof_log_set_level(QOF_MOD_CLASS, log_level); 00330 qof_log_set_level(QOF_MOD_ENGINE, log_level); 00331 qof_log_set_level(QOF_MOD_OBJECT, log_level); 00332 qof_log_set_level(QOF_MOD_KVP, log_level); 00333 qof_log_set_level(QOF_MOD_MERGE, log_level); 00334 qof_log_set_level(QOF_MOD_QUERY, log_level); 00335 qof_log_set_level(QOF_MOD_SESSION, log_level); 00336 qof_log_set_level(QOF_MOD_CHOICE, log_level); 00337 qof_log_set_level(QOF_MOD_UTIL, log_level); 00338 }
|
|
Specify an alternate log output, to pipe or file. By default, all logging goes to /tmp/qof.trace Needs to be called before qof_log_init() Definition at line 140 of file qoflog.c.
|
|
Set the logging level of the given log_module. Registers the log_module with the qof_log hashtable and sets an initial value for the loglevel for that log_module. Definition at line 110 of file qoflog.c. 00111 { 00112 gchar* level_string; 00113 00114 if(!log_module || level == 0) { return; } 00115 level_string = g_strdup(QofLogLevelasString(level)); 00116 if(!log_table) 00117 { 00118 log_table = g_hash_table_new(g_str_hash, g_str_equal); 00119 } 00120 g_hash_table_insert(log_table, (gpointer)log_module, level_string); 00121 }
|
|
Set the logging level for all registered log_modules.
e.g. if you are working in one section of the code and do not want the extra log information created by allowing the default modules to log as well. This makes the log itself easier to use when working in a small area of the codebase. Silent log_modules can also be useful where no default currently exists - again to isolate certain sections of the default log output - and using qof_log_set_level_registered allows these silent log_modules to be retained in the code without being logged by other developers etc. Definition at line 130 of file qoflog.c. 00131 { 00132 gchar* level_string; 00133 00134 if(!log_table || level == 0) { return; } 00135 level_string = g_strdup(QofLogLevelasString(level)); 00136 g_hash_table_foreach(log_table, log_module_foreach, level_string); 00137 }
|
|
Be nice, close the logfile if possible. Definition at line 162 of file qoflog.c. 00163 { 00164 if(fout && fout != stderr) { fclose(fout); } 00165 if(filename) { g_free(filename); } 00166 if(function_buffer) { g_free(function_buffer); } 00167 g_hash_table_destroy(log_table); 00168 }
|
|
Infrastructure to make timing measurements for critical pieces of code. Used for only for performance tuning & debugging. |
|
Convert QofLogLevel to a string. The macro correlates the enum value and an exact copy as a string, removing the need to keep two separate lists in sync. Definition at line 54 of file qoflog.c.
|
|
Convert the log_string to a QofLogLevel Only for use as a partner to QofLogLevelasString Definition at line 56 of file qoflog.c.
|