mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Bug #642739 - Translog files being created in Gnucash program
installation directory Translog files for databases are now created in a directory "translog" inside the .gnucash dir. The files will be named following this scheme: <dbtype>_<hostname>_<user>_<dbname>.<timestamp>.log git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@20400 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
8306612eeb
commit
7e95b8635a
@ -29,6 +29,7 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <glib.h>
|
||||
#include <glib/gstdio.h>
|
||||
#if !HAVE_GMTIME_R
|
||||
#include "gmtime_r.h"
|
||||
@ -47,6 +48,7 @@
|
||||
|
||||
#include "gnc-gconf-utils.h"
|
||||
#include "gnc-uri-utils.h"
|
||||
#include "gnc-filepath-utils.h"
|
||||
#include "gnc-locale-utils.h"
|
||||
|
||||
#include "gnc-backend-dbi.h"
|
||||
@ -339,6 +341,12 @@ gnc_dbi_sqlite3_session_begin( QofBackend *qbe, QofSession *session,
|
||||
}
|
||||
be->sql_be.conn = create_dbi_connection( GNC_DBI_PROVIDER_SQLITE, qbe, be->conn );
|
||||
be->sql_be.timespec_format = SQLITE3_TIMESPEC_STR_FORMAT;
|
||||
|
||||
/* We should now have a proper session set up.
|
||||
* Let's start logging */
|
||||
xaccLogSetBaseName (filepath);
|
||||
PINFO ("logpath=%s", filepath ? filepath : "(null)");
|
||||
|
||||
exit:
|
||||
if ( filepath != NULL ) g_free ( filepath );
|
||||
if ( basename != NULL ) g_free( basename );
|
||||
@ -620,9 +628,7 @@ gnc_dbi_lock_database ( QofBackend* qbe, gboolean ignore_lock )
|
||||
result = NULL;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
}static void
|
||||
gnc_dbi_unlock( QofBackend *qbe )
|
||||
{
|
||||
GncDbiBackend *qe = (GncDbiBackend*)qbe;
|
||||
@ -722,6 +728,8 @@ gnc_dbi_mysql_session_begin( QofBackend* qbe, QofSession *session,
|
||||
gchar* dbname = NULL;
|
||||
gchar* username = NULL;
|
||||
gchar* password = NULL;
|
||||
gchar* basename = NULL;
|
||||
gchar* translog_path = NULL;
|
||||
gint portnum = 0;
|
||||
gint result;
|
||||
gboolean success = FALSE;
|
||||
@ -872,11 +880,20 @@ gnc_dbi_mysql_session_begin( QofBackend* qbe, QofSession *session,
|
||||
}
|
||||
be->sql_be.timespec_format = MYSQL_TIMESPEC_STR_FORMAT;
|
||||
|
||||
/* We should now have a proper session set up.
|
||||
* Let's start logging */
|
||||
basename = g_strjoin("_", protocol, host, username, dbname, NULL);
|
||||
translog_path = gnc_build_translog_path (basename);
|
||||
xaccLogSetBaseName (translog_path);
|
||||
PINFO ("logpath=%s", translog_path ? translog_path : "(null)");
|
||||
|
||||
exit:
|
||||
g_free( protocol );
|
||||
g_free( host );
|
||||
g_free( username );
|
||||
g_free( password );
|
||||
g_free( basename );
|
||||
g_free( translog_path );
|
||||
g_free( dbname );
|
||||
|
||||
LEAVE (" ");
|
||||
@ -984,6 +1001,8 @@ gnc_dbi_postgres_session_begin( QofBackend *qbe, QofSession *session,
|
||||
gchar *dbname = NULL, *dbnamelc = NULL;
|
||||
gchar* username = NULL;
|
||||
gchar* password = NULL;
|
||||
gchar* basename = NULL;
|
||||
gchar* translog_path = NULL;
|
||||
gboolean success = FALSE;
|
||||
gint portnum = 0;
|
||||
|
||||
@ -1129,11 +1148,21 @@ gnc_dbi_postgres_session_begin( QofBackend *qbe, QofSession *session,
|
||||
be->sql_be.conn = create_dbi_connection( GNC_DBI_PROVIDER_PGSQL, qbe, be->conn );
|
||||
}
|
||||
be->sql_be.timespec_format = PGSQL_TIMESPEC_STR_FORMAT;
|
||||
|
||||
/* We should now have a proper session set up.
|
||||
* Let's start logging */
|
||||
basename = g_strjoin("_", protocol, host, username, dbname, NULL);
|
||||
translog_path = gnc_build_translog_path (basename);
|
||||
xaccLogSetBaseName (translog_path);
|
||||
PINFO ("logpath=%s", translog_path ? translog_path : "(null)");
|
||||
|
||||
exit:
|
||||
g_free( protocol );
|
||||
g_free( host );
|
||||
g_free( username );
|
||||
g_free( password );
|
||||
g_free( basename );
|
||||
g_free( translog_path );
|
||||
g_free( dbname );
|
||||
g_free( dbnamelc );
|
||||
|
||||
@ -1197,6 +1226,9 @@ gnc_dbi_destroy_backend( /*@ only @*/ QofBackend *be )
|
||||
{
|
||||
g_return_if_fail( be != NULL );
|
||||
|
||||
/* Stop transaction logging */
|
||||
xaccLogSetBaseName (NULL);
|
||||
|
||||
qof_backend_destroy( be );
|
||||
|
||||
g_free( be );
|
||||
|
@ -310,6 +310,9 @@ gnc_dotgnucash_dir (void)
|
||||
tmp_dir = g_build_filename(dotgnucash, "checks", (gchar *)NULL);
|
||||
gnc_validate_directory(tmp_dir);
|
||||
g_free(tmp_dir);
|
||||
tmp_dir = g_build_filename(dotgnucash, "translog", (gchar *)NULL);
|
||||
gnc_validate_directory(tmp_dir);
|
||||
g_free(tmp_dir);
|
||||
|
||||
return dotgnucash;
|
||||
}
|
||||
@ -349,6 +352,27 @@ gnc_build_book_path (const gchar *filename)
|
||||
return result;
|
||||
}
|
||||
|
||||
/** @fn gchar * gnc_build_translog_path (const gchar *filename)
|
||||
* @brief Make a path to filename in the translog subdirectory of the user's configuration directory.
|
||||
*
|
||||
* @param filename The name of the file
|
||||
*
|
||||
* @return An absolute path.
|
||||
*/
|
||||
|
||||
gchar *
|
||||
gnc_build_translog_path (const gchar *filename)
|
||||
{
|
||||
gchar* filename_dup = g_strdup(filename);
|
||||
gchar* result = NULL;
|
||||
|
||||
scrub_filename(filename_dup);
|
||||
result = g_build_filename(gnc_dotgnucash_dir(), "translog",
|
||||
filename_dup, (gchar *)NULL);
|
||||
g_free(filename_dup);
|
||||
return result;
|
||||
}
|
||||
|
||||
/** @fn gchar * gnc_build_data_path (const gchar *filename)
|
||||
* @brief Make a path to filename in the data subdirectory of the user's configuration directory.
|
||||
*
|
||||
|
@ -44,6 +44,7 @@ gchar *gnc_resolve_file_path (const gchar *filefrag);
|
||||
const gchar *gnc_dotgnucash_dir (void);
|
||||
gchar *gnc_build_dotgnucash_path (const gchar *filename);
|
||||
gchar *gnc_build_book_path (const gchar *filename);
|
||||
gchar *gnc_build_translog_path (const gchar *filename);
|
||||
gchar *gnc_build_data_path (const gchar *filename);
|
||||
gchar *gnc_build_report_path (const gchar *filename);
|
||||
gchar *gnc_build_stdreports_path (const gchar *filename);
|
||||
|
Loading…
Reference in New Issue
Block a user