26 #define __USE_MINGW_ANSI_STDIO 1 30 #include <glib/gstdio.h> 36 #include "TransactionP.hpp" 40 # define g_fopen fopen 43 static QofLogModule log_module =
"gnc.translog";
88 static int gen_logs = 1;
89 static std::ofstream trans_log_stream;
90 static std::string trans_log_name;
91 static std::string log_base_name;
111 if (trans_log_stream.is_open())
122 if (!basepath)
return;
124 log_base_name = basepath;
126 if (trans_log_stream.is_open())
145 if (!name || trans_log_name.empty())
148 base = g_path_get_basename(name);
149 bool result = trans_log_name.compare(base) == 0;
165 PINFO (
"Attempt to open disabled transaction log");
168 if (trans_log_stream.is_open())
return;
170 if (log_base_name.empty())
171 log_base_name =
"translog";
176 filename = g_strconcat (log_base_name.c_str(),
".", timestamp,
".log",
nullptr);
178 trans_log_stream.open(filename, std::ios::app);
179 if (!trans_log_stream.is_open())
182 printf (
"Error: xaccOpenLog(): cannot open journal\n" 183 "\t %d %s\n", norr, g_strerror (norr) ? g_strerror (norr) :
"");
191 auto tmpstr = g_path_get_basename(filename);
192 trans_log_name = tmpstr;
199 trans_log_stream <<
"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 <<
"-----------------\n";
213 if (!trans_log_stream.is_open())
return;
214 trans_log_stream.flush();
215 trans_log_stream.close();
227 const char *trans_notes;
228 char dnow[100], dent[100], dpost[100], drecn[100];
232 PINFO (
"Attempt to write disabled transaction log");
235 if (!trans_log_stream.is_open())
return;
242 trans_log_stream <<
"===== START\n";
244 for (node = trans->splits; node; node = node->next)
246 Split *split = GNC_SPLIT(node->data);
247 const char * accname =
"";
249 gnc_numeric amt, val;
259 acc_guid_str[0] =
'\0';
268 trans_log_stream << flag <<
'\t' 269 << trans_guid_str <<
'\t' 270 << split_guid_str <<
'\t' 274 << acc_guid_str <<
'\t' 275 << (accname ? accname :
"") <<
'\t' 276 << (trans->num ? trans->num :
"") <<
'\t' 277 << (trans->description ? trans->description :
"") <<
'\t' 278 << (trans_notes ? trans_notes :
"") <<
'\t' 279 << (split->memo ? split->memo :
"") <<
'\t' 280 << (split->action ? split->action :
"") <<
'\t' 281 << split->reconciled <<
'\t' 282 << gnc_numeric_num(amt) <<
'/' << gnc_numeric_denom(amt) <<
'\t' 283 << gnc_numeric_num(val) <<
'/' << gnc_numeric_denom(val) <<
'\t' 287 trans_log_stream <<
"===== END" << std::endl;
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.