init slog
[psensor.git] / src / main.c
index 323be42..134385d 100644 (file)
@@ -37,6 +37,7 @@
 #include "ui_sensorlist.h"
 #include "ui_color.h"
 #include "lmsensor.h"
+#include "slog.h"
 #include "ui_pref.h"
 #include "ui_graph.h"
 #include "ui_status.h"
@@ -118,23 +119,20 @@ static void print_help()
 }
 
 /*
-  Updates the size of the sensor values if different than the
-  configuration.
* Updates the size of the sensor values if different than the
* configuration.
  */
-void
+static void
 update_psensor_values_size(struct psensor **sensors, struct config *cfg)
 {
-       struct psensor **cur;
+       struct psensor **cur, *s;
 
-       cur = sensors;
-       while (*cur) {
-               struct psensor *s = *cur;
+       for (cur = sensors; *cur; cur++) {
+               s = *cur;
 
                if (s->values_max_length != cfg->sensor_values_max_length)
                        psensor_values_resize(s,
                                              cfg->sensor_values_max_length);
-
-               cur++;
        }
 }
 
@@ -168,6 +166,9 @@ static void update_measures(struct ui_psensor *ui)
 
                psensor_log_measures(sensors);
 
+               if (cfg->slog_enabled)
+                       slog_write_sensors(sensors);
+
                period = cfg->sensor_update_interval;
 
                g_mutex_unlock(ui->sensors_mutex);
@@ -325,6 +326,8 @@ static void associate_preferences(struct psensor **sensors)
                        s->name = n;
                }
 
+               s->appindicator_enabled = config_is_appindicator_enabled(s->id);
+
                sensor_cur++;
        }
 }
@@ -518,7 +521,7 @@ int main(int argc, char **argv)
                        exit(EXIT_SUCCESS);
                case 'd':
                        log_level = atoi(optarg);
-                       log_printf(LOG_INFO, _("Enables debug mode."));
+                       log_info(_("Enables debug mode."));
                        break;
                case 'n':
                        new_instance = 1;
@@ -572,6 +575,9 @@ int main(int argc, char **argv)
        ui.sensors = create_sensors_list(url, use_libatasmart);
        associate_cb_alarm_raised(ui.sensors, &ui);
 
+       if (ui.config->slog_enabled)
+               slog_init(NULL, ui.sensors);
+
 #if !defined(HAVE_APPINDICATOR) && !defined(HAVE_APPINDICATOR_029)
        ui_status_init(&ui);
        ui_status_set_visible(1);
@@ -611,7 +617,7 @@ int main(int argc, char **argv)
         * drawn before determining whether the main window must be
         * show.
         */
-       g_timeout_add(2000,(GSourceFunc)initial_window_show, &ui);
+       g_timeout_add(2000, (GSourceFunc)initial_window_show, &ui);
 
        /* main loop */
        gtk_main();