Use message logging function instead of fprintf.
authorDaniel Carl <danielcarl@gmx.de>
Sun, 19 Jan 2014 16:37:17 +0000 (17:37 +0100)
committerDaniel Carl <danielcarl@gmx.de>
Sun, 19 Jan 2014 16:37:17 +0000 (17:37 +0100)
src/input.c
src/js.c
src/main.c
src/util.c

index d8f37b9..9ae2a52 100644 (file)
@@ -105,7 +105,7 @@ VbResult input_open_editor(void)
     /* spawn editor */
     char* command = g_strdup_printf(vb.config.editor_command, file_path);
     if (!g_shell_parse_argv(command, &argc, &argv, NULL)) {
-        fprintf(stderr, "Could not parse editor-command");
+        g_critical("Could not parse editor-command '%s'", command);
         g_free(command);
         return RESULT_ERROR;
     }
@@ -120,6 +120,7 @@ VbResult input_open_editor(void)
     if (!success) {
         unlink(file_path);
         g_free(file_path);
+        g_warning("Could not spawn editor-command");
         return RESULT_ERROR;
     }
 
index c54c613..3bc3a49 100644 (file)
--- a/src/js.c
+++ b/src/js.c
@@ -37,7 +37,7 @@ gboolean js_eval_file(WebKitWebFrame *frame, const char *file)
     ) {
         gboolean success = js_eval(frame, js, file, &value);
         if (!success) {
-            fprintf(stderr, "%s", value);
+            g_warning("JavaScript error in %s: %s", file, value);
         }
         g_free(value);
         g_free(js);
index 1b7e3a3..57d7447 100644 (file)
@@ -633,7 +633,7 @@ static void read_config(void)
     /* load default config */
     for (guint i = 0; default_config[i] != NULL; i++) {
         if (!ex_run_string(default_config[i])) {
-            fprintf(stderr, "Invalid default config: %s\n", default_config[i]);
+            g_error("Invalid default config: '%s'", default_config[i]);
         }
     }
 
@@ -648,7 +648,7 @@ static void read_config(void)
                 continue;
             }
             if (!ex_run_string(line)) {
-                fprintf(stderr, "Invalid config: %s\n", line);
+                g_warning("Invalid user config: '%s'", line);
             }
         }
     }
index 6e69b40..c368991 100644 (file)
@@ -76,7 +76,7 @@ char *util_get_file_contents(const char *filename, gsize *length)
     if (!(g_file_test(filename, G_FILE_TEST_IS_REGULAR)
         && g_file_get_contents(filename, &content, length, &error))
     ) {
-        fprintf(stderr, "Cannot open %s: %s\n", filename, error ? error->message : "file not found");
+        g_warning("Cannot open %s: %s", filename, error ? error->message : "file not found");
         g_clear_error(&error);
     }
     return content;
@@ -268,7 +268,7 @@ gboolean util_create_tmp_file(const char *content, char **file)
 
     fp = g_file_open_tmp(PROJECT "-XXXXXX", file, NULL);
     if (fp == -1) {
-        fprintf(stderr, "Could not create temporary file %s", *file);
+        g_critical("Could not create temp file %s", *file);
         g_free(*file);
         return false;
     }
@@ -280,7 +280,7 @@ gboolean util_create_tmp_file(const char *content, char **file)
     if (bytes < len) {
         close(fp);
         unlink(*file);
-        fprintf(stderr, "Could not write temporary file %s", *file);
+        g_critical("Could not write temp file %s", *file);
         g_free(*file);
 
         return false;