misc debugging cleanup and a typo fix

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@6250 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Linas Vepstas 2001-12-05 06:27:39 +00:00
parent 2bbd1f43e9
commit 6dc2d03555
7 changed files with 43 additions and 11 deletions

View File

@ -137,6 +137,9 @@ xaccCloneAccountSimple(const Account *from, GNCBook *book)
{
Account *ret;
if (!from || !book) return NULL;
ENTER (" ");
ret = g_new (Account, 1);
g_return_val_if_fail (ret, NULL);
@ -157,6 +160,7 @@ xaccCloneAccountSimple(const Account *from, GNCBook *book)
xaccAccountCommitEdit (ret);
LEAVE (" ");
return ret;
}
@ -166,6 +170,9 @@ xaccCloneAccount (const Account *from, GNCBook *book)
time_t now;
Account *ret;
if (!from || !book) return NULL;
ENTER (" ");
ret = g_new (Account, 1);
g_return_val_if_fail (ret, NULL);
@ -191,6 +198,7 @@ xaccCloneAccount (const Account *from, GNCBook *book)
xaccAccountCommitEdit (ret);
LEAVE (" ");
return ret;
}
@ -203,6 +211,7 @@ xaccAccountLookupTwin (Account *acc, GNCBook *book)
int i, ncopies = 0;
if (!acc || !book) return NULL;
ENTER (" ");
v_ncopies = kvp_frame_get_slot_path (acc->kvp_data, "gemini", "ncopies");
if (!v_ncopies) return NULL;
@ -234,6 +243,7 @@ xaccAccountLookupTwin (Account *acc, GNCBook *book)
return twin;
}
}
LEAVE (" ");
return NULL;
}

View File

@ -765,6 +765,7 @@ xaccGroupCopyGroup (AccountGroup *to, AccountGroup *from)
if (!to || !from) return;
if (!from->accounts || !to->book) return;
ENTER (" ");
for (node = from->accounts; node; node=node->next)
{
Account *to_acc, *from_acc = node->data;
@ -793,6 +794,7 @@ xaccGroupCopyGroup (AccountGroup *to, AccountGroup *from)
xaccAccountGroupBeginEdit (to_acc->children);
}
}
LEAVE (" ");
}
/********************************************************************\

View File

@ -180,7 +180,7 @@ AccountGroup * xaccAccountGetRoot (Account *account);
Account * xaccGroupGetParentAccount (AccountGroup *group);
/* The xaccGroupMapAccounts() routine will traverse the account
group, returning a list of accounts. If teh callback
group, returning a list of accounts. If the callback
returns null for a given item, it won't show up in
the result list. You should free the returned list when
you are done with it.

View File

@ -2363,7 +2363,7 @@ xaccTransSetDateInternal(Transaction *trans, int which, time_t secs,
if(!trans) return;
check_open(trans);
PINFO ("addr=%p set %d date to %lu %li %s \n",
PINFO ("addr=%p set %d date to %lu %li %s",
trans, which, secs, nsecs, ctime (&secs));
dadate = ((which == TDATE_POSTED)

View File

@ -65,6 +65,7 @@ static gncLogLevel loglevel[MOD_LAST + 1] =
GNC_LOG_DEBUG, /* SX */
};
static FILE *fout = NULL;
/* Set the logging level of the given module. */
void
@ -86,6 +87,12 @@ gnc_set_log_level_global(gncLogLevel level)
loglevel[module] = level;
}
void
gnc_set_logfile (FILE *outfile)
{
fout = outfile;
}
/* 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 30 chars. Note this routine is not thread
@ -138,17 +145,19 @@ gnc_log (gncModuleType module, gncLogLevel log_level, const char *prefix,
if (!gnc_should_log (module, log_level))
return;
fprintf (stderr, "%s: %s: ",
if (!fout) fout = stderr;
fprintf (fout, "%s: %s: ",
prefix ? prefix : "(null)",
prettify (function_name));
va_start (ap, format);
vfprintf (stderr, format, ap);
vfprintf (fout, format, ap);
va_end (ap);
fprintf (stderr, "\n");
fprintf (fout, "\n");
}
@ -173,16 +182,16 @@ gnc_start_clock (int clockno, gncModuleType module, gncLogLevel log_level,
if ((0>clockno) || (NUM_CLOCKS <= clockno)) return;
gettimeofday (&gnc_clock[clockno], &tz);
fprintf (stderr, "Clock %d Start: %s: ",
fprintf (fout, "Clock %d Start: %s: ",
clockno, prettify (function_name));
va_start (ap, format);
vfprintf (stderr, format, ap);
vfprintf (fout, format, ap);
va_end (ap);
fprintf (stderr, "\n");
fprintf (fout, "\n");
}
void
@ -205,16 +214,16 @@ gnc_report_clock (int clockno, gncModuleType module, gncLogLevel log_level,
now.tv_sec -= gnc_clock[clockno].tv_sec;
now.tv_usec -= gnc_clock[clockno].tv_usec;
fprintf (stderr, "Clock %d Elapsed: %ld.%06ld %s: ",
fprintf (fout, "Clock %d Elapsed: %ld.%06ld %s: ",
clockno, now.tv_sec, now.tv_usec, prettify (function_name));
va_start (ap, format);
vfprintf (stderr, format, ap);
vfprintf (fout, format, ap);
va_end (ap);
fprintf (stderr, "\n");
fprintf (fout, "\n");
}
/********************************************************************\

View File

@ -79,6 +79,11 @@ typedef enum
* the glib.h g_error(), etc functions. That way, we would have
* unified logging mechanism, instead of having some messages
* work one way, and other a different way ...
*
* FIXME: the if test should not be a subroutine call, it should
* not use that many CPU cycles. These logging functions are supposed
* to be lightweight. Who changed this ??? Why ???
*
*/
gboolean gnc_should_log (gncModuleType module, gncLogLevel log_level);
void gnc_log (gncModuleType module, gncLogLevel log_level,
@ -171,6 +176,8 @@ void gnc_set_log_level(gncModuleType module, gncLogLevel level);
/* Set the logging level for all modules. */
void gnc_set_log_level_global(gncLogLevel level);
/* Pipe log output to pipe or file */
void gnc_set_logfile (FILE *outfile);
/** Macros *****************************************************/
#define EPS (1.0e-6)

View File

@ -14,6 +14,7 @@
#include "Period.h"
#include "gnc-book.h"
#include "gnc-book-p.h"
#include "gnc-engine-util.h"
#include "gnc-module.h"
#include "test-stuff.h"
#include "test-engine-stuff.h"
@ -107,6 +108,9 @@ run_test (void)
tsmiddle = tsfirst;
tsmiddle.tv_sec = (tsfirst.tv_sec + tslast.tv_sec)/2;
// stdout is broken with guile for some reason
// gnc_set_logfile (stdout);
// gnc_set_log_level_global (GNC_LOG_INFO);
closedbook = gnc_book_close_period (openbook, tsmiddle,
NULL, "this is opening balance dude");