26 #define __USE_MINGW_ANSI_STDIO 1 30 #include <glib/gstdio.h> 35 #include "TransactionP.hpp" 39 # define g_fopen fopen 42 static QofLogModule log_module =
"gnc.translog";
87 static int gen_logs = 1;
88 static FILE * trans_log =
nullptr;
89 static char * trans_log_name =
nullptr;
90 static char * log_base_name =
nullptr;
121 if (!basepath)
return;
123 g_free (log_base_name);
124 log_base_name = g_strdup (basepath);
146 if (!name || !trans_log_name)
149 base = g_path_get_basename(name);
150 result = (strcmp(base, trans_log_name) == 0);
166 PINFO (
"Attempt to open disabled transaction log");
169 if (trans_log)
return;
171 if (!log_base_name) log_base_name = g_strdup (
"translog");
176 filename = g_strconcat (log_base_name,
".", timestamp,
".log",
nullptr);
178 trans_log = g_fopen (filename,
"a");
182 printf (
"Error: xaccOpenLog(): cannot open journal\n" 183 "\t %d %s\n", norr, g_strerror (norr) ? g_strerror (norr) :
"");
192 g_free (trans_log_name);
193 trans_log_name = g_path_get_basename(filename);
199 fprintf (trans_log,
"mod\ttrans_guid\tsplit_guid\ttime_now\t" 200 "date_entered\tdate_posted\t" 201 "acc_guid\tacc_name\tnum\tdescription\t" 202 "notes\tmemo\taction\treconciled\t" 203 "amount\tvalue\tdate_reconciled\n");
204 fprintf (trans_log,
"-----------------\n");
213 if (!trans_log)
return;
228 const char *trans_notes;
229 char dnow[100], dent[100], dpost[100], drecn[100];
233 PINFO (
"Attempt to write disabled transaction log");
236 if (!trans_log)
return;
243 fprintf (trans_log,
"===== START\n");
245 for (node = trans->splits; node; node = node->next)
247 Split *split = GNC_SPLIT(node->data);
248 const char * accname =
"";
250 gnc_numeric amt, val;
260 acc_guid_str[0] =
'\0';
271 "%c\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t" 272 "%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",
274 trans_guid_str, split_guid_str,
281 accname ? accname :
"",
282 trans->num ? trans->num :
"",
283 trans->description ? trans->description :
"",
284 trans_notes ? trans_notes :
"",
285 split->memo ? split->memo :
"",
286 split->action ? split->action :
"",
288 gnc_numeric_num(amt),
289 gnc_numeric_denom(amt),
290 gnc_numeric_num(val),
291 gnc_numeric_denom(val),
296 fprintf (trans_log,
"===== END\n");
char * gnc_date_timestamp(void)
Make a timestamp in YYYYMMDDHHMMSS format.
#define PINFO(format, args...)
Print an informational note.
void xaccTransWriteLog(Transaction *trans, char flag)
void xaccLogDisable(void)
document me
gchar * guid_to_string_buff(const GncGUID *guid, gchar *str)
The guid_to_string_buff() routine puts a null-terminated string encoding of the id into the memory po...
const char * xaccTransGetNotes(const Transaction *trans)
Gets the transaction Notes.
#define xaccAccountGetGUID(X)
Account handling public routines.
#define GUID_ENCODING_LENGTH
Number of characters needed to encode a guid as a string not including the null terminator.
#define xaccSplitGetGUID(X)
#define xaccTransGetGUID(X)
API for the transaction logger.
void xaccLogSetBaseName(const char *basepath)
The xaccLogSetBaseName() method sets the base filepath and the root part of the journal file name...
gnc_numeric xaccSplitGetValue(const Split *split)
Returns the value of this split in the transaction's commodity.
Account * xaccSplitGetAccount(const Split *split)
Returns the account of this split, which was set through xaccAccountInsertSplit().
gboolean xaccFileIsCurrentLog(const gchar *name)
Test a filename to see if it is the name of the current logfile.
time64 gnc_time(time64 *tbuf)
get the current time
const char * xaccAccountGetName(const Account *acc)
Get the account's name.
API for Transactions and Splits (journal entries)
char * gnc_time64_to_iso8601_buff(time64 time, char *buff)
The gnc_time64_to_iso8601_buff() routine takes the input UTC time64 value and prints it as an ISO-860...
void xaccLogEnable(void)
document me
gnc_numeric xaccSplitGetAmount(const Split *split)
Returns the amount of the split in the account's commodity.