From bf2df51c56df0d020834f13e47477c25c14a951f Mon Sep 17 00:00:00 2001 From: guyou Date: Sat, 14 Jul 2007 16:39:23 +0000 Subject: [PATCH] Converting printf calls Use of GLib message logging framework: http://developer.gnome.org/doc/API/2.0/glib/glib-Message-Logging.html git-svn-id: https://viking.svn.sourceforge.net/svnroot/viking/trunk@344 02d69b8e-d120-0410-893f-fe71a3b6e39e --- src/babel.c | 6 +++--- src/clipboard.c | 2 -- src/curl_download.c | 2 +- src/datasource_gps.c | 2 +- src/download.c | 2 +- src/googlesearch.c | 2 +- src/vikcoord.c | 2 +- src/vikfilelist.c | 2 +- src/vikgpslayer.c | 7 +++---- src/vikmapslayer.c | 4 ++-- src/viktrack.c | 9 +-------- src/viktrwlayer.c | 4 ++-- src/vikwindow.c | 14 +++++++------- 13 files changed, 24 insertions(+), 34 deletions(-) diff --git a/src/babel.c b/src/babel.c index 1661a2d..5fc0fb2 100644 --- a/src/babel.c +++ b/src/babel.c @@ -138,7 +138,7 @@ gboolean a_babel_convert_from_shellcommand ( VikTrwLayer *vt, const char *input_ ret = FALSE; } else { gchar *shell_command = g_strdup_printf("%s | gpsbabel -i %s -f - -o gpx -F %s", input_cmd, input_type, name_dst); - printf("%s\n", shell_command); + g_debug("%s", shell_command); close(fd_dst); args = g_malloc(sizeof(gchar *)*4); @@ -164,7 +164,7 @@ gboolean babel_general_convert_to( VikTrwLayer *vt, BabelStatusFunc cb, gchar ** gint babel_stdin, babel_stdout, babel_stderr; if (!a_file_export(vt, name_src, FILE_TYPE_GPX)) { - fprintf(stderr, "babel_general_convert_to(): error exporting to %s\n", name_src); + g_warning("babel_general_convert_to(): error exporting to %s\n", name_src); return(FALSE); } @@ -221,7 +221,7 @@ gboolean a_babel_convert_to( VikTrwLayer *vt, const char *babelargs, BabelStatus if ( unbuffer_loc ) g_free ( unbuffer_loc ); #ifdef DBG - fprintf(stderr, "cmd=%s\n", cmd); + g_debug("cmd=%s\n", cmd); #endif /* DBG */ args = g_strsplit(cmd, " ", 0); ret = babel_general_convert_to ( vt, cb, args, name_src, user_data ); diff --git a/src/clipboard.c b/src/clipboard.c index 1206331..dc98a58 100644 --- a/src/clipboard.c +++ b/src/clipboard.c @@ -145,8 +145,6 @@ static gboolean clip_parse_latlon ( const gchar *text, struct LatLon *coord ) gint j, k; cand = s+i; - // printf("Trying >>>>> %s\n", cand); - for (j=0; j<2; j++) { for (k=0; k<2; k++) { gchar fmt1[] = "N %d%*[ ]%lf W %d%*[ ]%lf"; diff --git a/src/curl_download.c b/src/curl_download.c index f19d5aa..840c859 100644 --- a/src/curl_download.c +++ b/src/curl_download.c @@ -59,7 +59,7 @@ static gchar *get_cookie_file(gboolean init) curl_easy_setopt(curl, CURLOPT_COOKIEJAR, cookie_file); res = curl_easy_perform(curl); if (res != CURLE_OK) { - fprintf(stderr, "%s() Curl perform failed: %s\n", __PRETTY_FUNCTION__, + g_warning("%s() Curl perform failed: %s\n", __PRETTY_FUNCTION__, curl_easy_strerror(res)); unlink(cookie_file); } diff --git a/src/datasource_gps.c b/src/datasource_gps.c index 1fbbd67..6a87884 100644 --- a/src/datasource_gps.c +++ b/src/datasource_gps.c @@ -115,7 +115,7 @@ static void datasource_gps_get_cmd_string ( gpointer user_data, gchar **babelarg *input_file = g_strdup_printf("%s", gtk_combo_box_get_active_iter(GTK_COMBO_BOX(w->ser_b),&iter)); #endif - fprintf(stderr, "using cmdline '%s' and file '%s'\n", *babelargs, *input_file); + g_debug("using cmdline '%s' and file '%s'\n", *babelargs, *input_file); } static void datasource_gps_cleanup ( gpointer user_data ) diff --git a/src/download.c b/src/download.c index fcaef0b..871c0ee 100644 --- a/src/download.c +++ b/src/download.c @@ -149,7 +149,7 @@ static int download( const char *hostname, const char *uri, const char *fn, Down if (ret == -1 || ret == 1 || ret == -2 || check_map_file(f)) { - fprintf(stderr, "Download error: %s\n", fn); + g_warning("Download error: %s\n", fn); fclose ( f ); remove ( tmpfilename ); g_free ( tmpfilename ); diff --git a/src/googlesearch.c b/src/googlesearch.c index 8037663..3803ea6 100644 --- a/src/googlesearch.c +++ b/src/googlesearch.c @@ -209,7 +209,7 @@ static int google_search_get_coord(VikWindow *vw, VikViewport *vvp, gchar *srch_ /* TODO: curl may not be available */ if (curl_download_uri(uri, tmp_file, &googlesearch_options)) { /* error */ - fprintf(stderr, "DEBUG: %s() download error\n", __PRETTY_FUNCTION__); + g_debug("DEBUG: %s() download error\n", __PRETTY_FUNCTION__); fclose(tmp_file); ret = -1; goto done; diff --git a/src/vikcoord.c b/src/vikcoord.c index 3614bac..086576a 100644 --- a/src/vikcoord.c +++ b/src/vikcoord.c @@ -166,7 +166,7 @@ gboolean vik_coord_inside(const VikCoord *coord, const VikCoord *tl, const VikCo vik_coord_to_latlon(br, &br_ll); #ifdef DEBUG - fprintf(stderr, "DEBUG: %s() ll=%f, %f tl=%f, %f br=%f, %f\n", + g_debug("DEBUG: %s() ll=%f, %f tl=%f, %f br=%f, %f\n", __PRETTY_FUNCTION__, ll.lat, ll.lon, tl_ll.lat, tl_ll.lon, br_ll.lat, br_ll.lon); #endif diff --git a/src/vikfilelist.c b/src/vikfilelist.c index 77c2205..c948c8b 100644 --- a/src/vikfilelist.c +++ b/src/vikfilelist.c @@ -117,7 +117,7 @@ static gboolean get_file_name(GtkTreeModel *model, GtkTreePath *path, GtkTreeIte { gchar *str; gtk_tree_model_get ( model, iter, 0, &str, -1 ); - printf("%s\n\n\n", str); + g_debug("get_file_name: %s", str); (*list) = g_list_append((*list), g_strdup(str)); return FALSE; } diff --git a/src/vikgpslayer.c b/src/vikgpslayer.c index 80d1c7e..cd03ce6 100644 --- a/src/vikgpslayer.c +++ b/src/vikgpslayer.c @@ -295,7 +295,7 @@ static VikLayerParamData gps_layer_get_param ( VikGpsLayer *vgl, guint16 id ) g_warning("gps_layer_get_param(): unknown parameter"); } - /* fprintf(stderr, "gps_layer_get_param() called\n"); */ + /* g_debug("gps_layer_get_param() called\n"); */ return rv; } @@ -505,8 +505,7 @@ static void gps_layer_drag_drop_request ( VikGpsLayer *val_src, VikGpsLayer *val gchar *dp; gboolean target_exists; - /* DEBUG */ - fprintf(stderr, "gps_layer_drag_drop_request() called\n"); + g_debug("gps_layer_drag_drop_request() called\n"); dp = gtk_tree_path_to_string(dest_path); target_exists = vik_treeview_get_iter_from_path_str(vt, &dest_iter, dp); @@ -829,7 +828,7 @@ static gint gps_comm(VikTrwLayer *vtl, gps_dir dir, vik_gps_proto proto, gchar * gps_session_delete(sess); } - // fprintf(stderr, "\"gps_comm: cmd_args=%s\" port=%s\n", sess->cmd_args, sess->port); + // g_debug("\"gps_comm: cmd_args=%s\" port=%s\n", sess->cmd_args, sess->port); return 0; } diff --git a/src/vikmapslayer.c b/src/vikmapslayer.c index 5c4c73f..0dbd5e8 100644 --- a/src/vikmapslayer.c +++ b/src/vikmapslayer.c @@ -597,7 +597,7 @@ static void maps_layer_draw_section ( VikMapsLayer *vml, VikViewport *vvp, VikCo gchar *path_buf = g_malloc ( max_path_len * sizeof(char) ); if ( vml->autodownload && should_start_autodownload(vml, vvp)) { - fprintf(stderr, "DEBUG: Starting autodownload\n"); + g_debug("DEBUG: Starting autodownload\n"); start_download_thread ( vml, vvp, ul, br, REDOWNLOAD_NONE ); } @@ -889,7 +889,7 @@ void maps_layer_download_section_without_redraw( VikMapsLayer *vml, VikViewport if (!map_type->coord_to_mapcoord(ul, zoom, zoom, &ulm) || !map_type->coord_to_mapcoord(br, zoom, zoom, &brm)) { - fprintf(stderr, "%s() coord_to_mapcoord() failed\n", __PRETTY_FUNCTION__); + g_warning("%s() coord_to_mapcoord() failed\n", __PRETTY_FUNCTION__); return; } diff --git a/src/viktrack.c b/src/viktrack.c index cbbdc8b..9ff7c74 100644 --- a/src/viktrack.c +++ b/src/viktrack.c @@ -570,7 +570,7 @@ gdouble *vik_track_make_speed_map ( const VikTrack *tr, guint16 num_chunks ) return NULL; if (duration < 0) { - fprintf(stderr, "negative duration: unsorted trackpoint timestamps?\n"); + g_warning("negative duration: unsorted trackpoint timestamps?\n"); return NULL; } pt_count = vik_track_get_tp_count(tr); @@ -596,13 +596,6 @@ gdouble *vik_track_make_speed_map ( const VikTrack *tr, guint16 num_chunks ) compute_spline(numpts, t, s, p); - /* - printf("Got spline\n"); - for (i=0; ix, event->y); - printf("Abort: shouldn't be here\n"); + g_critical("shouldn't be here"); exit(1); } else if ( params.closest_wp ) diff --git a/src/vikwindow.c b/src/vikwindow.c index 64d8748..0071190 100644 --- a/src/vikwindow.c +++ b/src/vikwindow.c @@ -833,7 +833,7 @@ void draw_goto_cb ( GtkAction *a, VikWindow *vw ) return; } else { - fprintf(stderr, "Houston we have a problem\n"); + g_critical("Houston we have a problem\n"); return; } @@ -909,7 +909,7 @@ static toolbox_tools_t* toolbox_create(VikWindow *vw) vt->active_tool = -1; vt->vw = vw; if (!vw->viking_vvp) { - printf("Error: no viewport found.\n"); + g_critical("no viewport found."); exit(1); } return vt; @@ -946,7 +946,7 @@ static void toolbox_activate(toolbox_tools_t *vt, const gchar *tool_name) VikLayer *vl = vik_layers_panel_get_selected ( vt->vw->viking_vlp ); if (tool == vt->n_tools) { - printf("panic: trying to activate a non-existent tool... \n"); + g_critical("trying to activate a non-existent tool..."); exit(1); } /* is the tool already active? */ @@ -1090,7 +1090,7 @@ static void load_file ( GtkAction *a, VikWindow *vw ) newwindow = FALSE; } else { - fprintf(stderr, "Houston we got a problem\n"); + g_critical("Houston we got a problem\n"); return; } @@ -1248,7 +1248,7 @@ static void save_image_file ( VikWindow *vw, const gchar *fn, guint w, guint h, gdk_pixbuf_save ( pixbuf_to_save, fn, save_as_png ? "png" : "jpeg", &error, NULL ); if (error) { - fprintf(stderr, "Unable to write to file %s: %s", fn, error->message ); + g_warning("Unable to write to file %s: %s", fn, error->message ); g_error_free (error); } g_object_unref ( G_OBJECT(pixbuf_to_save) ); @@ -1312,7 +1312,7 @@ static void save_image_dir ( VikWindow *vw, const gchar *fn, guint w, guint h, g gdk_pixbuf_save ( pixbuf_to_save, name_of_file, save_as_png ? "png" : "jpeg", &error, NULL ); if (error) { - fprintf(stderr, "Unable to write to file %s: %s", name_of_file, error->message ); + g_warning("Unable to write to file %s: %s", name_of_file, error->message ); g_error_free (error); } @@ -1545,7 +1545,7 @@ static void window_change_coord_mode_cb ( GtkAction *old_a, GtkAction *a, VikWin drawmode = VIK_VIEWPORT_DRAWMODE_MERCATOR; } else { - fprintf(stderr, "Houston, we got a problem!\n"); + g_critical("Houston, we got a problem!\n"); return; } -- 2.11.4.GIT