Browse code

jansson: add path to error log for easier debugging

Kelvin Chua authored on 26/01/2017 15:52:49
Showing 1 changed files
... ...
@@ -142,14 +142,14 @@ int janssonmod_set(unsigned int append, struct sip_msg* msg, char* type_in,
142 142
 	if(STR_EQ_STATIC(type_s, "object") || STR_EQ_STATIC(type_s, "obj")){
143 143
 		value = json_loads(value_s.s, JSON_REJECT_DUPLICATES, &parsing_error);
144 144
 		if(value && !json_is_object(value)) {
145
-			ERR("value to add is not an object\n");
145
+			ERR("value to add is not an object - \"%s\"\n", path_s.s);
146 146
 			goto fail;
147 147
 		}
148 148
 
149 149
 	}else if(STR_EQ_STATIC(type_s, "array")) {
150 150
 		value = json_loads(value_s.s, JSON_REJECT_DUPLICATES, &parsing_error);
151 151
 		if(value && !json_is_array(value)) {
152
-			ERR("value to add is not an array\n");
152
+			ERR("value to add is not an array - \"%s\"\n", path_s.s);
153 153
 			goto fail;
154 154
 		}
155 155
 
... ...
@@ -157,7 +157,7 @@ int janssonmod_set(unsigned int append, struct sip_msg* msg, char* type_in,
157 157
 				|| STR_EQ_STATIC(type_s, "str")) {
158 158
 		value = json_string(value_s.s);
159 159
 		if(!value || !json_is_string(value)) {
160
-			ERR("value to add is not a string\n");
160
+			ERR("value to add is not a string - \"%s\"\n", path_s.s);
161 161
 			goto fail;
162 162
 		}
163 163
 
... ...
@@ -165,24 +165,24 @@ int janssonmod_set(unsigned int append, struct sip_msg* msg, char* type_in,
165 165
 				|| STR_EQ_STATIC(type_s, "int")) {
166 166
 		long long i = strtoll(value_s.s, &endptr, 10);
167 167
 		if(*endptr != '\0') {
168
-			ERR("parsing int failed for \"%s\"\n", value_s.s);
168
+			ERR("parsing int failed for \"%s\" - \"%s\"\n", path_s.s, value_s.s);
169 169
 			goto fail;
170 170
 		}
171 171
 		value = json_integer(i);
172 172
 		if(!value || !json_is_integer(value)) {
173
-			ERR("value to add is not an integer\n");
173
+			ERR("value to add is not an integer \"%s\"\n", path_s.s);
174 174
 			goto fail;
175 175
 		}
176 176
 
177 177
 	}else if(STR_EQ_STATIC(type_s, "real")) {
178 178
 		double d = strtod(value_s.s, &endptr);
179 179
 		if(*endptr != '\0') {
180
-			ERR("parsing real failed for \"%s\"\n", value_s.s);
180
+			ERR("parsing real failed for \"%s\" - \"%s\"\n", path_s.s, value_s.s);
181 181
 			goto fail;
182 182
 		}
183 183
 		value = json_real(d);
184 184
 		if(!value || !json_is_real(value)) {
185
-			ERR("value to add is not a real\n");
185
+			ERR("value to add is not a real \"%s\"\n", path_s.s);
186 186
 			goto fail;
187 187
 		}
188 188