Browse code

socket_info.c: logging: convert LOG to LM_*

Ovidiu Sas authored on 04/10/2014 01:33:56
Showing 1 changed files
... ...
@@ -159,7 +159,7 @@ static int init_addr_info(struct addr_info* a,
159 159
 	a->flags=flags;
160 160
 	return 0;
161 161
 error:
162
-	LOG(L_ERR, "ERROR: init_addr_info: memory allocation error\n");
162
+	LM_ERR("memory allocation error\n");
163 163
 	return -1;
164 164
 }
165 165
 
... ...
@@ -178,7 +178,7 @@ static inline struct addr_info* new_addr_info(char* name,
178 178
 	if (init_addr_info(al, name, gf)!=0) goto error;
179 179
 	return al;
180 180
 error:
181
-	LOG(L_ERR, "ERROR: new_addr_info: memory allocation error\n");
181
+	LM_ERR("memory allocation error\n");
182 182
 	if (al){
183 183
 		if (al->name.s) pkg_free(al->name.s);
184 184
 		pkg_free(al);
... ...
@@ -260,7 +260,7 @@ static inline struct socket_info* new_sock_info(	char* name,
260 260
 	si->addr_info_lst=0;
261 261
 	for (n=addr_l; n; n=n->next){
262 262
 		if (new_addr_info2list(n->name, n->flags, &si->addr_info_lst)!=0){
263
-			LOG(L_ERR, "ERROR: new_sockk_info:new_addr_info2list failed\n");
263
+			LM_ERR("new_addr_info2list failed\n");
264 264
 			goto error;
265 265
 		}
266 266
 	}
... ...
@@ -296,14 +296,14 @@ static inline struct socket_info* new_sock_info(	char* name,
296 296
 
297 297
 		he=resolvehost(si->useinfo.name.s);
298 298
 		if (he==0){
299
-			LM_ERR(" unable to resolve advertised name %s\n", si->useinfo.name.s);
299
+			LM_ERR("unable to resolve advertised name %s\n", si->useinfo.name.s);
300 300
 			goto error;
301 301
 		}
302 302
 		hostent2ip_addr(&si->useinfo.address, he, 0);
303 303
 	}
304 304
 	return si;
305 305
 error:
306
-	LOG(L_ERR, "ERROR: new_sock_info: memory allocation error\n");
306
+	LM_ERR("memory allocation error\n");
307 307
 	if (si) {
308 308
 		if(si->name.s)
309 309
 			pkg_free(si->name.s);
... ...
@@ -437,7 +437,7 @@ static int fix_sock_str(struct socket_info* si)
437 437
 	
438 438
 	si->sock_str.s = pkg_malloc(len + 1);
439 439
 	if (si->sock_str.s == NULL) {
440
-		ERR("fix_sock_str: No memory left\n");
440
+		LM_ERR("No memory left\n");
441 441
 		return -1;
442 442
 	}
443 443
 	if (socketinfo2str(si->sock_str.s, &len, si, 0) < 0) {
... ...
@@ -454,7 +454,7 @@ static int fix_sock_str(struct socket_info* si)
454 454
 
455 455
 		si->useinfo.sock_str.s = pkg_malloc(len + 1);
456 456
 		if (si->useinfo.sock_str.s == NULL) {
457
-			ERR("fix_sock_str: No memory left\n");
457
+			LM_ERR("No memory left\n");
458 458
 			return -1;
459 459
 		}
460 460
 		if (socketinfo2str(si->useinfo.sock_str.s, &len, si, 1) < 0) {
... ...
@@ -495,7 +495,7 @@ struct socket_info** get_sock_info_list(unsigned short proto)
495 495
 #endif
496 496
 			break;
497 497
 		default:
498
-			LOG(L_CRIT, "BUG: get_sock_info_list: invalid proto %d\n", proto);
498
+			LM_CRIT("invalid proto %d\n", proto);
499 499
 	}
500 500
 	return 0;
501 501
 }
... ...
@@ -726,7 +726,7 @@ static struct socket_info* new_sock2list(char* name, struct name_lst* addr_l,
726 726
 	
727 727
 	si=new_sock_info(name, addr_l, port, proto, usename, useport, flags);
728 728
 	if (si==0){
729
-		LOG(L_ERR, "ERROR: new_sock2list: new_sock_info failed\n");
729
+		LM_ERR("new_sock_info failed\n");
730 730
 		goto error;
731 731
 	}
732 732
 	if(socket_workers>0) {
... ...
@@ -756,7 +756,7 @@ static struct socket_info* new_sock2list_after(char* name,
756 756
 	
757 757
 	si=new_sock_info(name, addr_l, port, proto, usename, useport, flags);
758 758
 	if (si==0){
759
-		LOG(L_ERR, "ERROR: new_sock2list_after: new_sock_info failed\n");
759
+		LM_ERR("new_sock_info failed\n");
760 760
 		goto error;
761 761
 	}
762 762
 	sock_listins(si, after);
... ...
@@ -804,7 +804,7 @@ int add_listen_advertise_iface(char* name, struct name_lst* addr_l,
804 804
 		if (c_proto!=PROTO_SCTP){
805 805
 			if (new_sock2list(name, 0, c_port, c_proto, usename, useport,
806 806
 								flags & ~SI_IS_MHOMED, list)==0){
807
-				LOG(L_ERR, "ERROR: add_listen_iface: new_sock2list failed\n");
807
+				LM_ERR("new_sock2list failed\n");
808 808
 				goto error;
809 809
 			}
810 810
 			/* add the other addresses in the list as separate sockets
... ...
@@ -813,15 +813,14 @@ int add_listen_advertise_iface(char* name, struct name_lst* addr_l,
813 813
 				if (new_sock2list(a_l->name, 0, c_port, 
814 814
 									c_proto, usename, useport,
815 815
 									flags & ~SI_IS_MHOMED, list)==0){
816
-					LOG(L_ERR, "ERROR: add_listen_iface: new_sock2list"
817
-								" failed\n");
816
+					LM_ERR("new_sock2list failed\n");
818 817
 					goto error;
819 818
 				}
820 819
 			}
821 820
 		}else{
822 821
 			if (new_sock2list(name, addr_l, c_port, c_proto, usename, useport,
823 822
 						flags, list)==0){
824
-				LOG(L_ERR, "ERROR: add_listen_iface: new_sock2list failed\n");
823
+				LM_ERR("new_sock2list failed\n");
825 824
 				goto error;
826 825
 			}
827 826
 		}
... ...
@@ -1190,8 +1189,7 @@ int add_interfaces_via_netlink(char* if_name, int family, unsigned short port,
1190 1190
 					}
1191 1191
 					/* save the info */
1192 1192
 					if (new_addr_info2list(tmp->addr, flags, ai_l)!=0){
1193
-						LOG(L_ERR, "ERROR: add_interfaces: "
1194
-							"new_addr_info2list failed\n");
1193
+						LM_ERR("new_addr_info2list failed\n");
1195 1194
 						goto error;
1196 1195
 			    		}
1197 1196
 				}
... ...
@@ -1241,13 +1239,12 @@ int add_interfaces(char* if_name, int family, unsigned short port,
1241 1241
 		ifc.ifc_len=size*sizeof(struct ifreq);
1242 1242
 		ifc.ifc_req=(struct ifreq*) pkg_malloc(size*sizeof(struct ifreq));
1243 1243
 		if (ifc.ifc_req==0){
1244
-			LOG(L_ERR, "ERROR: add_interfaces: memory allocation failure\n");
1244
+			LM_ERR("memory allocation failure\n");
1245 1245
 			goto error;
1246 1246
 		}
1247 1247
 		if (ioctl(s, SIOCGIFCONF, &ifc)==-1){
1248 1248
 			if(errno==EBADF) return 0; /* invalid descriptor => no such ifs*/
1249
-			LOG(L_ERR, "ERROR: add_interfaces: ioctl failed: %s\n",
1250
-					strerror(errno));
1249
+			LM_ERR("ioctl failed: %s\n", strerror(errno));
1251 1250
 			goto error;
1252 1251
 		}
1253 1252
 		if  ((lastlen) && (ifc.ifc_len==lastlen)) break; /*success,
... ...
@@ -1309,8 +1306,7 @@ int add_interfaces(char* if_name, int family, unsigned short port,
1309 1309
 				flags|=SI_IS_LO;
1310 1310
 			/* save the info */
1311 1311
 			if (new_addr_info2list(tmp, flags, ai_l)!=0){
1312
-				LOG(L_ERR, "ERROR: add_interfaces: "
1313
-						"new_addr_info2list failed\n");
1312
+				LM_ERR("new_addr_info2list failed\n");
1314 1313
 				goto error;
1315 1314
 			}
1316 1315
 			ret=0;
... ...
@@ -1350,20 +1346,20 @@ static int fix_hostname(str* name, struct ip_addr* address, str* address_str,
1350 1350
 	/* get "official hostnames", all the aliases etc. */
1351 1351
 	he=resolvehost(name->s);
1352 1352
 	if (he==0){
1353
-		LOG(L_ERR, "ERROR: fix_hostname: could not resolve %s\n", name->s);
1353
+		LM_ERR("could not resolve %s\n", name->s);
1354 1354
 		goto error;
1355 1355
 	}
1356 1356
 	/* check if we got the official name */
1357 1357
 	if (strcasecmp(he->h_name, name->s)!=0){
1358 1358
 		if (sr_auto_aliases && 
1359 1359
 				add_alias(name->s, name->len, s->port_no, s->proto)<0){
1360
-			LOG(L_ERR, "ERROR: fix_hostname: add_alias failed\n");
1360
+			LM_ERR("add_alias failed\n");
1361 1361
 		}
1362 1362
 		/* change the official name */
1363 1363
 		pkg_free(name->s);
1364 1364
 		name->s=(char*)pkg_malloc(strlen(he->h_name)+1);
1365 1365
 		if (name->s==0){
1366
-			LOG(L_ERR,  "ERROR: fix_hostname: out of memory.\n");
1366
+			LM_ERR("out of memory.\n");
1367 1367
 			goto error;
1368 1368
 		}
1369 1369
 		name->len=strlen(he->h_name);
... ...
@@ -1372,7 +1368,7 @@ static int fix_hostname(str* name, struct ip_addr* address, str* address_str,
1372 1372
 	/* add the aliases*/
1373 1373
 	for(h=he->h_aliases; sr_auto_aliases && h && *h; h++)
1374 1374
 		if (add_alias(*h, strlen(*h), s->port_no, s->proto)<0){
1375
-			LOG(L_ERR, "ERROR: fix_hostname: add_alias failed\n");
1375
+			LM_ERR("add_alias failed\n");
1376 1376
 		}
1377 1377
 	hostent2ip_addr(address, he, 0); /*convert to ip_addr format*/
1378 1378
 	if (type_flags){
... ...
@@ -1381,7 +1377,7 @@ static int fix_hostname(str* name, struct ip_addr* address, str* address_str,
1381 1381
 	if ((tmp=ip_addr2a(address))==0) goto error;
1382 1382
 	address_str->s=pkg_malloc(strlen(tmp)+1);
1383 1383
 	if (address_str->s==0){
1384
-		LOG(L_ERR, "ERROR: fix_hostname: out of memory.\n");
1384
+		LM_ERR("out of memory.\n");
1385 1385
 		goto error;
1386 1386
 	}
1387 1387
 	strncpy(address_str->s, tmp, strlen(tmp)+1);
... ...
@@ -1393,17 +1389,16 @@ static int fix_hostname(str* name, struct ip_addr* address, str* address_str,
1393 1393
 		/* do rev. DNS on it (for aliases)*/
1394 1394
 		he=rev_resolvehost(address);
1395 1395
 		if (he==0){
1396
-			LOG(L_WARN, "WARNING: fix_hostname: could not rev. resolve %s\n",
1397
-					name->s);
1396
+			LM_WARN("could not rev. resolve %s\n", name->s);
1398 1397
 		}else{
1399 1398
 			/* add the aliases*/
1400 1399
 			if (add_alias(he->h_name, strlen(he->h_name), s->port_no,
1401 1400
 							s->proto)<0){
1402
-				LOG(L_ERR, "ERROR: fix_hostname: add_alias failed\n");
1401
+				LM_ERR("add_alias failed\n");
1403 1402
 			}
1404 1403
 			for(h=he->h_aliases; h && *h; h++)
1405 1404
 				if (add_alias(*h, strlen(*h), s->port_no, s->proto) < 0){
1406
-					LOG(L_ERR, "ERROR: fix_hostname: add_alias failed\n");
1405
+					LM_ERR("add_alias failed\n");
1407 1406
 				}
1408 1407
 		}
1409 1408
 	}
... ...
@@ -1579,13 +1574,12 @@ static int fix_socket_list(struct socket_info **list, int* type_flags)
1579 1579
 		}
1580 1580
 		tmp=int2str(si->port_no, &len);
1581 1581
 		if (len>=MAX_PORT_LEN){
1582
-			LOG(L_ERR, "ERROR: fix_socket_list: bad port number: %d\n", 
1583
-						si->port_no);
1582
+			LM_ERR("bad port number: %d\n", si->port_no);
1584 1583
 			goto error;
1585 1584
 		}
1586 1585
 		si->port_no_str.s=(char*)pkg_malloc(len+1);
1587 1586
 		if (si->port_no_str.s==0){
1588
-			LOG(L_ERR, "ERROR: fix_socket_list: out of memory.\n");
1587
+			LM_ERR("out of memory.\n");
1589 1588
 			goto error;
1590 1589
 		}
1591 1590
 		strncpy(si->port_no_str.s, tmp, len+1);
... ...
@@ -1772,7 +1766,7 @@ static int fix_socket_list(struct socket_info **list, int* type_flags)
1772 1772
 #endif
1773 1773
 			){
1774 1774
 			if (si->flags & SI_IS_MCAST){
1775
-				LOG(L_WARN, "WARNING: removing entry %s:%s [%s]:%s\n",
1775
+				LM_WARN("removing entry %s:%s [%s]:%s\n",
1776 1776
 					get_valid_proto_name(si->proto), si->name.s, 
1777 1777
 					si->address_str.s, si->port_no_str.s);
1778 1778
 				l = si;
... ...
@@ -1783,7 +1777,7 @@ static int fix_socket_list(struct socket_info **list, int* type_flags)
1783 1783
 				ail=si->addr_info_lst;
1784 1784
 				while(ail){
1785 1785
 					if (ail->flags & SI_IS_MCAST){
1786
-						LOG(L_WARN, "WARNING: removing mh entry %s:%s"
1786
+						LM_WARN("removing mh entry %s:%s"
1787 1787
 								" [%s]:%s\n",
1788 1788
 								get_valid_proto_name(si->proto), ail->name.s, 
1789 1789
 								ail->address_str.s, si->port_no_str.s);
... ...
@@ -1892,21 +1886,18 @@ int fix_all_socket_lists()
1892 1892
 			/* if error fall back to get hostname */
1893 1893
 			/* get our address, only the first one */
1894 1894
 			if (uname (&myname) <0){
1895
-				LOG(L_ERR, "ERROR: fix_all_socket_lists: cannot determine"
1896
-						" hostname, try -l address\n");
1895
+				LM_ERR("cannot determine hostname, try -l address\n");
1897 1896
 				goto error;
1898 1897
 			}
1899 1898
 			if (add_listen_iface(myname.nodename, 0, 0, 0, 0)!=0){
1900
-				LOG(L_ERR, "ERROR: fix_all_socket_lists: add_listen_iface "
1901
-						"failed \n");
1899
+				LM_ERR("add_listen_iface failed \n");
1902 1900
 				goto error;
1903 1901
 			}
1904 1902
 		}
1905 1903
 	}
1906 1904
 	flags=0;
1907 1905
 	if (fix_socket_list(&udp_listen, &flags)!=0){
1908
-		LOG(L_ERR, "ERROR: fix_all_socket_lists: fix_socket_list"
1909
-				" udp failed\n");
1906
+		LM_ERR("fix_socket_list udp failed\n");
1910 1907
 		goto error;
1911 1908
 	}
1912 1909
 	if (flags){
... ...
@@ -1915,8 +1906,7 @@ int fix_all_socket_lists()
1915 1915
 #ifdef USE_TCP
1916 1916
 	flags=0;
1917 1917
 	if (!tcp_disable && (fix_socket_list(&tcp_listen, &flags)!=0)){
1918
-		LOG(L_ERR, "ERROR: fix_all_socket_lists: fix_socket_list"
1919
-				" tcp failed\n");
1918
+		LM_ERR("fix_socket_list tcp failed\n");
1920 1919
 		goto error;
1921 1920
 	}
1922 1921
 	if (flags){
... ...
@@ -1925,8 +1915,7 @@ int fix_all_socket_lists()
1925 1925
 #ifdef USE_TLS
1926 1926
 	flags=0;
1927 1927
 	if (!tls_disable && (fix_socket_list(&tls_listen, &flags)!=0)){
1928
-		LOG(L_ERR, "ERROR: fix_all_socket_lists: fix_socket_list"
1929
-				" tls failed\n");
1928
+		LM_ERR("fix_socket_list tls failed\n");
1930 1929
 		goto error;
1931 1930
 	}
1932 1931
 	if (flags){
... ...
@@ -1937,8 +1926,7 @@ int fix_all_socket_lists()
1937 1937
 #ifdef USE_SCTP
1938 1938
 	flags=0;
1939 1939
 	if (!sctp_disable && (fix_socket_list(&sctp_listen, &flags)!=0)){
1940
-		LOG(L_ERR, "ERROR: fix_all_socket_lists: fix_socket_list"
1941
-				" sctp failed\n");
1940
+		LM_ERR("fix_socket_list sctp failed\n");
1942 1941
 		goto error;
1943 1942
 	}
1944 1943
 	if (flags){
... ...
@@ -1956,7 +1944,7 @@ int fix_all_socket_lists()
1956 1956
 			&& (sctp_listen==0)
1957 1957
 #endif
1958 1958
 		){
1959
-		LOG(L_ERR, "ERROR: fix_all_socket_lists: no listening sockets\n");
1959
+		LM_ERR("no listening sockets\n");
1960 1960
 		goto error;
1961 1961
 	}
1962 1962
 	return 0;
... ...
@@ -2127,16 +2115,16 @@ int parse_protohostport(str* ins, sr_phostp_t *r)
2127 2127
 end:
2128 2128
 	return 0;
2129 2129
 error_brackets:
2130
-	LOG(L_ERR, "too many brackets in %.*s\n", ins->len, ins->s);
2130
+	LM_ERR("too many brackets in %.*s\n", ins->len, ins->s);
2131 2131
 	return -1;
2132 2132
 error_colons:
2133
-	LOG(L_ERR, "too many colons in %.*s\n", ins->len, ins->s);
2133
+	LM_ERR("too many colons in %.*s\n", ins->len, ins->s);
2134 2134
 	return -1;
2135 2135
 error_proto:
2136
-	LOG(L_ERR, "bad protocol in %.*s\n", ins->len, ins->s);
2136
+	LM_ERR("bad protocol in %.*s\n", ins->len, ins->s);
2137 2137
 	return -1;
2138 2138
 error_port:
2139
-	LOG(L_ERR, "bad port number in %.*s\n", ins->len, ins->s);
2139
+	LM_ERR("bad port number in %.*s\n", ins->len, ins->s);
2140 2140
 	return -1;
2141 2141
 }
2142 2142