bmsd/ispindels.c

changeset 852
71f0fa38b634
parent 850
26cc7ea0f790
child 853
f54decd31acb
--- a/bmsd/ispindels.c	Tue Oct 17 11:54:38 2023 +0200
+++ b/bmsd/ispindels.c	Wed Oct 18 10:06:11 2023 +0200
@@ -231,10 +231,9 @@
     sys_ispindel_list	*ispindel, *tmpp;
     struct json_object  *jobj, *metric, *val;
     bool		new_ispindel = true;
-    char		*datetime, buf[65], *line, *logfile, *query = malloc(512);
+    char		*datetime, *query = malloc(512);
     struct tm           *mytime;
     time_t              timestamp;
-    FILE		*fp;
 
     //syslog(LOG_NOTICE, "ispindel_set: %s %s", node, payload);
 
@@ -341,58 +340,14 @@
     	snprintf(datetime, 72, "%04d-%02d-%02d %02d:%02d:%02d",
         	mytime->tm_year + 1900, mytime->tm_mon + 1, mytime->tm_mday, mytime->tm_hour, mytime->tm_min, mytime->tm_sec);
 
-	line = xstrcpy(datetime);
-    	line = xstrcat(line, (char *)",");
-	snprintf(buf, 64, "%.4f", ispindel->temperature);
-        line = xstrcat(line, buf);
-        line = xstrcat(line, (char *)",");
-	snprintf(buf, 64, "%.5f", ispindel->gravity);
-        line = xstrcat(line, buf);
-        line = xstrcat(line, (char *)",");
-	snprintf(buf, 64, "%.5f", plato_to_sg(ispindel->gravity));
-	line = xstrcat(line, buf);
-        line = xstrcat(line, (char *)",");
-        snprintf(buf, 64, "%.6f", ispindel->battery);
-        line = xstrcat(line, buf);
-        line = xstrcat(line, (char *)",");
-        snprintf(buf, 64, "%.5f", ispindel->angle);
-        line = xstrcat(line, buf);
-        line = xstrcat(line, (char *)",");
-	snprintf(buf, 64, "%d", ispindel->interval);
-        line = xstrcat(line, buf);
-        line = xstrcat(line, (char *)",");
-	line = xstrcat(line, ispindel->uuid);
-
 	snprintf(query, 511, "INSERT IGNORE INTO log_ispindel SET code='%s', datetime='%s', " \
 			"temperature='%.4f', plato='%.5f', sg='%.5f', battery='%.6f', " \
 			"angle='%.5f', refresh='%d', uuid='%s'",
 			ispindel->beercode, datetime, ispindel->temperature, ispindel->gravity, plato_to_sg(ispindel->gravity),
 			ispindel->battery, ispindel->angle, ispindel->interval, ispindel->uuid);
-	//syslog(LOG_NOTICE, "%s", query);
+	syslog(LOG_NOTICE, "%s", query);
 	bms_mysql_query(query);
 
-	/*
-	 * Build logfile name
-	 */
-	logfile = xstrcpy(Config.web_root);
-	logfile = xstrcat(logfile, (char *)"/log/ispindel/");
-	logfile = xstrcat(logfile, ispindel->beercode);
-	logfile = xstrcat(logfile, (char *)" ");
-	logfile = xstrcat(logfile, ispindel->beername);
-	logfile = xstrcat(logfile, (char *)".log");
-
-	fp = fopen(logfile, "a");
-	if (fp) {
-	    fprintf(fp, "%s\n", line);
-	    fclose(fp);
-	} else {
-	    syslog(LOG_NOTICE, "cannot append to `%s'", logfile);
-	}
-
-	free(logfile);
-	logfile = NULL;
-	free(line);
-	line = NULL;
 	free(datetime);
 	datetime = NULL;
     }

mercurial