GLOBAL PUT command logging added.

Tue, 02 Sep 2014 15:02:33 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Tue, 02 Sep 2014 15:02:33 +0200
changeset 278
76c8a6f18e4d
parent 277
6f9a7cca8f19
child 279
4c505414435c

GLOBAL PUT command logging added.

thermferm/server.c file | annotate | diff | comparison | revisions
--- a/thermferm/server.c	Tue Sep 02 14:14:54 2014 +0200
+++ b/thermferm/server.c	Tue Sep 02 15:02:33 2014 +0200
@@ -425,7 +425,7 @@
 			    } else if (strcmp(kwd, (char *)"ADDRESS") == 0) {
 				if (device->address) {
 				    if (strcmp(device->address, val))
-					syslog(LOG_NOTICE, "Device %s changed address %s to %s", device->uuid, device->address, val);
+					syslog(LOG_NOTICE, "Device %s changed address `%s' to `%s'", device->uuid, device->address, val);
 				    free(device->address);
 				}
 				device->address = xstrcpy(val);
@@ -447,7 +447,7 @@
 			    } else if (strcmp(kwd, (char *)"DESCRIPTION") == 0) {
 				if (device->description) {
 				    if (strcmp(device->description, val))
-					syslog(LOG_NOTICE, "Device %s changed description %s to %s", device->uuid, device->description, val);
+					syslog(LOG_NOTICE, "Device %s changed description `%s' to `%s'", device->uuid, device->description, val);
 				    free(device->description);
 				}
 				device->description = xstrcpy(val);
@@ -455,7 +455,7 @@
 			    } else if (strcmp(kwd, (char *)"COMMENT") == 0) {
 				if (device->comment) {
 				    if (strcmp(device->comment, val))
-					syslog(LOG_NOTICE, "Device %s changed comment %s to %s", device->uuid, device->comment, val);
+					syslog(LOG_NOTICE, "Device %s changed comment `%s' to `%s'", device->uuid, device->comment, val);
 				    free(device->comment);
 				}
 				device->comment = xstrcpy(val);
@@ -549,6 +549,8 @@
 		val = strtok(NULL, "\0");
 		if (kwd) {
 		    if (strcmp(kwd, (char *)"NAME") == 0) {
+			if (val && Config.name && strcmp(val, Config.name))
+			    syslog(LOG_NOTICE, "Global name `%s' to `%s'", Config.name, val);
 			if (Config.name)
 			    free(Config.name);
 			if (val)
@@ -557,14 +559,22 @@
 			    Config.name = NULL;
 
 		    } else if (val && (strcmp(kwd, (char *)"PORT") == 0)) {
-			if (sscanf(val, "%d", &ival) == 1)
+			if (sscanf(val, "%d", &ival) == 1) {
+			    if (Config.my_port != ival)
+			    	syslog(LOG_NOTICE, "Global port %d to %d", Config.my_port, ival);
 			    Config.my_port = ival;
+			}
 
 		    } else if (val && (strcmp(kwd, (char *)"TEMPFORMAT") == 0)) {
-			if ((val[0] == 'C') || (val[0] == 'F'))
+			if ((val[0] == 'C') || (val[0] == 'F')) {
+			    if (Config.tempFormat != val[0])
+				syslog(LOG_NOTICE, "Global port %c to %c", Config.tempFormat, val[0]);
 			    Config.tempFormat = val[0];
+			}
 
 		    } else if (strcmp(kwd, (char *)"TEMP_ADDRESS") == 0) {
+			if (val && Config.temp_address && (strcmp(val, Config.temp_address)))
+			    syslog(LOG_NOTICE, "Global temperature address `%s' to `%s'", Config.temp_address, val);
 		        if (Config.temp_address) {
 			    device_count(FALSE, Config.temp_address);
 			    free(Config.temp_address);
@@ -576,6 +586,8 @@
 			    Config.temp_address = NULL;
 
 		    } else if (strcmp(kwd, (char *)"HUM_ADDRESS") == 0) {
+			if (val && Config.hum_address && (strcmp(val, Config.hum_address)))
+			    syslog(LOG_NOTICE, "Global humidity address `%s' to `%s'", Config.hum_address, val);
 			if (Config.hum_address) {
 			    device_count(FALSE, Config.hum_address);
 			    free(Config.hum_address);
@@ -588,12 +600,18 @@
 
 #ifdef HAVE_WIRINGPI_H
 		    } else if (val && (strcmp(kwd, (char *)"LCD_COLS") == 0)) {
-			if (sscanf(val, "%d", &ival) == 1)
+			if (sscanf(val, "%d", &ival) == 1) {
+			    if (Config.lcd_cols != ival)
+				syslog(LOG_NOTICE, "Global LCD columns %d to %d", Config.lcd_cols, ival);
 			    Config.lcd_cols = ival;
+			}
 
 		    } else if (val && (strcmp(kwd, (char *)"LCD_ROWS") == 0)) {
-			if (sscanf(val, "%d", &ival) == 1)
+			if (sscanf(val, "%d", &ival) == 1) {
+			    if (Config.lcd_rows != ival)
+				syslog(LOG_NOTICE, "Global LCD rows %d to %d", Config.lcd_rows, ival);
 			    Config.lcd_rows = ival;
+			}
 #endif
 		    }
 		}

mercurial