Delegate transaction log enabling/disabling to the backends. Let only the xml backend enable logging.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@19254 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Geert Janssens 2010-06-12 16:03:42 +00:00
parent 86e75faa85
commit f21313c526
4 changed files with 8 additions and 46 deletions

View File

@ -297,10 +297,14 @@ xml_session_begin(QofBackend *be_start, QofSession *session,
}
}
/* ---------------------------------------------------- */
/* We should now have a fully resolved path name.
* Lets see if we can get a lock on it. */
* Let's start logging */
xaccLogSetBaseName (be->fullpath);
PINFO ("logpath=%s", be->fullpath ? be->fullpath : "(null)");
/* And let's see if we can get a lock on it. */
be->lockfile = g_strconcat(be->fullpath, ".LCK", NULL);
if (!ignore_lock && !gnc_xml_be_get_file_lock (be))
@ -362,6 +366,9 @@ xml_session_end(QofBackend *be_start)
static void
xml_destroy_backend(QofBackend *be)
{
/* Stop transactionlogging */
xaccLogSetBaseName (NULL);
qof_backend_destroy(be);
g_free(be);
}

View File

@ -454,13 +454,6 @@ void MainWindow::loadFile(const QString &fileName)
if (!we_are_in_error)
{
gchar *logpath = NULL;
if ( gnc_uri_is_file_uri ( newfile ) )
logpath = gnc_uri_get_path(newfile);
PINFO ("logpath=%s", logpath ? logpath : "(null)");
xaccLogSetBaseName (logpath);
g_free ( logpath );
xaccLogDisable();
{
@ -665,18 +658,6 @@ bool MainWindow::saveFileAs(const QString &fileName)
/* Whoa-ok. Blow away the previous file. */
}
/* XXX Would logging make sense for databases as well (mysql/postgres) ?
* Currently the logpath is relative to the data file path.
* Databases don't have a file path, so no logging will be
* done for them in the current setup.
*/
gchar *logpath = NULL;
if ( gnc_uri_is_file_uri ( newfile ) )
logpath = gnc_uri_get_path(newfile);
PINFO ("logpath=%s", logpath ? logpath : "(null)");
xaccLogSetBaseName (logpath);
g_free ( logpath );
/* Prevent race condition between swapping the contents of the two
* sessions, and actually installing the new session as the current

View File

@ -751,8 +751,6 @@ gxi_parse_file (GncXmlImportData *data)
goto cleanup_parse_file;
}
logpath = gnc_uri_get_path (data->filename);
xaccLogSetBaseName (logpath);
xaccLogDisable ();
gxi_update_progress_bar (_("Reading file..."), 0.0);
qof_session_load (session, gxi_update_progress_bar);

View File

@ -733,18 +733,6 @@ gnc_post_file_open (const char * filename)
if (!uh_oh)
{
Account *new_root;
gchar *logpath = NULL;
/* XXX Would logging make sense for databases as well (mysql/postgres) ?
* Currently the logpath is relative to the data file path.
* Databases don't have a file path, so no logging will be
* done for them in the current setup.
*/
if ( gnc_uri_is_file_uri ( newfile ) )
logpath = gnc_uri_get_path(newfile);
PINFO ("logpath=%s", logpath ? logpath : "(null)");
xaccLogSetBaseName (logpath);
g_free ( logpath );
/* If the new "file" is a database, attempt to store the password
* in a keyring. GnuCash itself will not save it.
@ -1083,7 +1071,6 @@ gnc_file_do_save_as (const char* filename)
char *norm_file;
char *newfile;
const char *oldfile;
gchar *logpath = NULL;
gchar *protocol=NULL;
gchar *hostname=NULL;
@ -1193,17 +1180,6 @@ gnc_file_do_save_as (const char* filename)
/* Whoa-ok. Blow away the previous file. */
}
/* XXX Would logging make sense for databases as well (mysql/postgres) ?
* Currently the logpath is relative to the data file path.
* Databases don't have a file path, so no logging will be
* done for them in the current setup.
*/
if ( gnc_uri_is_file_protocol ( protocol ) )
logpath = gnc_uri_get_path(newfile);
PINFO ("logpath=%s", logpath ? logpath : "(null)");
xaccLogSetBaseName (logpath);
g_free ( logpath );
/* If the new "file" is a database, attempt to store the password
* in a keyring. GnuCash itself will not save it.
*/