The transaction logging mechanism provides a very simple, low-level logging of user input to a file. The goal of the transaction logger is to provide mechanism of last resort for recovering lost user data in the event of a crash.
Ideally, the storage backends should provide a robust journaling, logging and crash-recovery mechanism. But just in case they don't, or it didn't work, this mechanism provides a "Plan B" by providing a low-tech, fool-proof, simple logging system that can be used to recover user input. There are some simple command-line tools that will read a log and replay it.
gboolean xaccFileIsCurrentLog |
( |
const gchar * |
name | ) |
|
Test a filename to see if it is the name of the current logfile
Definition at line 139 of file TransLog.c.
144 if (!name || !trans_log_name)
147 base = g_path_get_basename(name);
148 result = (strcmp(base, trans_log_name) == 0);
void xaccLogDisable |
( |
void |
| ) |
|
void xaccLogEnable |
( |
void |
| ) |
|
void xaccLogSetBaseName |
( |
const char * |
| ) |
|
The xaccLogSetBaseName() method sets the base filepath and the root part of the journal file name. If the journal file is already open, it will close it and reopen it with the new base name.
Definition at line 117 of file TransLog.c.
119 if (!basepath)
return;
121 g_free (log_base_name);
122 log_base_name = g_strdup (basepath);
void xaccTransWriteLog |
( |
Transaction * |
trans, |
|
|
char |
flag |
|
) |
| |
- Parameters
-
trans | The transaction to write out to the log |
flag | The engine currently uses the log mechanism with flag char set as follows: 'B' for 'begin edit' (followed by the transaction as it looks before any changes, i.e. the 'old value') 'D' for delete (i.e. delete the previous B; echoes the data in the 'old B') 'C' for commit (i.e. accept a previous B; data that follows is the 'new value') 'R' for rollback (i.e. revert to previous B; data that follows should be identical to old B) |
Definition at line 221 of file TransLog.c.
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...)
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)
#define GUID_ENCODING_LENGTH
#define xaccSplitGetGUID(X)
#define xaccTransGetGUID(X)
gnc_numeric xaccSplitGetValue(const Split *split)
Account * xaccSplitGetAccount(const Split *s)
time64 gnc_time(time64 *tbuf)
get the current local time
const char * xaccAccountGetName(const Account *acc)
gnc_numeric xaccSplitGetAmount(const Split *split)
void timespecFromTime64(Timespec *ts, time64 t)