r23295 - gnucash/trunk/src/app-utils - Prefs migration: improve messaging
Geert Janssens
gjanssens at code.gnucash.org
Wed Oct 16 11:23:09 EDT 2013
Author: gjanssens
Date: 2013-10-16 11:23:08 -0400 (Wed, 16 Oct 2013)
New Revision: 23295
Trac: http://svn.gnucash.org/trac/changeset/23295
Modified:
gnucash/trunk/src/app-utils/gnc-gsettings.c
gnucash/trunk/src/app-utils/migrate-prefs.scm
Log:
Prefs migration: improve messaging
Redirect all messages to trace file (or wherever logs are configured to go)
Reduce default output by playing with the log levels
Modified: gnucash/trunk/src/app-utils/gnc-gsettings.c
===================================================================
--- gnucash/trunk/src/app-utils/gnc-gsettings.c 2013-10-16 15:22:56 UTC (rev 23294)
+++ gnucash/trunk/src/app-utils/gnc-gsettings.c 2013-10-16 15:23:08 UTC (rev 23295)
@@ -610,9 +610,9 @@
if (warning != NULL) {
ctxt->sax->warning = warning;
if (URL != NULL)
- warning(ctxt, "failed to load external entity \"%s\"\n", URL);
+ DEBUG ("External entity \"%s\" not loaded", URL);
else if (ID != NULL)
- warning(ctxt, "failed to load external entity \"%s\"\n", ID);
+ DEBUG ("External entity \"%s\" not loaded", ID);
}
return(NULL);
}
@@ -678,9 +678,10 @@
{
g_free (base_dir);
gnc_gsettings_set_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_MIGRATE_PREFS_DONE, TRUE);
- LEAVE ("No pre-existing GConf gnucash section found.\n"
+ PINFO ("No pre-existing GConf gnucash section found.\n"
"Most likely this system never ran GnuCash before.\n"
"Assume migration is not needed.");
+ LEAVE ();
return;
}
@@ -697,7 +698,7 @@
g_free (base_dir);
g_free (stylesheet);
g_free (input);
- LEAVE ("Migration input file and stylesheet missing. Skip migration.");
+ PWARN ("Migration input file and stylesheet missing. Skip migration.");
return;
}
@@ -712,7 +713,8 @@
g_free (base_dir);
g_free (stylesheet);
g_free (input);
- LEAVE ("Migration preparation step failed. Skip migration.");
+ PWARN ("Migration preparation step failed. Skip migration.");
+ LEAVE ();
return;
}
@@ -747,7 +749,8 @@
{
/* Actual migration step failed */
g_free (base_dir);
- LEAVE ("Actual migration step failed. Skip migration.");
+ PWARN ("Actual migration step failed. Skip migration.");
+ LEAVE ();
return;
}
@@ -762,11 +765,10 @@
DEBUG ("command = %s", command);
migration_ok = scm_is_true (scm_c_eval_string (command));
g_free (command);
- if (!migration_ok)
- {
- /* Actual migration step failed */
- DEBUG ("Cleanup step failed. You may need to delete %s/.gnc-migration-tmp manually.", base_dir);
- }
+ if (!migration_ok) /* Cleanup step failed, not critical */
+ PWARN ("Cleanup step failed. You may need to delete %s/.gnc-migration-tmp manually.", base_dir);
+ else
+ PINFO ("Preferences migration completed successfully");
LEAVE ("");
g_free (base_dir);
Modified: gnucash/trunk/src/app-utils/migrate-prefs.scm
===================================================================
--- gnucash/trunk/src/app-utils/migrate-prefs.scm 2013-10-16 15:22:56 UTC (rev 23294)
+++ gnucash/trunk/src/app-utils/migrate-prefs.scm 2013-10-16 15:23:08 UTC (rev 23295)
@@ -10,6 +10,8 @@
(define-module (migrate-prefs))
+(use-modules (gnucash main))
+
(define gconf-dir "")
(define prefix-length 0)
(define migration-dir "")
@@ -19,18 +21,17 @@
(base-name "")
(slash-index 0)
(dest-name ""))
- ;(display "processing file... ")(display filename)(newline)
+ (gnc:debug "Processing file... " filename)
(if (eq? (stat:type stats) 'regular)
(begin
(set! base-name (string-drop filename prefix-length))
- ;(display base-name)(newline)
(set! slash-index (- (string-rindex base-name #\%) 1))
(if (> slash-index 0)
(begin
(set! dest-name (string-take base-name (- (string-rindex base-name #\%) 1)))
(set! dest-name (string-join (string-split dest-name #\/) "-"))
(set! dest-name (string-append migration-dir "/" dest-name ".xml"))
- ;(format #t "~A -> ~A\n" base-name dest-name)
+ (gnc:debug "Copying " base-name " -> " dest-name)
(copy-file filename dest-name)
))))
(if (eq? (stat:type stats) 'directory)
@@ -66,13 +67,12 @@
; cleanup first if a previous migration attempt failed to do so
(if (access? migration-dir (logior R_OK W_OK X_OK))
(begin
- (format #t "Clear previous migration tmp dir ~A\n" migration-dir)
+ (gnc:msg "Clear previous migration tmp dir " migration-dir)
(migration-cleanup-internal)))
- (display "*** GnuCash switched to a new preferences system ***\n")
- (display "Attempt to migrate your preferences from the old to the new system\n")
+ (gnc:warn "*** GnuCash switched to a new preferences system ***")
+ (gnc:warn "Attempt to migrate your preferences from the old to the new system")
(mkdir migration-dir)
- (format #t "Copy all gconf files to tmp dir ~A\n" migration-dir)
- (display "Note: you can ignore the failed to load extnral entity warnings below. They are harmless.\n")
+ (gnc:msg "Copy all gconf files to tmp dir " migration-dir)
(apply find copy-one-file (list gconf-dir))
; Indicate successful preparation
#t
@@ -86,18 +86,17 @@
(set! migration-dir (string-append base-dir "/.gnc-migration-tmp"))
(catch #t
migration-prepare-internal
- (lambda args
- (display (string-append
- "An error occurred while preparing to migrate preferences."
- (newline) "The error is: "
- (symbol->string key) " - " (car (caddr args)) "."))
+ (lambda (key . args)
+ (gnc:error "An error occurred while preparing to migrate preferences.")
+ (gnc:error "The error is: "
+ (symbol->string key) " - " (car (caddr args)) ".")
#f))
)
(define (rmtree args)
(define (zap f)
(let ((rm (if (eq? (stat:type (stat f)) 'directory) rmdir delete-file)))
- ;(format #t "deleting ~A\n" f)
+ (gnc:debug "deleting " f)
(catch #t
(lambda () (rm f))
(lambda args (format #t "couldn't delete ~A\n" f)))))
@@ -113,14 +112,13 @@
(set! migration-dir (string-append base-dir "/.gnc-migration-tmp"))
(if (access? migration-dir (logior R_OK W_OK X_OK))
(begin
- (format #t "Delete tmp dir ~A\n" migration-dir)
+ (gnc:msg "Delete tmp dir " migration-dir)
(catch #t
migration-cleanup-internal
- (lambda args
- (display (string-append
- "An error occurred while cleaning up after preferences migration."
- (newline) "The error is: "
- (symbol->string key) " - " (car (caddr args)) "."))
+ (lambda (key . args)
+ (gnc:error "An error occurred while cleaning up after preferences migration.")
+ (gnc:error "The error is: "
+ (symbol->string key) " - " (car (caddr args)) ".")
#f))))
)
More information about the gnucash-changes
mailing list