28 #include <glib/gstdio.h>
33 #include "TransactionP.h"
37 # define g_fopen fopen
85 static int gen_logs = 1;
86 static FILE * trans_log = NULL;
87 static char * trans_log_name = NULL;
88 static char * log_base_name = NULL;
119 if (!basepath)
return;
121 g_free (log_base_name);
122 log_base_name = g_strdup (basepath);
144 if (!name || !trans_log_name)
147 base = g_path_get_basename(name);
148 result = (strcmp(base, trans_log_name) == 0);
164 PINFO (
"Attempt to open disabled transaction log");
167 if (trans_log)
return;
169 if (!log_base_name) log_base_name = g_strdup (
"translog");
174 filename = g_strconcat (log_base_name,
".", timestamp,
".log", NULL);
176 trans_log = g_fopen (filename,
"a");
180 printf (
"Error: xaccOpenLog(): cannot open journal \n"
181 "\t %d %s\n", norr, g_strerror (norr) ? g_strerror (norr) :
"");
190 g_free (trans_log_name);
191 trans_log_name = g_path_get_basename(filename);
197 fprintf (trans_log,
"mod\ttrans_guid\tsplit_guid\ttime_now\t"
198 "date_entered\tdate_posted\t"
199 "acc_guid\tacc_name\tnum\tdescription\t"
200 "notes\tmemo\taction\treconciled\t"
201 "amount\tvalue\tdate_reconciled\n");
202 fprintf (trans_log,
"-----------------\n");
211 if (!trans_log)
return;
226 const char *trans_notes;
227 char dnow[100], dent[100], dpost[100], drecn[100];
232 PINFO (
"Attempt to write disabled transaction log");
235 if (!trans_log)
return;
248 fprintf (trans_log,
"===== START\n");
250 for (node = trans->splits; node; node = node->next)
252 Split *split = node->data;
253 const char * accname =
"";
265 acc_guid_str[0] =
'\0';
277 "%c\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t"
278 "%s\t%s\t%s\t%s\t%c\t%" G_GINT64_FORMAT
"/%" G_GINT64_FORMAT
"\t%" G_GINT64_FORMAT
"/%" G_GINT64_FORMAT
"\t%s\n",
280 trans_guid_str, split_guid_str,
287 accname ? accname :
"",
288 trans->num ? trans->num :
"",
289 trans->description ? trans->description :
"",
290 trans_notes ? trans_notes :
"",
291 split->memo ? split->memo :
"",
292 split->action ? split->action :
"",
294 gnc_numeric_num(amt),
295 gnc_numeric_denom(amt),
296 gnc_numeric_num(val),
297 gnc_numeric_denom(val),
302 fprintf (trans_log,
"===== END\n");
gchar * gnc_timespec_to_iso8601_buff(Timespec ts, gchar *buff)
#define PINFO(format, args...)
void xaccTransWriteLog(Transaction *trans, char flag)
void xaccLogDisable(void)
Use a 64-bit unsigned int timespec.
gchar * guid_to_string_buff(const GncGUID *guid, gchar *buff)
const char * xaccTransGetNotes(const Transaction *trans)
#define xaccAccountGetGUID(X)
Account handling public routines.
#define GUID_ENCODING_LENGTH
#define xaccSplitGetGUID(X)
#define xaccTransGetGUID(X)
API for the transaction logger.
void xaccLogSetBaseName(const char *basepath)
gnc_numeric xaccSplitGetValue(const Split *split)
Account * xaccSplitGetAccount(const Split *s)
gboolean xaccFileIsCurrentLog(const gchar *name)
time64 gnc_time(time64 *tbuf)
get the current local time
const char * xaccAccountGetName(const Account *acc)
API for Transactions and Splits (journal entries)
const gchar * QofLogModule
gnc_numeric xaccSplitGetAmount(const Split *split)
void timespecFromTime64(Timespec *ts, time64 t)
char * gnc_date_timestamp(void)
Make a timestamp in YYYYMMDDHHMMSS format.