mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
begine modernization of debuggin infrastructure
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@1425 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
13479e1ec9
commit
18d991d3d7
@ -117,6 +117,9 @@
|
||||
* new/improved account & transaction structures
|
||||
*/
|
||||
|
||||
/* This static indicates the debugging module that this .o belongs to. */
|
||||
static short module = MOD_IO;
|
||||
|
||||
/** GLOBALS *********************************************************/
|
||||
|
||||
/* the default currency is used when importin old-style
|
||||
@ -365,7 +368,7 @@ readGroup (int fd, Account *aparent, int token)
|
||||
}
|
||||
XACC_FLIP_INT (numAcc);
|
||||
|
||||
INFO_2 ("readGroup(): expecting %d accounts \n", numAcc);
|
||||
DEBUG ("readGroup(): expecting %d accounts \n", numAcc);
|
||||
|
||||
/* read in the accounts */
|
||||
for( i=0; i<numAcc; i++ )
|
||||
@ -451,7 +454,7 @@ readAccount( int fd, AccountGroup *grp, int token )
|
||||
|
||||
tmp = readString( fd, token );
|
||||
if( NULL == tmp) { free (tmp); return NULL; }
|
||||
INFO_2 ("readAccount(): reading acct %s \n", tmp);
|
||||
DEBUG ("readAccount(): reading acct %s \n", tmp);
|
||||
xaccAccountSetName (acc, tmp);
|
||||
free (tmp);
|
||||
|
||||
@ -494,7 +497,7 @@ readAccount( int fd, AccountGroup *grp, int token )
|
||||
if( err != sizeof(int) ) { return NULL; }
|
||||
XACC_FLIP_INT (numTrans);
|
||||
|
||||
INFO_2 ("Info: readAccount(): expecting %d transactions \n", numTrans);
|
||||
DEBUG ("Info: readAccount(): expecting %d transactions \n", numTrans);
|
||||
/* read the transactions */
|
||||
for( i=0; i<numTrans; i++ )
|
||||
{
|
||||
@ -846,7 +849,7 @@ readTransaction( int fd, Account *acc, int token )
|
||||
xaccSplitSetSharePriceAndAmount (s, share_price, num_shares);
|
||||
}
|
||||
|
||||
INFO_2 ("readTransaction(): num_shares %f \n", num_shares);
|
||||
DEBUG ("readTransaction(): num_shares %f \n", num_shares);
|
||||
|
||||
/* Read the account numbers for double-entry */
|
||||
/* These are first used in Version 2 of the file format */
|
||||
@ -862,7 +865,7 @@ readTransaction( int fd, Account *acc, int token )
|
||||
return NULL;
|
||||
}
|
||||
XACC_FLIP_INT (acc_id);
|
||||
INFO_2 ("readTransaction(): credit %d\n", acc_id);
|
||||
DEBUG ("readTransaction(): credit %d\n", acc_id);
|
||||
peer_acc = locateAccount (acc_id);
|
||||
|
||||
/* insert the split part of the transaction into
|
||||
@ -880,7 +883,7 @@ readTransaction( int fd, Account *acc, int token )
|
||||
return NULL;
|
||||
}
|
||||
XACC_FLIP_INT (acc_id);
|
||||
INFO_2 ("readTransaction(): debit %d\n", acc_id);
|
||||
DEBUG ("readTransaction(): debit %d\n", acc_id);
|
||||
peer_acc = locateAccount (acc_id);
|
||||
if (peer_acc) {
|
||||
Split *split;
|
||||
@ -1061,7 +1064,7 @@ readSplit ( int fd, int token )
|
||||
XACC_FLIP_DOUBLE (share_price);
|
||||
xaccSplitSetSharePriceAndAmount (split, share_price, num_shares);
|
||||
|
||||
INFO_2 ("readSplit(): num_shares %f \n", num_shares);
|
||||
DEBUG ("readSplit(): num_shares %f \n", num_shares);
|
||||
|
||||
/* Read the account number */
|
||||
|
||||
@ -1073,7 +1076,7 @@ readSplit ( int fd, int token )
|
||||
return NULL;
|
||||
}
|
||||
XACC_FLIP_INT (acc_id);
|
||||
INFO_2 ("readSplit(): account id %d\n", acc_id);
|
||||
DEBUG ("readSplit(): account id %d\n", acc_id);
|
||||
peer_acc = locateAccount (acc_id);
|
||||
xaccAccountInsertSplit (peer_acc, split);
|
||||
|
||||
@ -1374,7 +1377,7 @@ writeAccount( int fd, Account *acc )
|
||||
int numChildren = 0;
|
||||
char * tmp;
|
||||
|
||||
INFO_2 ("writeAccount(): writing acct %s \n", xaccAccountGetName (acc));
|
||||
DEBUG ("writeAccount(): writing acct %s \n", xaccAccountGetName (acc));
|
||||
|
||||
acc_id = acc->id;
|
||||
XACC_FLIP_INT (acc_id);
|
||||
@ -1464,7 +1467,7 @@ writeAccount( int fd, Account *acc )
|
||||
if( err != sizeof(int) )
|
||||
return -1;
|
||||
|
||||
INFO_2 ("writeAccount(): will write %d trans\n", numUnwrittenTrans);
|
||||
DEBUG ("writeAccount(): will write %d trans\n", numUnwrittenTrans);
|
||||
i=0;
|
||||
s = acc->splits[i];
|
||||
while (s) {
|
||||
@ -1595,7 +1598,7 @@ writeSplit ( int fd, Split *split )
|
||||
if( -1 == err ) return err;
|
||||
|
||||
damount = xaccSplitGetShareAmount (split);
|
||||
INFO_2 ("writeSplit: amount=%f \n", damount);
|
||||
DEBUG ("writeSplit: amount=%f \n", damount);
|
||||
XACC_FLIP_DOUBLE (damount);
|
||||
err = write( fd, &damount, sizeof(double) );
|
||||
if( err != sizeof(double) )
|
||||
@ -1611,7 +1614,7 @@ writeSplit ( int fd, Split *split )
|
||||
xfer_acc = split->acc;
|
||||
acc_id = -1;
|
||||
if (xfer_acc) acc_id = xfer_acc -> id;
|
||||
INFO_2 ("writeSplit: credit %d \n", acc_id);
|
||||
DEBUG ("writeSplit: credit %d \n", acc_id);
|
||||
XACC_FLIP_INT (acc_id);
|
||||
err = write( fd, &acc_id, sizeof(int) );
|
||||
if( err != sizeof(int) )
|
||||
|
@ -54,6 +54,9 @@
|
||||
|
||||
static int error_code=0; /* error code, if error occurred */
|
||||
|
||||
/* This static indicates the debugging module that this .o belongs to. */
|
||||
static short module = MOD_IO;
|
||||
|
||||
/*******************************************************/
|
||||
|
||||
int
|
||||
|
@ -31,7 +31,13 @@
|
||||
#include "util.h"
|
||||
|
||||
/** GLOBALS *********************************************************/
|
||||
int loglevel = 1;
|
||||
int loglevel[MODULE_MAX] =
|
||||
{0, /* DUMMY */
|
||||
4, /* ENGINE */
|
||||
1, /* IO */
|
||||
3, /* REGISTER */
|
||||
2, /* GUI */
|
||||
};
|
||||
|
||||
/********************************************************************\
|
||||
* DEBUGGING MEMORY ALLOCATION STUFF *
|
||||
|
@ -31,37 +31,36 @@
|
||||
|
||||
#define BUFSIZE 1024
|
||||
|
||||
extern int loglevel;
|
||||
|
||||
/** DEBUGGING MACROS ************************************************/
|
||||
/* The debuging macros enable the setting of trace messages */
|
||||
#include <nana.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define PERR(x) { if (0 <=loglevel) { \
|
||||
fprintf (stderr, "Error: "); \
|
||||
fprintf (stderr, x); }}
|
||||
#define MOD_ENGINE 1
|
||||
#define MOD_IO 2
|
||||
#define MOD_LEDGER 3
|
||||
#define MOD_GUI 4
|
||||
#define MODULE_MAX 5
|
||||
|
||||
#define WARN(x) { if (1 <=loglevel) { \
|
||||
fprintf (stderr, "Warning: "); \
|
||||
fprintf (stderr, x); }}
|
||||
extern int loglevel[MODULE_MAX];
|
||||
|
||||
#define INFO(x) { if (2 <=loglevel) { \
|
||||
fprintf (stderr, "Info: "); \
|
||||
fprintf (stderr, x); }}
|
||||
#define LERR (1 <= loglevel[module])
|
||||
#define LWARN (2 <= loglevel[module])
|
||||
#define LINFO (3 <= loglevel[module])
|
||||
#define LDEBUG (4 <= loglevel[module])
|
||||
#define LDETAIL (5 <= loglevel[module])
|
||||
|
||||
#define INFO_2(x,y) { if (2 <=loglevel) { \
|
||||
fprintf (stderr, "Info: "); \
|
||||
fprintf (stderr, x, y); }}
|
||||
|
||||
#define DEBUG(x) { if (3 <=loglevel) { \
|
||||
fprintf (stderr, "Debug: "); \
|
||||
fprintf (stderr, x); }}
|
||||
|
||||
#define ENTER(x) { if (3 <=loglevel) { \
|
||||
fprintf(stderr,"Entering: %s()\n", x); }}
|
||||
#define LEAVE(x) { if (3 <=loglevel) { \
|
||||
fprintf(stderr,"Leaving: %s()\n", x); }}
|
||||
#define DEBUGCMD(x) { if (3 <=loglevel) { x; }}
|
||||
/* utility macros */
|
||||
#define PERR(x...) LG(LERR, "Error: "); LG(LERR, ##x);
|
||||
#define PWARN(x...) LG(LWARN, "Waring: "); LG(LWARN, ##x);
|
||||
#define PINFO(x...) LG(LINFO, "Info: "); LG(LINFO, ##x);
|
||||
#define DEBUG(x...) LG(LDEBUG, "Debug: "); LG(LDEBUG, ##x);
|
||||
#define ENTER(x...) LG(LDEBUG, "Enter: "); LG(LDEBUG, ##x);
|
||||
#define LEAVE(x...) LG(LDEBUG, "Leave: "); LG(LDEBUG, ##x);
|
||||
#define DETAIL(x...) LG(LDETAIL, "Detail: "); LG(LDETAIL, ##x);
|
||||
|
||||
#define DEBUGCMD(x) { if (INFO) { x; }}
|
||||
|
||||
#include <errno.h>
|
||||
#define ERROR() fprintf(stderr,"%s: Line %d, error = %s\n", \
|
||||
|
Loading…
Reference in New Issue
Block a user