[gnome-calendar/wip/flb/weather-forecast: 12/50] weather: Add optional reading point logging



commit 11369e812d1d6bab461ab658b701d7673d22b143
Author: Florian Brosch <flo brosch gmail com>
Date:   Thu Oct 12 23:51:57 2017 +0200

    weather: Add optional reading point logging

 src/gcal-weather-service.c |   41 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 41 insertions(+), 0 deletions(-)
---
diff --git a/src/gcal-weather-service.c b/src/gcal-weather-service.c
index b8ef25b..b0fcfa7 100644
--- a/src/gcal-weather-service.c
+++ b/src/gcal-weather-service.c
@@ -339,6 +339,40 @@ gcal_weather_service_init (GcalWeatherService *self)
  * < private >
  **************/
 
+#if PRINT_WEATHER_DATA
+static gchar*
+gwc2str (GWeatherInfo *gwi)
+{
+    gchar *result = NULL; /* owned */
+
+    g_autoptr (GDateTime) date = NULL;
+    g_autofree gchar     *date_str = NULL;
+    glong      update;
+
+    gdouble    temp;
+
+    GWeatherConditionPhenomenon phen;
+
+    if (!gweather_info_get_value_update (gwi, &update))
+        return g_strdup ("<null>");
+
+    date = g_date_time_new_from_unix_local (update);
+    date_str = g_date_time_format (date, "%F %T"),
+
+    get_gweather_temperature (gwi, &temp);
+    get_gweather_phenomenon (gwi, &phen);
+
+
+    result = g_strdup_printf ("(%s: t:%f, w:%d)",
+                              date_str,
+                              temp,
+                              phen);
+    return result;
+}
+#endif
+
+
+
 /* get_time_day_start:
  * @self: The #GcalWeatherService instance.
  * @date: (out) (not nullable): A #GDate that should be set to today.
@@ -592,6 +626,13 @@ preprocess_gweather_reports (GcalWeatherService *self,
       if (!valid_date)
         continue;
 
+      #if PRINT_WEATHER_DATA
+      {
+        g_autofree gchar* dbg_str = gwc2str (gwi);
+        g_message ("WEATHER READING POINT: %s", dbg_str);
+      }
+      #endif
+
       if (gwi_dtime >= 0 && gwi_dtime >= today_unix)
         {
           bucket = (gwi_dtime - today_unix) / DAY_SECONDS;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]