mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Chris Shoemaker's gnc-trace patch.
* src/engine/gnc-trace.[ch]: - Recent use of malloc in gnc-trace breaks my compile, use g_malloc - Fix leak of filename mem - add indenting of trace file according to ENTER/LEAVE stack depth - have ENTER report file name of function along with function name git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@10398 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
@@ -2,6 +2,13 @@
|
||||
|
||||
John Ellson's patch to fix some gcc4 warnings (bug #162582).
|
||||
|
||||
Chris Shoemaker's gnc-trace patch.
|
||||
* src/engine/gnc-trace.[ch]:
|
||||
- Recent use of malloc in gnc-trace breaks my compile, use g_malloc
|
||||
- Fix leak of filename mem
|
||||
- add indenting of trace file according to ENTER/LEAVE stack depth
|
||||
- have ENTER report file name of function along with function name
|
||||
|
||||
2004-12-29 Christian Stimming <stimming@tuhh.de>
|
||||
|
||||
* src/tax/us/txf-de_DE.scm: Add Tax TXF categories for the de_DE
|
||||
|
||||
@@ -72,14 +72,21 @@ gncLogLevel gnc_log_modules[MOD_LAST + 1] =
|
||||
static FILE *fout = NULL;
|
||||
static const int MAX_TRACE_FILENAME = 100;
|
||||
|
||||
/* Don't be fooled: gnc_trace_num_spaces has external linkage and
|
||||
static storage, but can't be defined with 'extern' because it has
|
||||
an initializer, and can't be declared with 'static' because that
|
||||
would give it internal linkage. */
|
||||
gint __attribute__ ((unused)) gnc_trace_num_spaces = 0;
|
||||
|
||||
static void
|
||||
fh_printer (const gchar *log_domain,
|
||||
GLogLevelFlags log_level,
|
||||
const gchar *message,
|
||||
gpointer user_data)
|
||||
{
|
||||
extern gint gnc_trace_num_spaces;
|
||||
FILE *fh = user_data;
|
||||
fprintf (fh, "%s\n", message);
|
||||
fprintf (fh, "%*s%s\n", gnc_trace_num_spaces, "", message);
|
||||
fflush(fh);
|
||||
}
|
||||
|
||||
@@ -90,9 +97,11 @@ gnc_log_init (void)
|
||||
|
||||
fout = fopen ("/tmp/gnucash.trace", "w");
|
||||
|
||||
if(!fout && (filename = (char *)malloc(MAX_TRACE_FILENAME))) {
|
||||
snprintf(filename, MAX_TRACE_FILENAME-1, "/tmp/gnucash.trace.%d", getpid());
|
||||
if(!fout && (filename = (char *)g_malloc(MAX_TRACE_FILENAME))) {
|
||||
snprintf(filename, MAX_TRACE_FILENAME-1, "/tmp/gnucash.trace.%d",
|
||||
getpid());
|
||||
fout = fopen (filename, "w");
|
||||
g_free(filename);
|
||||
}
|
||||
|
||||
if(!fout)
|
||||
|
||||
@@ -82,6 +82,8 @@ typedef enum
|
||||
|
||||
//extern gncLogLevel gnc_log_modules[MOD_LAST + 1];
|
||||
|
||||
#define GNC_TRACE_INDENT_WIDTH 4
|
||||
|
||||
/** Initialize the error logging subsystem */
|
||||
void gnc_log_init (void);
|
||||
|
||||
@@ -104,7 +106,7 @@ void gnc_set_logfile (FILE *outfile);
|
||||
const char * gnc_log_prettify (const char *name);
|
||||
|
||||
/* We want logging decisions to be made inline, rather than through
|
||||
* a CPU-cucking subroutine call. Thus, this is a #define, not a
|
||||
* a CPU-sucking subroutine call. Thus, this is a #define, not a
|
||||
* subroutine call. The prototype would have been:
|
||||
* gboolean gnc_should_log (gncModuleType module, gncLogLevel log_level);
|
||||
*
|
||||
@@ -159,7 +161,8 @@ gboolean gnc_should_log(gncModuleType module, gncLogLevel log_level);
|
||||
#define PINFO(format, args...) { \
|
||||
if (gnc_should_log (module, GNC_LOG_INFO)) { \
|
||||
g_log (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, \
|
||||
"Info: %s(): " format, FUNK , ## args); \
|
||||
"Info: %s(): " format, \
|
||||
FUNK , ## args); \
|
||||
} \
|
||||
}
|
||||
|
||||
@@ -167,23 +170,30 @@ gboolean gnc_should_log(gncModuleType module, gncLogLevel log_level);
|
||||
#define DEBUG(format, args...) { \
|
||||
if (gnc_should_log (module, GNC_LOG_DEBUG)) { \
|
||||
g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, \
|
||||
"Debug: %s(): " format, FUNK , ## args); \
|
||||
"Debug: %s(): " format, \
|
||||
FUNK , ## args); \
|
||||
} \
|
||||
}
|
||||
|
||||
/** Print an function entry debugging message */
|
||||
#define ENTER(format, args...) { \
|
||||
extern gint gnc_trace_num_spaces; \
|
||||
if (gnc_should_log (module, GNC_LOG_DEBUG)) { \
|
||||
g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, \
|
||||
"Enter: %s" format, FUNK , ## args); \
|
||||
"Enter in %s: %s()" format, __FILE__, \
|
||||
FUNK , ## args); \
|
||||
gnc_trace_num_spaces += GNC_TRACE_INDENT_WIDTH;\
|
||||
} \
|
||||
}
|
||||
|
||||
/** Print an function exit debugging message */
|
||||
#define LEAVE(format, args...) { \
|
||||
extern gint gnc_trace_num_spaces; \
|
||||
if (gnc_should_log (module, GNC_LOG_DEBUG)) { \
|
||||
gnc_trace_num_spaces -= GNC_TRACE_INDENT_WIDTH;\
|
||||
g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, \
|
||||
"Leave: %s" format, FUNK , ## args); \
|
||||
"Leave: %s()" format, \
|
||||
FUNK , ## args); \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user