Browse code

tcp_main.c: logging: convert LOG to LM_*

Ovidiu Sas authored on 04/10/2014 02:42:25
Showing 1 changed files
... ...
@@ -327,8 +327,7 @@ static inline int init_sock_keepalive(int s)
327 327
 		optval=1;
328 328
 		if (setsockopt(s, SOL_SOCKET, SO_KEEPALIVE, &optval,
329 329
 						sizeof(optval))<0){
330
-			LOG(L_WARN, "WARNING: init_sock_keepalive: failed to enable"
331
-						" SO_KEEPALIVE: %s\n", strerror(errno));
330
+			LM_WARN("failed to enable SO_KEEPALIVE: %s\n", strerror(errno));
332 331
 			return -1;
333 332
 		}
334 333
 	}
... ...
@@ -337,8 +336,7 @@ static inline int init_sock_keepalive(int s)
337 337
 	if ((optval=cfg_get(tcp, tcp_cfg, keepintvl))){
338 338
 		if (setsockopt(s, IPPROTO_TCP, TCP_KEEPINTVL, &optval,
339 339
 						sizeof(optval))<0){
340
-			LOG(L_WARN, "WARNING: init_sock_keepalive: failed to set"
341
-						" keepalive probes interval: %s\n", strerror(errno));
340
+			LM_WARN("failed to set keepalive probes interval: %s\n", strerror(errno));
342 341
 		}
343 342
 	}
344 343
 #endif
... ...
@@ -346,8 +344,7 @@ static inline int init_sock_keepalive(int s)
346 346
 	if ((optval=cfg_get(tcp, tcp_cfg, keepidle))){
347 347
 		if (setsockopt(s, IPPROTO_TCP, TCP_KEEPIDLE, &optval,
348 348
 						sizeof(optval))<0){
349
-			LOG(L_WARN, "WARNING: init_sock_keepalive: failed to set"
350
-						" keepalive idle interval: %s\n", strerror(errno));
349
+			LM_WARN("failed to set keepalive idle interval: %s\n", strerror(errno));
351 350
 		}
352 351
 	}
353 352
 #endif
... ...
@@ -355,8 +352,7 @@ static inline int init_sock_keepalive(int s)
355 355
 	if ((optval=cfg_get(tcp, tcp_cfg, keepcnt))){
356 356
 		if (setsockopt(s, IPPROTO_TCP, TCP_KEEPCNT, &optval,
357 357
 						sizeof(optval))<0){
358
-			LOG(L_WARN, "WARNING: init_sock_keepalive: failed to set"
359
-						" maximum keepalive count: %s\n", strerror(errno));
358
+			LM_WARN("failed to set maximum keepalive count: %s\n", strerror(errno));
360 359
 		}
361 360
 	}
362 361
 #endif
... ...
@@ -378,8 +374,7 @@ static int init_sock_opt(int s, int af)
378 378
 	flags=1;
379 379
 	if ( (tcp_proto_no!=-1) && (setsockopt(s, tcp_proto_no , TCP_NODELAY,
380 380
 					&flags, sizeof(flags))<0) ){
381
-		LOG(L_WARN, "WARNING: init_sock_opt: could not disable Nagle: %s\n",
382
-				strerror(errno));
381
+		LM_WARN("could not disable Nagle: %s\n", strerror(errno));
383 382
 	}
384 383
 #endif
385 384
 	/* tos*/
... ...
@@ -387,15 +382,13 @@ static int init_sock_opt(int s, int af)
387 387
 	if(af==AF_INET){
388 388
 		if (setsockopt(s, IPPROTO_IP, IP_TOS, (void*)&optval,
389 389
 					sizeof(optval)) ==-1){
390
-			LOG(L_WARN, "WARNING: init_sock_opt: setsockopt tos: %s\n",
391
-					strerror(errno));
390
+			LM_WARN("setsockopt tos: %s\n", strerror(errno));
392 391
 			/* continue since this is not critical */
393 392
 		}
394 393
 	} else if(af==AF_INET6){
395 394
 		if (setsockopt(s, IPPROTO_IPV6, IPV6_TCLASS,
396 395
 					(void*)&optval, sizeof(optval)) ==-1) {
397
-			LOG(L_WARN, "WARNING: init_sock_opt: setsockopt v6 tos: %s\n",
398
-					strerror(errno));
396
+			LM_WARN("setsockopt v6 tos: %s\n", strerror(errno));
399 397
 			/* continue since this is not critical */
400 398
 		}
401 399
 	}
... ...
@@ -404,8 +397,7 @@ static int init_sock_opt(int s, int af)
404 404
 	optval=1;
405 405
 	if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR,
406 406
 						(void*)&optval, sizeof(optval))==-1){
407
-		LOG(L_ERR, "ERROR: setsockopt SO_REUSEADDR %s\n",
408
-				strerror(errno));
407
+		LM_ERR("setsockopt SO_REUSEADDR %s\n", strerror(errno));
409 408
 		/* continue, not critical */
410 409
 	}
411 410
 #endif /* !TCP_DONT_REUSEADDR */
... ...
@@ -413,8 +405,7 @@ static int init_sock_opt(int s, int af)
413 413
 	if ((optval=cfg_get(tcp, tcp_cfg, syncnt))){
414 414
 		if (setsockopt(s, IPPROTO_TCP, TCP_SYNCNT, &optval,
415 415
 						sizeof(optval))<0){
416
-			LOG(L_WARN, "WARNING: init_sock_opt: failed to set"
417
-						" maximum SYN retr. count: %s\n", strerror(errno));
416
+			LM_WARN("failed to set maximum SYN retr. count: %s\n", strerror(errno));
418 417
 		}
419 418
 	}
420 419
 #endif
... ...
@@ -422,8 +413,7 @@ static int init_sock_opt(int s, int af)
422 422
 	if ((optval=cfg_get(tcp, tcp_cfg, linger2))){
423 423
 		if (setsockopt(s, IPPROTO_TCP, TCP_LINGER2, &optval,
424 424
 						sizeof(optval))<0){
425
-			LOG(L_WARN, "WARNING: init_sock_opt: failed to set"
426
-						" maximum LINGER2 timeout: %s\n", strerror(errno));
425
+			LM_WARN("failed to set maximum LINGER2 timeout: %s\n", strerror(errno));
427 426
 		}
428 427
 	}
429 428
 #endif
... ...
@@ -432,8 +422,7 @@ static int init_sock_opt(int s, int af)
432 432
 		optval=0; /* reset quick ack => delayed ack */
433 433
 		if (setsockopt(s, IPPROTO_TCP, TCP_QUICKACK, &optval,
434 434
 						sizeof(optval))<0){
435
-			LOG(L_WARN, "WARNING: init_sock_opt: failed to reset"
436
-						" TCP_QUICKACK: %s\n", strerror(errno));
435
+			LM_WARN("failed to reset TCP_QUICKACK: %s\n", strerror(errno));
437 436
 		}
438 437
 	}
439 438
 #endif /* HAVE_TCP_QUICKACK */
... ...
@@ -442,13 +431,11 @@ static int init_sock_opt(int s, int af)
442 442
 	/* non-blocking */
443 443
 	flags=fcntl(s, F_GETFL);
444 444
 	if (flags==-1){
445
-		LOG(L_ERR, "ERROR: init_sock_opt: fnctl failed: (%d) %s\n",
446
-				errno, strerror(errno));
445
+		LM_ERR("fnctl failed: (%d) %s\n", errno, strerror(errno));
447 446
 		goto error;
448 447
 	}
449 448
 	if (fcntl(s, F_SETFL, flags|O_NONBLOCK)==-1){
450
-		LOG(L_ERR, "ERROR: init_sock_opt: fcntl: set non-blocking failed:"
451
-				" (%d) %s\n", errno, strerror(errno));
449
+		LM_ERR("fcntl: set non-blocking failed: (%d) %s\n", errno, strerror(errno));
452 450
 		goto error;
453 451
 	}
454 452
 	return 0;
... ...
@@ -477,14 +464,11 @@ static int init_sock_opt_accept(int s)
477 477
 	/* non-blocking */
478 478
 	flags=fcntl(s, F_GETFL);
479 479
 	if (flags==-1){
480
-		LOG(L_ERR, "ERROR: init_sock_opt_accept: fnctl failed: (%d) %s\n",
481
-				errno, strerror(errno));
480
+		LM_ERR("fnctl failed: (%d) %s\n", errno, strerror(errno));
482 481
 		goto error;
483 482
 	}
484 483
 	if (fcntl(s, F_SETFL, flags|O_NONBLOCK)==-1){
485
-		LOG(L_ERR, "ERROR: init_sock_opt_accept: "
486
-					"fcntl: set non-blocking failed: (%d) %s\n",
487
-					errno, strerror(errno));
484
+		LM_ERR("fcntl: set non-blocking failed: (%d) %s\n", errno, strerror(errno));
488 485
 		goto error;
489 486
 	}
490 487
 	return 0;
... ...
@@ -592,8 +576,7 @@ again:
592 592
 #endif
593 593
 		if (n<0){
594 594
 			if (errno==EINTR) continue;
595
-			LOG(L_ERR, "ERROR: tcp_blocking_connect %s: poll/select failed:"
596
-					" (%d) %s\n",
595
+			LM_ERR("%s: poll/select failed: (%d) %s\n",
597 596
 					su2a((union sockaddr_union*)servaddr, addrlen),
598 597
 					errno, strerror(errno));
599 598
 			goto error;
... ...
@@ -602,8 +585,7 @@ again:
602 602
 		if (FD_ISSET(fd, &sel_set))
603 603
 #else
604 604
 		if (pf.revents&(POLLERR|POLLHUP|POLLNVAL)){ 
605
-			LOG(L_ERR, "ERROR: tcp_blocking_connect %s: poll error: "
606
-					"flags %x\n",
605
+			LM_ERR("%s: poll error: flags %x\n",
607 606
 					su2a((union sockaddr_union*)servaddr, addrlen),
608 607
 					pf.revents);
609 608
 			poll_err=1;
... ...
@@ -614,8 +596,7 @@ again:
614 614
 			getsockopt(fd, SOL_SOCKET, SO_ERROR, &err, &err_len);
615 615
 			if ((err==0) && (poll_err==0)) goto end;
616 616
 			if (err!=EINPROGRESS && err!=EALREADY){
617
-				LOG(L_ERR, "ERROR: tcp_blocking_connect %s: SO_ERROR (%d) "
618
-						"%s\n",
617
+				LM_ERR("%s: SO_ERROR (%d) %s\n",
619 618
 						su2a((union sockaddr_union*)servaddr, addrlen),
620 619
 						err, strerror(err));
621 620
 				errno=err;
... ...
@@ -659,7 +640,7 @@ error_errno:
659 659
 			TCP_EV_CONNECT_ERR(errno, 0, 0,
660 660
 								(union sockaddr_union*)servaddr, type);
661 661
 	}
662
-	LOG(L_ERR, "ERROR: tcp_blocking_connect %s: (%d) %s\n",
662
+	LM_ERR("%s: (%d) %s\n",
663 663
 			su2a((union sockaddr_union*)servaddr, addrlen),
664 664
 			errno, strerror(errno));
665 665
 	goto error;
... ...
@@ -670,8 +651,8 @@ error_timeout:
670 670
 						(union sockaddr_union*)servaddr, send_flags, 0);
671 671
 #endif /* USE_DST_BLACKLIST */
672 672
 	TCP_EV_CONNECT_TIMEOUT(0, 0, 0, (union sockaddr_union*)servaddr, type);
673
-	LOG(L_ERR, "ERROR: tcp_blocking_connect %s: timeout %d s elapsed "
674
-				"from %d s\n", su2a((union sockaddr_union*)servaddr, addrlen),
673
+	LM_ERR("%s: timeout %d s elapsed from %d s\n",
674
+				su2a((union sockaddr_union*)servaddr, addrlen),
675 675
 				elapsed, cfg_get(tcp, tcp_cfg, connect_timeout_s));
676 676
 error:
677 677
 	TCP_STATS_CONNECT_FAILED();
... ...
@@ -708,7 +689,7 @@ inline static int _wbufq_add(struct  tcp_connection* c, const char* data,
708 708
 					((*tcp_total_wq+size)>cfg_get(tcp, tcp_cfg, tcp_wq_max)) ||
709 709
 					(q->first &&
710 710
 					TICKS_LT(q->wr_timeout, t)) )){
711
-		LOG(L_ERR, "ERROR: wbufq_add(%d bytes): write queue full or timeout "
711
+		LM_ERR("(%d bytes): write queue full or timeout "
712 712
 					" (%d, total %d, last write %d s ago)\n",
713 713
 					size, q->queued, *tcp_total_wq,
714 714
 					TICKS_TO_S(t-(q->wr_timeout-
... ...
@@ -801,7 +782,7 @@ inline static int _wbufq_insert(struct  tcp_connection* c, const char* data,
801 801
 		return _wbufq_add(c, data, size);
802 802
 	
803 803
 	if (unlikely((*tcp_total_wq+size)>cfg_get(tcp, tcp_cfg, tcp_wq_max))){
804
-		LOG(L_ERR, "ERROR: wbufq_insert(%d bytes): write queue full"
804
+		LM_ERR("(%d bytes): write queue full"
805 805
 					" (%d, total %d, last write %d s ago)\n",
806 806
 					size, q->queued, *tcp_total_wq,
807 807
 					TICKS_TO_S(get_ticks_raw()-q->wr_timeout-
... ...
@@ -809,7 +790,7 @@ inline static int _wbufq_insert(struct  tcp_connection* c, const char* data,
809 809
 		goto error;
810 810
 	}
811 811
 	if (unlikely(q->offset)){
812
-		LOG(L_CRIT, "BUG: wbufq_insert: non-null offset %d (bad call, should"
812
+		LM_CRIT("non-null offset %d (bad call, should"
813 813
 				"never be called after the wbufq_run())\n", q->offset);
814 814
 		goto error;
815 815
 	}
... ...
@@ -954,8 +935,7 @@ inline static int wbufq_run(int fd, struct tcp_connection* c, int* empty)
954 954
 						}
955 955
 					}
956 956
 					ret=-1;
957
-					LOG(L_ERR, "ERROR: wbuf_runq: %s [%d]\n",
958
-						strerror(errno), errno);
957
+					LM_ERR("%s [%d]\n", strerror(errno), errno);
959 958
 				}
960 959
 			}
961 960
 			break;
... ...
@@ -1007,8 +987,7 @@ again:
1007 1007
 	if (n<0){
1008 1008
 		if (errno==EINTR)	goto again;
1009 1009
 		else if (errno!=EAGAIN && errno!=EWOULDBLOCK){
1010
-			LOG(L_ERR, "tcp_blocking_write: failed to send: (%d) %s\n",
1011
-					errno, strerror(errno));
1010
+			LM_ERR("failed to send: (%d) %s\n", errno, strerror(errno));
1012 1011
 			TCP_EV_SEND_TIMEOUT(errno, &c->rcv);
1013 1012
 			TCP_STATS_SEND_TIMEOUT();
1014 1013
 			goto error;
... ...
@@ -1030,14 +1009,12 @@ again:
1030 1030
 		n=select(fd+1, 0, &sel_set, 0, &timeout);
1031 1031
 		if (n<0){
1032 1032
 			if (errno==EINTR) continue; /* signal, ignore */
1033
-			LOG(L_ERR, "ERROR: tcp_blocking_write: select failed: "
1034
-					" (%d) %s\n", errno, strerror(errno));
1033
+			LM_ERR("select failed: (%d) %s\n", errno, strerror(errno));
1035 1034
 			goto error;
1036 1035
 		}else if (n==0){
1037 1036
 			/* timeout */
1038 1037
 			if (get_ticks()-ticks>=tcp_send_timeout){
1039
-				LOG(L_ERR, "ERROR: tcp_blocking_write: send timeout (%d)\n",
1040
-						tcp_send_timeout);
1038
+				LM_ERR("send timeout (%d)\n", tcp_send_timeout);
1041 1039
 				goto error;
1042 1040
 			}
1043 1041
 			continue;
... ...
@@ -1067,14 +1044,14 @@ struct tcp_connection* tcpconn_new(int sock, union sockaddr_union* su,
1067 1067
 	rd_b_size=cfg_get(tcp, tcp_cfg, rd_buf_size);
1068 1068
 	c=shm_malloc(sizeof(struct tcp_connection) + rd_b_size);
1069 1069
 	if (c==0){
1070
-		LOG(L_ERR, "ERROR: tcpconn_new: mem. allocation failure\n");
1070
+		LM_ERR("mem. allocation failure\n");
1071 1071
 		goto error;
1072 1072
 	}
1073 1073
 	memset(c, 0, sizeof(struct tcp_connection)); /* zero init (skip rd buf)*/
1074 1074
 	c->s=sock;
1075 1075
 	c->fd=-1; /* not initialized */
1076 1076
 	if (lock_init(&c->write_lock)==0){
1077
-		LOG(L_ERR, "ERROR: tcpconn_new: init lock failed\n");
1077
+		LM_ERR("init lock failed\n");
1078 1078
 		goto error;
1079 1079
 	}
1080 1080
 	
... ...
@@ -1143,19 +1120,19 @@ inline static int tcp_do_connect(	union sockaddr_union* server,
1143 1143
 
1144 1144
 	s=socket(AF2PF(server->s.sa_family), SOCK_STREAM, 0);
1145 1145
 	if (unlikely(s==-1)){
1146
-		LOG(L_ERR, "ERROR: tcp_do_connect %s: socket: (%d) %s\n",
1146
+		LM_ERR("%s: socket: (%d) %s\n",
1147 1147
 				su2a(server, sizeof(*server)), errno, strerror(errno));
1148 1148
 		goto error;
1149 1149
 	}
1150 1150
 	if (init_sock_opt(s, server->s.sa_family)<0){
1151
-		LOG(L_ERR, "ERROR: tcp_do_connect %s: init_sock_opt failed\n",
1151
+		LM_ERR("%s: init_sock_opt failed\n",
1152 1152
 					su2a(server, sizeof(*server)));
1153 1153
 		goto error;
1154 1154
 	}
1155 1155
 	
1156 1156
 	if (unlikely(from && bind(s, &from->s, sockaddru_len(*from)) != 0)){
1157
-		LOG(L_WARN, "WARNING: tcp_do_connect: binding to source address"
1158
-					" %s failed: %s [%d]\n", su2a(from, sizeof(*from)),
1157
+		LM_WARN("binding to source address %s failed: %s [%d]\n",
1158
+					su2a(from, sizeof(*from)),
1159 1159
 					strerror(errno), errno);
1160 1160
 	}
1161 1161
 	*state=S_CONN_OK;
... ...
@@ -1199,7 +1176,7 @@ again:
1199 1199
 						TCP_EV_CONNECT_ERR(errno, 0, 0, server, type);
1200 1200
 				}
1201 1201
 				TCP_STATS_CONNECT_FAILED();
1202
-				LOG(L_ERR, "ERROR: tcp_do_connect: connect %s: (%d) %s\n",
1202
+				LM_ERR("connect %s: (%d) %s\n",
1203 1203
 							su2a(server, sizeof(*server)),
1204 1204
 							errno, strerror(errno));
1205 1205
 				goto error;
... ...
@@ -1209,8 +1186,8 @@ again:
1209 1209
 #endif /* TCP_ASYNC */
1210 1210
 		if (tcp_blocking_connect(s, type,  send_flags, &server->s,
1211 1211
 									sockaddru_len(*server))<0){
1212
-			LOG(L_ERR, "ERROR: tcp_do_connect: tcp_blocking_connect %s"
1213
-						" failed\n", su2a(server, sizeof(*server)));
1212
+			LM_ERR("tcp_blocking_connect %s failed\n",
1213
+						su2a(server, sizeof(*server)));
1214 1214
 			goto error;
1215 1215
 		}
1216 1216
 #ifdef TCP_ASYNC
... ...
@@ -1224,8 +1201,7 @@ again:
1224 1224
 	}
1225 1225
 	my_name_len=sizeof(my_name);
1226 1226
 	if (unlikely(getsockname(s, &my_name.s, &my_name_len)!=0)){
1227
-		LOG(L_ERR, "ERROR: tcp_do_connect: getsockname failed: %s(%d)\n",
1228
-				strerror(errno), errno);
1227
+		LM_ERR("getsockname failed: %s(%d)\n", strerror(errno), errno);
1229 1228
 		*res_si=0;
1230 1229
 		goto error;
1231 1230
 	}
... ...
@@ -1240,7 +1216,7 @@ find_socket:
1240 1240
 		*res_si=find_si(&ip, 0, PROTO_TCP);
1241 1241
 	
1242 1242
 	if (unlikely(*res_si==0)){
1243
-		LOG(L_WARN, "WARNING: tcp_do_connect %s: could not find corresponding"
1243
+		LM_WARN("%s: could not find corresponding"
1244 1244
 				" listening socket for %s, using default...\n",
1245 1245
 					su2a(server, sizeof(*server)), ip_addr2a(&ip));
1246 1246
 		if (server->s.sa_family==AF_INET) *res_si=sendipv4_tcp;
... ...
@@ -1268,15 +1244,14 @@ struct tcp_connection* tcpconn_connect( union sockaddr_union* server,
1268 1268
 	s=-1;
1269 1269
 	
1270 1270
 	if (*tcp_connections_no >= cfg_get(tcp, tcp_cfg, max_connections)){
1271
-		LOG(L_ERR, "ERROR: tcpconn_connect: maximum number of connections"
1272
-					" exceeded (%d/%d)\n",
1271
+		LM_ERR("maximum number of connections exceeded (%d/%d)\n",
1273 1272
 					*tcp_connections_no,
1274 1273
 					cfg_get(tcp, tcp_cfg, max_connections));
1275 1274
 		goto error;
1276 1275
 	}
1277 1276
 	if (unlikely(type==PROTO_TLS)) {
1278 1277
 		if (*tls_connections_no >= cfg_get(tcp, tcp_cfg, max_tls_connections)){
1279
-			LM_ERR("ERROR: maximum number of tls connections"
1278
+			LM_ERR("maximum number of tls connections"
1280 1279
 						" exceeded (%d/%d)\n",
1281 1280
 						*tls_connections_no,
1282 1281
 						cfg_get(tcp, tcp_cfg, max_tls_connections));
... ...
@@ -1286,13 +1261,13 @@ struct tcp_connection* tcpconn_connect( union sockaddr_union* server,
1286 1286
 
1287 1287
 	s=tcp_do_connect(server, from, type,  send_flags, &my_name, &si, &state);
1288 1288
 	if (s==-1){
1289
-		LOG(L_ERR, "ERROR: tcp_do_connect %s: failed (%d) %s\n",
1289
+		LM_ERR("tcp_do_connect %s: failed (%d) %s\n",
1290 1290
 				su2a(server, sizeof(*server)), errno, strerror(errno));
1291 1291
 		goto error;
1292 1292
 	}
1293 1293
 	con=tcpconn_new(s, server, &my_name, si, type, state);
1294 1294
 	if (con==0){
1295
-		LOG(L_ERR, "ERROR: tcp_connect %s: tcpconn_new failed, closing the "
1295
+		LM_ERR("%s: tcpconn_new failed, closing the "
1296 1296
 				 " socket\n", su2a(server, sizeof(*server)));
1297 1297
 		goto error;
1298 1298
 	}
... ...
@@ -1320,9 +1295,8 @@ int tcpconn_finish_connect( struct tcp_connection* c,
1320 1320
 	s=tcp_do_connect(&c->rcv.src_su, from, c->type, &c->send_flags,
1321 1321
 						&local_addr, &si, &state);
1322 1322
 	if (unlikely(s==-1)){
1323
-		LOG(L_ERR, "ERROR: tcpconn_finish_connect %s: tcp_do_connect for %p"
1324
-					" failed\n", su2a(&c->rcv.src_su, sizeof(c->rcv.src_su)),
1325
-					c);
1323
+		LM_ERR("%s: tcp_do_connect for %p failed\n",
1324
+					su2a(&c->rcv.src_su, sizeof(c->rcv.src_su)), c);
1326 1325
 		return -1;
1327 1326
 	}
1328 1327
 	c->rcv.bind_address=si;
... ...
@@ -1408,7 +1382,7 @@ inline static struct tcp_connection*  tcpconn_add(struct tcp_connection *c)
1408 1408
 												c->id_hash);
1409 1409
 		return c;
1410 1410
 	}else{
1411
-		LOG(L_CRIT, "tcpconn_add: BUG: null connection pointer\n");
1411
+		LM_CRIT("null connection pointer\n");
1412 1412
 		return 0;
1413 1413
 	}
1414 1414
 }
... ...
@@ -1609,8 +1583,7 @@ inline static int _tcpconn_add_alias_unsafe(struct tcp_connection* c, int port,
1609 1609
 						for (i=0; (i<p->aliases) && (&(p->con_aliases[i])!=a);
1610 1610
 								i++);
1611 1611
 						if (unlikely(i==p->aliases)){
1612
-							LOG(L_CRIT, "BUG: _tcpconn_add_alias_unsafe: "
1613
-									" alias %p not found in con %p (id %d)\n",
1612
+							LM_CRIT("alias %p not found in con %p (id %d)\n",
1614 1613
 									a, p, p->id);
1615 1614
 							goto error_not_found;
1616 1615
 						}
... ...
@@ -1700,32 +1673,29 @@ int tcpconn_add_alias(int id, int port, int proto)
1700 1700
 	return 0;
1701 1701
 error_not_found:
1702 1702
 	TCPCONN_UNLOCK;
1703
-	LOG(L_ERR, "ERROR: tcpconn_add_alias: no connection found for id %d\n",id);
1703
+	LM_ERR("no connection found for id %d\n",id);
1704 1704
 	return -1;
1705 1705
 error:
1706 1706
 	TCPCONN_UNLOCK;
1707 1707
 	switch(ret){
1708 1708
 		case -2:
1709
-			LOG(L_ERR, "ERROR: tcpconn_add_alias: too many aliases (%d)"
1710
-					" for connection %p (id %d) %s:%d <- %d\n",
1709
+			LM_ERR("too many aliases (%d) for connection %p (id %d) %s:%d <- %d\n",
1711 1710
 					c->aliases, c, c->id, ip_addr2a(&c->rcv.src_ip),
1712 1711
 					c->rcv.src_port, port);
1713 1712
 			for (r=0; r<c->aliases; r++){
1714
-				LOG(L_ERR, "ERROR: tcpconn_add_alias: alias %d: for %p (%d)"
1715
-						" %s:%d <-%d hash %x\n",  r, c, c->id, 
1716
-						 ip_addr2a(&c->rcv.src_ip), c->rcv.src_port, 
1713
+				LM_ERR("alias %d: for %p (%d) %s:%d <-%d hash %x\n",  r, c, c->id, 
1714
+						ip_addr2a(&c->rcv.src_ip), c->rcv.src_port, 
1717 1715
 						c->con_aliases[r].port, c->con_aliases[r].hash);
1718 1716
 			}
1719 1717
 			break;
1720 1718
 		case -3:
1721
-			LOG(L_ERR, "ERROR: tcpconn_add_alias: possible port"
1722
-					" hijack attempt\n");
1723
-			LOG(L_ERR, "ERROR: tcpconn_add_alias: alias for %d port %d already"
1719
+			LM_ERR("possible port hijack attempt\n");
1720
+			LM_ERR("alias for %d port %d already"
1724 1721
 						" present and points to another connection \n",
1725 1722
 						c->id, port);
1726 1723
 			break;
1727 1724
 		default:
1728
-			LOG(L_ERR, "ERROR: tcpconn_add_alias: unknown error %d\n", ret);
1725
+			LM_ERR("unknown error %d\n", ret);
1729 1726
 	}
1730 1727
 	return -1;
1731 1728
 }
... ...
@@ -1818,7 +1788,7 @@ int tcp_send(struct dest_info* dst, union sockaddr_union* from,
1818 1818
 	}else if (likely(dst->id)){
1819 1819
 		c=tcpconn_get(dst->id, 0, 0, 0, con_lifetime);
1820 1820
 	}else{
1821
-		LOG(L_CRIT, "BUG: tcp_send called with null id & to\n");
1821
+		LM_CRIT("null id & to\n");
1822 1822
 		return -1;
1823 1823
 	}
1824 1824
 	
... ...
@@ -1828,8 +1798,7 @@ int tcp_send(struct dest_info* dst, union sockaddr_union* from,
1828 1828
 				/* try again w/o id */
1829 1829
 				c=tcpconn_get(0, &ip, port, from, con_lifetime);
1830 1830
 			}else{
1831
-				LOG(L_ERR, "ERROR: tcp_send: id %d not found, dropping\n",
1832
-						dst->id);
1831
+				LM_ERR("id %d not found, dropping\n", dst->id);
1833 1832
 				return -1;
1834 1833
 			}
1835 1834
 		}
... ...
@@ -1867,8 +1836,7 @@ int tcp_send(struct dest_info* dst, union sockaddr_union* from,
1867 1867
 					cfg_get(tcp, tcp_cfg, async) )){
1868 1868
 			if (unlikely(*tcp_connections_no >=
1869 1869
 							cfg_get(tcp, tcp_cfg, max_connections))){
1870
-				LOG(L_ERR, "ERROR: tcp_send %s: maximum number of"
1871
-							" connections exceeded (%d/%d)\n",
1870
+				LM_ERR("%s: maximum number of connections exceeded (%d/%d)\n",
1872 1871
 							su2a(&dst->to, sizeof(dst->to)),
1873 1872
 							*tcp_connections_no,
1874 1873
 							cfg_get(tcp, tcp_cfg, max_connections));
... ...
@@ -1877,8 +1845,7 @@ int tcp_send(struct dest_info* dst, union sockaddr_union* from,
1877 1877
 			if (unlikely(dst->proto==PROTO_TLS)) {
1878 1878
 				if (unlikely(*tls_connections_no >=
1879 1879
 							cfg_get(tcp, tcp_cfg, max_tls_connections))){
1880
-					LM_ERR("tcp_send %s: maximum number of"
1881
-							" tls connections exceeded (%d/%d)\n",
1880
+					LM_ERR("%s: maximum number of tls connections exceeded (%d/%d)\n",
1882 1881
 							su2a(&dst->to, sizeof(dst->to)),
1883 1882
 							*tls_connections_no,
1884 1883
 							cfg_get(tcp, tcp_cfg, max_tls_connections));
... ...
@@ -1888,8 +1855,7 @@ int tcp_send(struct dest_info* dst, union sockaddr_union* from,
1888 1888
 			c=tcpconn_new(-1, &dst->to, from, 0, dst->proto,
1889 1889
 							S_CONN_CONNECT);
1890 1890
 			if (unlikely(c==0)){
1891
-				LOG(L_ERR, "ERROR: tcp_send %s: could not create new"
1892
-						" connection\n",
1891
+				LM_ERR("%s: could not create new connection\n",
1893 1892
 						su2a(&dst->to, sizeof(dst->to)));
1894 1893
 				return -1;
1895 1894
 			}
... ...
@@ -1899,10 +1865,8 @@ int tcp_send(struct dest_info* dst, union sockaddr_union* from,
1899 1899
 										 table */
1900 1900
 			/* add it to id hash and aliases */
1901 1901
 			if (unlikely(tcpconn_add(c)==0)){
1902
-				LOG(L_ERR, "ERROR: tcp_send %s: could not add "
1903
-							"connection %p\n",
1904
-							su2a(&dst->to, sizeof(dst->to)),
1905
-								c);
1902
+				LM_ERR("%s: could not add connection %p\n",
1903
+						su2a(&dst->to, sizeof(dst->to)), c);
1906 1904
 				_tcpconn_free(c);
1907 1905
 				n=-1;
1908 1906
 				goto end_no_conn;
... ...
@@ -1912,9 +1876,8 @@ int tcp_send(struct dest_info* dst, union sockaddr_union* from,
1912 1912
 			if (unlikely((fd=tcpconn_finish_connect(c, from))<0)){
1913 1913
 				/* tcpconn_finish_connect will automatically blacklist
1914 1914
 				   on error => no need to do it here */
1915
-				LOG(L_ERR, "ERROR: tcp_send %s: tcpconn_finish_connect(%p)"
1916
-						" failed\n", su2a(&dst->to, sizeof(dst->to)),
1917
-							c);
1915
+				LM_ERR("%s: tcpconn_finish_connect(%p) failed\n",
1916
+						su2a(&dst->to, sizeof(dst->to)), c);
1918 1917
 				goto conn_wait_error;
1919 1918
 			}
1920 1919
 			/* ? TODO: it might be faster just to queue the write directly
... ...
@@ -2049,8 +2012,7 @@ redo_tls_encode:
2049 2049
 			response[0]=(long)c;
2050 2050
 			if (unlikely(send_fd(unix_tcp_sock, response,
2051 2051
 									sizeof(response), fd) <= 0)){
2052
-				LOG(L_ERR, "BUG: tcp_send %s: %ld for %p"
2053
-							" failed:" " %s (%d)\n",
2052
+				LM_ERR("%s: %ld for %p failed:" " %s (%d)\n",
2054 2053
 							su2a(&dst->to, sizeof(dst->to)),
2055 2054
 							response[1], c, strerror(errno), errno);
2056 2055
 				goto conn_wait_error;
... ...
@@ -2060,8 +2022,7 @@ redo_tls_encode:
2060 2060
 #endif /* TCP_CONNECT_WAIT  && TCP_ASYNC */
2061 2061
 		if (unlikely((c=tcpconn_connect(&dst->to, from, dst->proto,
2062 2062
 										&dst->send_flags))==0)){
2063
-			LOG(L_ERR, "ERROR: tcp_send %s: connect failed\n",
2064
-							su2a(&dst->to, sizeof(dst->to)));
2063
+			LM_ERR("%s: connect failed\n", su2a(&dst->to, sizeof(dst->to)));
2065 2064
 			return -1;
2066 2065
 		}
2067 2066
 		tcpconn_set_send_flags(c, dst->send_flags);
... ...
@@ -2079,7 +2040,7 @@ redo_tls_encode:
2079 2079
 		response[1]=CONN_NEW;
2080 2080
 		n=send_fd(unix_tcp_sock, response, sizeof(response), c->s);
2081 2081
 		if (unlikely(n<=0)){
2082
-			LOG(L_ERR, "BUG: tcp_send %s: failed send_fd: %s (%d)\n",
2082
+			LM_ERR("%s: failed send_fd: %s (%d)\n",
2083 2083
 					su2a(&dst->to, sizeof(dst->to)),
2084 2084
 					strerror(errno), errno);
2085 2085
 			/* we can safely delete it, it's not referenced by anybody */
... ...
@@ -2178,7 +2139,7 @@ conn_wait_success:
2178 2178
 	} else
2179 2179
 #endif /* TCP_FD_CACHE */
2180 2180
 		if (unlikely (tcp_safe_close(fd) < 0))
2181
-			LOG(L_ERR, "closing temporary send fd for %p: %s: "
2181
+			LM_ERR("closing temporary send fd for %p: %s: "
2182 2182
 					"close(%d) failed (flags 0x%x): %s (%d)\n", c,
2183 2183
 					su2a(&c->rcv.src_su, sizeof(c->rcv.src_su)),
2184 2184
 					fd, c->flags, strerror(errno), errno);
... ...
@@ -2198,7 +2159,7 @@ conn_wait_close:
2198 2198
 	   a reader one) => if the connect was successful close the fd */
2199 2199
 	if (fd>=0) {
2200 2200
 		if (unlikely(tcp_safe_close(fd) < 0 ))
2201
-			LOG(L_ERR, "closing temporary send fd for %p: %s: "
2201
+			LM_ERR("closing temporary send fd for %p: %s: "
2202 2202
 					"close(%d) failed (flags 0x%x): %s (%d)\n", c,
2203 2203
 					su2a(&c->rcv.src_su, sizeof(c->rcv.src_su)),
2204 2204
 					fd, c->flags, strerror(errno), errno);
... ...
@@ -2339,16 +2300,15 @@ static int tcpconn_send_put(struct tcp_connection* c, const char* buf,
2339 2339
 			response[1]=CONN_GET_FD;
2340 2340
 			n=send_all(unix_tcp_sock, response, sizeof(response));
2341 2341
 			if (unlikely(n<=0)){
2342
-				LOG(L_ERR, "BUG: tcp_send: failed to get fd(write):%s (%d)\n",
2343
-						strerror(errno), errno);
2342
+				LM_ERR("failed to get fd(write):%s (%d)\n", strerror(errno), errno);
2344 2343
 				n=-1;
2345 2344
 				goto release_c;
2346 2345
 			}
2347 2346
 			DBG("tcp_send, c= %p, n=%d\n", c, n);
2348 2347
 			n=receive_fd(unix_tcp_sock, &tmp, sizeof(tmp), &fd, MSG_WAITALL);
2349 2348
 			if (unlikely(n<=0)){
2350
-				LOG(L_ERR, "BUG: tcp_send: failed to get fd(receive_fd):"
2351
-							" %s (%d)\n", strerror(errno), errno);
2349
+				LM_ERR("failed to get fd(receive_fd): %s (%d)\n",
2350
+						strerror(errno), errno);
2352 2351
 				n=-1;
2353 2352
 				do_close_fd=0;
2354 2353
 				goto release_c;
... ...
@@ -2460,7 +2420,7 @@ end:
2460 2460
 #endif /* TCP_FD_CACHE */
2461 2461
 	if (do_close_fd) {
2462 2462
 		if (unlikely(tcp_safe_close(fd) < 0))
2463
-			LOG(L_ERR, "closing temporary send fd for %p: %s: "
2463
+			LM_ERR("closing temporary send fd for %p: %s: "
2464 2464
 					"close(%d) failed (flags 0x%x): %s (%d)\n", c,
2465 2465
 					su2a(&c->rcv.src_su, sizeof(c->rcv.src_su)),
2466 2466
 					fd, c->flags, strerror(errno), errno);
... ...
@@ -2654,8 +2614,8 @@ static int tcpconn_do_send(int fd, struct tcp_connection* c,
2654 2654
 					break;
2655 2655
 			}
2656 2656
 		}
2657
-		LOG(L_ERR, "ERROR: tcp_send: failed to send on %p (%s:%d->%s): %s (%d)"
2658
-					"\n", c, ip_addr2a(&c->rcv.dst_ip), c->rcv.dst_port,
2657
+		LM_ERR("failed to send on %p (%s:%d->%s): %s (%d)\n",
2658
+					c, ip_addr2a(&c->rcv.dst_ip), c->rcv.dst_port,
2659 2659
 					su2a(&c->rcv.src_su, sizeof(c->rcv.src_su)),
2660 2660
 					strerror(errno), errno);
2661 2661
 		n = -1;
... ...
@@ -2747,8 +2707,7 @@ static int tcpconn_1st_send(int fd, struct tcp_connection* c,
2747 2747
 				if (unlikely(_wbufq_insert(c, buf+n, len-n)<0)){
2748 2748
 					if (likely(!locked)) lock_release(&c->write_lock);
2749 2749
 					n=-1;
2750
-					LOG(L_ERR, "%s: EAGAIN and"
2751
-							" write queue full or failed for %p\n",
2750
+					LM_ERR("%s: EAGAIN and write queue full or failed for %p\n",
2752 2751
 							su2a(&c->rcv.src_su, sizeof(c->rcv.src_su)), c);
2753 2752
 					goto error;
2754 2753
 				}
... ...
@@ -2786,12 +2745,12 @@ static int tcpconn_1st_send(int fd, struct tcp_connection* c,
2786 2786
 		}
2787 2787
 		/* error: destroy it directly */
2788 2788
 		TCP_STATS_CONNECT_FAILED();
2789
-		LOG(L_ERR, "%s: connect & send  for %p failed:" " %s (%d)\n",
2789
+		LM_ERR("%s: connect & send  for %p failed:" " %s (%d)\n",
2790 2790
 					su2a(&c->rcv.src_su, sizeof(c->rcv.src_su)),
2791 2791
 					c, strerror(errno), errno);
2792 2792
 		goto error;
2793 2793
 	}
2794
-	LOG(L_INFO, "quick connect for %p\n", c);
2794
+	LM_INFO("quick connect for %p\n", c);
2795 2795
 	if (likely(c->state == S_CONN_CONNECT))
2796 2796
 		TCP_STATS_ESTABLISHED(S_CONN_CONNECT);
2797 2797
 	if (unlikely(send_flags.f & SND_F_CON_CLOSE)){
... ...
@@ -2827,7 +2786,7 @@ int tcp_init(struct socket_info* sock_info)
2827 2827
 	if (tcp_proto_no==-1){ /* if not already set */
2828 2828
 		pe=getprotobyname("tcp");
2829 2829
 		if (pe==0){
2830
-			LOG(L_ERR, "ERROR: tcp_init: could not get TCP protocol number\n");
2830
+			LM_ERR("could not get TCP protocol number\n");
2831 2831
 			tcp_proto_no=-1;
2832 2832
 		}else{
2833 2833
 			tcp_proto_no=pe->p_proto;
... ...
@@ -2838,13 +2797,13 @@ int tcp_init(struct socket_info* sock_info)
2838 2838
 	addr=&sock_info->su;
2839 2839
 	/* sock_info->proto=PROTO_TCP; */
2840 2840
 	if (init_su(addr, &sock_info->address, sock_info->port_no)<0){
2841
-		LOG(L_ERR, "ERROR: tcp_init: could no init sockaddr_union\n");
2841
+		LM_ERR("could no init sockaddr_union\n");
2842 2842
 		goto error;
2843 2843
 	}
2844 2844
 	DBG("tcp_init: added %s\n", su2a(addr, sizeof(*addr)));
2845 2845
 	sock_info->socket=socket(AF2PF(addr->s.sa_family), SOCK_STREAM, 0);
2846 2846
 	if (sock_info->socket==-1){
2847
-		LOG(L_ERR, "ERROR: tcp_init: socket: %s\n", strerror(errno));
2847
+		LM_ERR("tcp_init: socket: %s\n", strerror(errno));
2848 2848
 		goto error;
2849 2849
 	}
2850 2850
 #ifdef DISABLE_NAGLE
... ...
@@ -2852,8 +2811,7 @@ int tcp_init(struct socket_info* sock_info)
2852 2852
 	if ( (tcp_proto_no!=-1) &&
2853 2853
 		 (setsockopt(sock_info->socket, tcp_proto_no , TCP_NODELAY,
2854 2854
 					 &flag, sizeof(flag))<0) ){
2855
-		LOG(L_ERR, "ERROR: tcp_init: could not disable Nagle: %s\n",
2856
-				strerror(errno));
2855
+		LM_ERR("could not disable Nagle: %s\n", strerror(errno));
2857 2856
 	}
2858 2857
 #endif
2859 2858
 
... ...
@@ -2871,8 +2829,7 @@ int tcp_init(struct socket_info* sock_info)
2871 2871
 	optval=1;
2872 2872
 	if (setsockopt(sock_info->socket, SOL_SOCKET, SO_REUSEADDR,
2873 2873
 				(void*)&optval, sizeof(optval))==-1) {
2874
-		LOG(L_ERR, "ERROR: tcp_init: setsockopt %s\n",
2875
-			strerror(errno));
2874
+		LM_ERR("setsockopt %s\n", strerror(errno));
2876 2875
 		goto error;
2877 2876
 	}
2878 2877
 #endif
... ...
@@ -2880,7 +2837,7 @@ int tcp_init(struct socket_info* sock_info)
2880 2880
 	optval = tos;
2881 2881
 	if (setsockopt(sock_info->socket, IPPROTO_IP, IP_TOS, (void*)&optval, 
2882 2882
 				sizeof(optval)) ==-1){
2883
-		LOG(L_WARN, "WARNING: tcp_init: setsockopt tos: %s\n", strerror(errno));
2883
+		LM_WARN("setsockopt tos: %s\n", strerror(errno));
2884 2884
 		/* continue since this is not critical */
2885 2885
 	}
2886 2886
 #ifdef HAVE_TCP_DEFER_ACCEPT
... ...
@@ -2888,8 +2845,7 @@ int tcp_init(struct socket_info* sock_info)
2888 2888
 	if ((optval=cfg_get(tcp, tcp_cfg, defer_accept))){
2889 2889
 		if (setsockopt(sock_info->socket, IPPROTO_TCP, TCP_DEFER_ACCEPT,
2890 2890
 					(void*)&optval, sizeof(optval)) ==-1){
2891
-			LOG(L_WARN, "WARNING: tcp_init: setsockopt TCP_DEFER_ACCEPT %s\n",
2892
-						strerror(errno));
2891
+			LM_WARN("setsockopt TCP_DEFER_ACCEPT %s\n", strerror(errno));
2893 2892
 		/* continue since this is not critical */
2894 2893
 		}
2895 2894
 	}
... ...
@@ -2898,8 +2854,7 @@ int tcp_init(struct socket_info* sock_info)
2898 2898
 	if ((optval=cfg_get(tcp, tcp_cfg, syncnt))){
2899 2899
 		if (setsockopt(sock_info->socket, IPPROTO_TCP, TCP_SYNCNT, &optval,
2900 2900
 						sizeof(optval))<0){
2901
-			LOG(L_WARN, "WARNING: tcp_init: failed to set"
2902
-						" maximum SYN retr. count: %s\n", strerror(errno));
2901
+			LM_WARN("failed to set maximum SYN retr. count: %s\n", strerror(errno));
2903 2902
 		}
2904 2903
 	}
2905 2904
 #endif
... ...
@@ -2907,14 +2862,13 @@ int tcp_init(struct socket_info* sock_info)
2907 2907
 	if ((optval=cfg_get(tcp, tcp_cfg, linger2))){
2908 2908
 		if (setsockopt(sock_info->socket, IPPROTO_TCP, TCP_LINGER2, &optval,
2909 2909
 						sizeof(optval))<0){
2910
-			LOG(L_WARN, "WARNING: tcp_init: failed to set"
2911
-						" maximum LINGER2 timeout: %s\n", strerror(errno));
2910
+			LM_WARN("failed to set maximum LINGER2 timeout: %s\n", strerror(errno));
2912 2911
 		}
2913 2912
 	}
2914 2913
 #endif
2915 2914
 	init_sock_keepalive(sock_info->socket);
2916 2915
 	if (bind(sock_info->socket, &addr->s, sockaddru_len(*addr))==-1){
2917
-		LOG(L_ERR, "ERROR: tcp_init: bind(%x, %p, %d) on %s:%d : %s\n",
2916
+		LM_ERR("bind(%x, %p, %d) on %s:%d : %s\n",
2918 2917
 				sock_info->socket,  &addr->s, 
2919 2918
 				(unsigned)sockaddru_len(*addr),
2920 2919
 				sock_info->address_str.s,
... ...
@@ -2923,7 +2877,7 @@ int tcp_init(struct socket_info* sock_info)
2923 2923
 		goto error;
2924 2924
 	}
2925 2925
 	if (listen(sock_info->socket, TCP_LISTEN_BACKLOG)==-1){
2926
-		LOG(L_ERR, "ERROR: tcp_init: listen(%x, %p, %d) on %s: %s\n",
2926
+		LM_ERR("listen(%x, %p, %d) on %s: %s\n",
2927 2927
 				sock_info->socket, &addr->s, 
2928 2928
 				(unsigned)sockaddru_len(*addr),
2929 2929
 				sock_info->address_str.s,
... ...
@@ -2937,7 +2891,7 @@ int tcp_init(struct socket_info* sock_info)
2937 2937
 		strcpy(afa.af_name, "dataready");
2938 2938
 		if (setsockopt(sock_info->socket, SOL_SOCKET, SO_ACCEPTFILTER,
2939 2939
 					(void*)&afa, sizeof(afa)) ==-1){
2940
-			LOG(L_WARN, "WARNING: tcp_init: setsockopt SO_ACCEPTFILTER %s\n",
2940
+			LM_WARN("setsockopt SO_ACCEPTFILTER %s\n",
2941 2941
 						strerror(errno));
2942 2942
 		/* continue since this is not critical */
2943 2943
 		}
... ...
@@ -2971,8 +2925,7 @@ inline static void tcpconn_close_main_fd(struct tcp_connection* tcpconn)
2971 2971
 	if (likely(cfg_get(tcp, tcp_cfg, fd_cache))) shutdown(fd, SHUT_RDWR);
2972 2972
 #endif /* TCP_FD_CACHE */
2973 2973
 	if (unlikely(tcp_safe_close(fd)<0))
2974
-		LOG(L_ERR, "ERROR: tcpconn_close_main_fd(%p): %s "
2975
-					"close(%d) failed (flags 0x%x): %s (%d)\n", tcpconn,
2974
+		LM_ERR("(%p): %s close(%d) failed (flags 0x%x): %s (%d)\n", tcpconn,
2976 2975
 					su2a(&tcpconn->rcv.src_su, sizeof(tcpconn->rcv.src_su)),
2977 2976
 					fd, tcpconn->flags, strerror(errno), errno);
2978 2977
 	tcpconn->s=-1;
... ...
@@ -2996,8 +2949,7 @@ inline static int tcpconn_chld_put(struct tcp_connection* tcpconn)
2996 2996
 			(tcpconn->flags &
2997 2997
 				(F_CONN_HASHED|F_CONN_MAIN_TIMER|
2998 2998
 				 F_CONN_READ_W|F_CONN_WRITE_W)) )){
2999
-			LOG(L_CRIT, "BUG: tcpconn_chld_put: %p bad flags = %0x\n",
3000
-					tcpconn, tcpconn->flags);
2999
+			LM_CRIT("%p bad flags = %0x\n", tcpconn, tcpconn->flags);
3001 3000
 			abort();
3002 3001
 		}
3003 3002
 		_tcpconn_free(tcpconn); /* destroys also the wbuf_q if still present*/
... ...
@@ -3017,8 +2969,7 @@ inline static void tcpconn_destroy(struct tcp_connection* tcpconn)
3017 3017
 				"flags %04x\n", tcpconn, tcpconn->id,
3018 3018
 				tcpconn->s, tcpconn->flags);
3019 3019
 		if (unlikely(tcpconn->flags & F_CONN_HASHED)){
3020
-			LOG(L_CRIT, "BUG: tcpconn_destroy: called with hashed"
3021
-						" connection (%p)\n", tcpconn);
3020
+			LM_CRIT("called with hashed connection (%p)\n", tcpconn);
3022 3021
 			/* try to continue */
3023 3022
 			if (likely(tcpconn->flags & F_CONN_MAIN_TIMER))
3024 3023
 				local_timer_del(&tcp_main_ltimer, &tcpconn->timer);
... ...
@@ -3056,7 +3007,7 @@ inline static int tcpconn_put_destroy(struct tcp_connection* tcpconn)
3056 3056
 			(F_CONN_WRITE_W|F_CONN_HASHED|F_CONN_MAIN_TIMER|F_CONN_READ_W)) )){
3057 3057
 		/* sanity check */
3058 3058
 		if (unlikely(tcpconn->flags & F_CONN_HASHED)){
3059
-			LOG(L_CRIT, "BUG: tcpconn_destroy: called with hashed and/or"
3059
+			LM_CRIT("called with hashed and/or"
3060 3060
 						"on timer connection (%p), flags = %0x\n",
3061 3061
 						tcpconn, tcpconn->flags);
3062 3062
 			/* try to continue */
... ...
@@ -3067,8 +3018,7 @@ inline static int tcpconn_put_destroy(struct tcp_connection* tcpconn)
3067 3067
 				tcpconn->flags &= ~(F_CONN_HASHED|F_CONN_MAIN_TIMER);
3068 3068
 			TCPCONN_UNLOCK;
3069 3069
 		}else{
3070
-			LOG(L_CRIT, "BUG: tcpconn_put_destroy: %p flags = %0x\n",
3071
-					tcpconn, tcpconn->flags);
3070
+			LM_CRIT("%p flags = %0x\n", tcpconn, tcpconn->flags);
3072 3071
 		}
3073 3072
 	}
3074 3073
 	tcpconn->state=S_CONN_BAD;
... ...
@@ -3162,7 +3112,7 @@ static int send_fd_queue_init(struct tcp_send_fd_q *q, unsigned int size)
3162 3162
 {
3163 3163
 	q->data=pkg_malloc(size*sizeof(struct send_fd_info));
3164 3164
 	if (q->data==0){
3165
-		LOG(L_ERR, "ERROR: send_fd_queue_init: out of memory\n");
3165
+		LM_ERR("out of memory\n");
3166 3166
 		return -1;
3167 3167
 	}
3168 3168
 	q->crt=&q->data[0];
... ...
@@ -3187,7 +3137,7 @@ static int init_send_fd_queues(void)
3187 3187
 		goto error;
3188 3188
 	return 0;
3189 3189
 error:
3190
-	LOG(L_ERR, "ERROR: init_send_fd_queues: init failed\n");
3190
+	LM_ERR("init failed\n");
3191 3191
 	return -1;
3192 3192
 }
3193 3193
 
... ...
@@ -3214,15 +3164,15 @@ inline static int send_fd_queue_add(	struct tcp_send_fd_q* q,
3214 3214
 			new_size*=2;
3215 3215
 		}else new_size=MAX_SEND_FD_QUEUE_SIZE;
3216 3216
 		if (unlikely(q->crt>=&q->data[new_size])){
3217
-			LOG(L_ERR, "ERROR: send_fd_queue_add: queue full: %ld/%ld\n",
3217
+			LM_ERR("queue full: %ld/%ld\n",
3218 3218
 					(long)(q->crt-&q->data[0]-1), new_size);
3219 3219
 			goto error;
3220 3220
 		}
3221
-		LOG(L_CRIT, "INFO: send_fd_queue: queue full: %ld, extending to %ld\n",
3221
+		LM_CRIT("queue full: %ld, extending to %ld\n",
3222 3222
 				(long)(q->end-&q->data[0]), new_size);
3223 3223
 		tmp=pkg_realloc(q->data, new_size*sizeof(struct send_fd_info));
3224 3224
 		if (unlikely(tmp==0)){
3225
-			LOG(L_ERR, "ERROR: send_fd_queue_add: out of memory\n");
3225
+			LM_ERR("out of memory\n");
3226 3226
 			goto error;
3227 3227
 		}
3228 3228
 		q->crt=(q->crt-&q->data[0])+tmp;
... ...
@@ -3262,8 +3212,7 @@ inline static void send_fd_queue_run(struct tcp_send_fd_q* q)
3262 3262
 				t->retries++;
3263 3263
 				t++;
3264 3264
 			}else{
3265
-				LOG(L_ERR, "ERROR: run_send_fd_queue: send_fd failed"
3266
-						   " on socket %d , queue entry %ld, retries %d,"
3265
+				LM_ERR("send_fd failed on socket %d , queue entry %ld, retries %d,"
3267 3266
 						   " connection %p, tcp socket %d, errno=%d (%s) \n",
3268 3267
 						   p->unix_sock, (long)(p-&q->data[0]), p->retries,
3269 3268
 						   p->tcp_conn, p->tcp_conn->s, errno,
... ...
@@ -3339,8 +3288,7 @@ inline static int handle_tcp_child(struct tcp_child* tcp_c, int fd_i)
3339 3339
 	
3340 3340
 	if (unlikely(tcp_c->unix_sock<=0)){
3341 3341
 		/* (we can't have a fd==0, 0 is never closed )*/
3342
-		LOG(L_CRIT, "BUG: handle_tcp_child: fd %d for %d "
3343
-				"(pid %ld, ser no %d)\n", tcp_c->unix_sock,
3342
+		LM_CRIT("fd %d for %d (pid %ld, ser no %d)\n", tcp_c->unix_sock,
3344 3343
 				(int)(tcp_c-&tcp_children[0]), (long)tcp_c->pid,
3345 3344
 				 tcp_c->proc_no);
3346 3345
 		goto error;
... ...
@@ -3361,8 +3309,7 @@ inline static int handle_tcp_child(struct tcp_child* tcp_c, int fd_i)
3361 3361
 			/* EAGAIN is ok if we try to empty the buffer
3362 3362
 			 * e.g.: SIGIO_RT overflow mode or EPOLL ET */
3363 3363
 			if ((errno!=EAGAIN) && (errno!=EWOULDBLOCK)){
3364
-				LOG(L_CRIT, "ERROR: handle_tcp_child: read from tcp child %ld "
3365
-						" (pid %ld, no %d) %s [%d]\n",
3364
+				LM_CRIT("read from tcp child %ld (pid %ld, no %d) %s [%d]\n",
3366 3365
 						(long)(tcp_c-&tcp_children[0]), (long)tcp_c->pid,
3367 3366
 						tcp_c->proc_no, strerror(errno), errno );
3368 3367
 			}else{
... ...
@@ -3372,8 +3319,7 @@ inline static int handle_tcp_child(struct tcp_child* tcp_c, int fd_i)
3372 3372
 			goto end;
3373 3373
 		}else{
3374 3374
 			/* should never happen */
3375
-			LOG(L_CRIT, "BUG: handle_tcp_child: too few bytes received (%d)\n",
3376
-					bytes );
3375
+			LM_CRIT("too few bytes received (%d)\n", bytes );
3377 3376
 			bytes=0; /* something was read so there is no error; otoh if
3378 3377
 					  receive_fd returned less then requested => the receive
3379 3378
 					  buffer is empty => no more io queued on this fd */
... ...
@@ -3387,8 +3333,7 @@ inline static int handle_tcp_child(struct tcp_child* tcp_c, int fd_i)
3387 3387
 	tcpconn=(struct tcp_connection*)response[0];
3388 3388
 	if (unlikely(tcpconn==0)){
3389 3389
 		/* should never happen */
3390
-		LOG(L_CRIT, "BUG: handle_tcp_child: null tcpconn pointer received"
3391
-				 " from tcp child %d (pid %ld): %lx, %lx\n",
3390
+		LM_CRIT("null tcpconn pointer received from tcp child %d (pid %ld): %lx, %lx\n",
3392 3391
 				 	(int)(tcp_c-&tcp_children[0]), (long)tcp_c->pid,
3393 3392
 					response[0], response[1]) ;
3394 3393
 		goto end;
... ...
@@ -3490,8 +3435,7 @@ inline static int handle_tcp_child(struct tcp_child* tcp_c, int fd_i)
3490 3490
 #endif /* TCP_ASYNC */
3491 3491
 				n=io_watch_add(&io_h, tcpconn->s, POLLIN, F_TCPCONN, tcpconn);
3492 3492
 			if (unlikely(n<0)){
3493
-				LOG(L_CRIT, "ERROR: tcp_main: handle_tcp_child: failed to add"
3494
-						" new socket to the fd list\n");
3493
+				LM_CRIT("failed to add new socket to the fd list\n");
3495 3494
 				tcpconn->flags&=~F_CONN_READ_W;
3496 3495
 				if (tcpconn_try_unhash(tcpconn)) {
3497 3496
 #ifdef TCP_ASYNC
... ...
@@ -3534,8 +3478,7 @@ inline static int handle_tcp_child(struct tcp_child* tcp_c, int fd_i)
3534 3534
 				tcpconn_put_destroy(tcpconn); /* deref & delete if refcnt==0 */
3535 3535
 				break;
3536 3536
 		default:
3537
-				LOG(L_CRIT, "BUG: handle_tcp_child:  unknown cmd %d"
3538
-									" from tcp reader %d\n",
3537
+				LM_CRIT("unknown cmd %d from tcp reader %d\n",
3539 3538
 									cmd, (int)(tcp_c-&tcp_children[0]));
3540 3539
 	}
3541 3540
 end:
... ...
@@ -3578,8 +3521,7 @@ inline static int handle_ser_child(struct process_table* p, int fd_i)
3578 3578
 	ret=-1;
3579 3579
 	if (unlikely(p->unix_sock<=0)){
3580 3580
 		/* (we can't have a fd==0, 0 is never closed )*/
3581
-		LOG(L_CRIT, "BUG: handle_ser_child: fd %d for %d "
3582
-				"(pid %d)\n", p->unix_sock, (int)(p-&pt[0]), p->pid);
3581
+		LM_CRIT("fd %d for %d (pid %d)\n", p->unix_sock, (int)(p-&pt[0]), p->pid);
3583 3582
 		goto error;
3584 3583
 	}
3585 3584
 			
... ...
@@ -3600,8 +3542,8 @@ inline static int handle_ser_child(struct process_table* p, int fd_i)
3600 3600
 			/* EAGAIN is ok if we try to empty the buffer
3601 3601
 			 * e.g: SIGIO_RT overflow mode or EPOLL ET */
3602 3602
 			if ((errno!=EAGAIN) && (errno!=EWOULDBLOCK)){
3603
-				LOG(L_CRIT, "ERROR: handle_ser_child: read from child %d  "
3604
-						"(pid %d):  %s [%d]\n", (int)(p-&pt[0]), p->pid,
3603
+				LM_CRIT("read from child %d  (pid %d):  %s [%d]\n",
3604
+						(int)(p-&pt[0]), p->pid,
3605 3605
 						strerror(errno), errno);
3606 3606
 				ret=-1;
3607 3607
 			}else{
... ...
@@ -3611,8 +3553,7 @@ inline static int handle_ser_child(struct process_table* p, int fd_i)
3611 3611
 			goto end;
3612 3612
 		}else{
3613 3613
 			/* should never happen */
3614
-			LOG(L_CRIT, "BUG: handle_ser_child: too few bytes received (%d)\n",
3615
-					bytes );
3614
+			LM_CRIT("too few bytes received (%d)\n", bytes );
3616 3615
 			ret=0; /* something was read so there is no error; otoh if
3617 3616
 					  receive_fd returned less then requested => the receive
3618 3617
 					  buffer is empty => no more io queued on this fd */
... ...
@@ -3625,15 +3566,13 @@ inline static int handle_ser_child(struct process_table* p, int fd_i)
3625 3625
 	cmd=response[1];
3626 3626
 	tcpconn=(struct tcp_connection*)response[0];
3627 3627
 	if (unlikely(tcpconn==0)){
3628
-		LOG(L_CRIT, "BUG: handle_ser_child: null tcpconn pointer received"
3629
-				 " from child %d (pid %d): %lx, %lx\n",
3628
+		LM_CRIT("null tcpconn pointer received from child %d (pid %d): %lx, %lx\n",
3630 3629
 				 	(int)(p-&pt[0]), p->pid, response[0], response[1]) ;
3631 3630
 		goto end;
3632 3631
 	}
3633 3632
 	switch(cmd){
3634 3633
 		case CONN_ERROR:
3635
-			LOG(L_ERR, "handle_ser_child: ERROR: received CON_ERROR for %p"
3636
-					" (id %d), refcnt %d, flags 0x%0x\n",
3634
+			LM_ERR("received CON_ERROR for %p (id %d), refcnt %d, flags 0x%0x\n",
3637 3635
 					tcpconn, tcpconn->id, atomic_get(&tcpconn->refcnt),
3638 3636
 					tcpconn->flags);
3639 3637
 		case CONN_EOF: /* forced EOF after full send, due to send flags */
... ...
@@ -3678,8 +3617,7 @@ inline static int handle_ser_child(struct process_table* p, int fd_i)
3678 3678
 				   be already in the process of being destroyed */
3679 3679
 			} else if (unlikely(send_fd(p->unix_sock, &tcpconn,
3680 3680
 										sizeof(tcpconn), tcpconn->s)<=0)){
3681
-				LOG(L_ERR, "handle_ser_child: CONN_GET_FD:"
3682
-							" send_fd failed\n");
3681
+				LM_ERR("CONN_GET_FD: send_fd failed\n");
3683 3682
 				/* try sending error (better then not sending anything) */
3684 3683
 				tmp = 0;
3685 3684
 				if (unlikely(send_all(p->unix_sock, &tmp, sizeof(tmp)) <= 0))
... ...
@@ -3692,8 +3630,7 @@ inline static int handle_ser_child(struct process_table* p, int fd_i)
3692 3692
 			/* WARNING: take care of setting refcnt properly to
3693 3693
 			 * avoid race conditions */
3694 3694
 			if (unlikely(fd==-1)){
3695
-				LOG(L_CRIT, "BUG: handle_ser_child: CONN_NEW:"
3696
-							" no fd received\n");
3695
+				LM_CRIT("CONN_NEW: no fd received\n");
3697 3696
 				tcpconn->flags|=F_CONN_FD_CLOSED;
3698 3697
 				tcpconn_put_destroy(tcpconn);
3699 3698
 				break;
... ...
@@ -3733,8 +3670,7 @@ inline static int handle_ser_child(struct process_table* p, int fd_i)
3733 3733
 			if (unlikely(
3734 3734
 					io_watch_add(&io_h, tcpconn->s, flags,
3735 3735
 												F_TCPCONN, tcpconn)<0)){
3736
-				LOG(L_CRIT, "ERROR: tcp_main: handle_ser_child: failed to add"
3737
-						" new socket to the fd list\n");
3736
+				LM_CRIT("failed to add new socket to the fd list\n");
3738 3737
 				tcpconn->flags&=~(F_CONN_WRITE_W|F_CONN_READ_W);
3739 3738
 				tcpconn_try_unhash(tcpconn); /*  unhash & dec refcnt */
3740 3739
 				tcpconn_put_destroy(tcpconn);
... ...
@@ -3778,9 +3714,7 @@ inline static int handle_ser_child(struct process_table* p, int fd_i)
3778 3778
 					if (!(tcpconn->flags & F_CONN_READ_W)){
3779 3779
 						if (unlikely(io_watch_add(&io_h, tcpconn->s, POLLOUT,
3780 3780
 												F_TCPCONN, tcpconn)<0)){
3781
-							LOG(L_CRIT, "ERROR: tcp_main: handle_ser_child:"
3782
-										" failed to enable write watch on"
3783
-										" socket\n");
3781
+							LM_CRIT("failed to enable write watch on socket\n");
3784 3782
 							if (tcpconn_try_unhash(tcpconn))
3785 3783
 								tcpconn_put_destroy(tcpconn);
3786 3784
 							break;
... ...
@@ -3788,8 +3722,7 @@ inline static int handle_ser_child(struct process_table* p, int fd_i)
3788 3788
 					}else{
3789 3789
 						if (unlikely(io_watch_chg(&io_h, tcpconn->s,
3790 3790
 													POLLIN|POLLOUT, -1)<0)){
3791
-							LOG(L_CRIT, "ERROR: tcp_main: handle_ser_child:"
3792
-									" failed to change socket watch events\n");
3791
+							LM_CRIT("failed to change socket watch events\n");
3793 3792
 							if (tcpconn_try_unhash(tcpconn)) {
3794 3793
 								io_watch_del(&io_h, tcpconn->s, -1,
3795 3794
 												IO_FD_CLOSING);
... ...
@@ -3805,8 +3738,7 @@ inline static int handle_ser_child(struct process_table* p, int fd_i)
3805 3805
 					}
3806 3806
 				}
3807 3807
 			}else{
3808
-				LOG(L_WARN, "tcp_main: handler_ser_child: connection %p"
3809
-							" already watched for write\n", tcpconn);
3808
+				LM_WARN("connection %p already watched for write\n", tcpconn);
3810 3809
 			}
3811 3810
 			break;
3812 3811
 #ifdef TCP_CONNECT_WAIT
... ...
@@ -3820,11 +3752,9 @@ inline static int handle_ser_child(struct process_table* p, int fd_i)
3820 3820
 			tcpconn->flags&=~(F_CONN_PENDING|F_CONN_FD_CLOSED);
3821 3821
 			if (unlikely((tcpconn->state==S_CONN_BAD) || (fd==-1))){
3822 3822
 				if (unlikely(fd==-1))
3823
-					LOG(L_CRIT, "BUG: handle_ser_child: CONN_NEW_COMPLETE:"
3824
-								" no fd received\n");
3823
+					LM_CRIT("CONN_NEW_COMPLETE: no fd received\n");
3825 3824
 				else
3826
-					LOG(L_WARN, "WARNING: handle_ser_child: CONN_NEW_COMPLETE:"
3827
-							" received connection with error\n");
3825
+					LM_WARN("CONN_NEW_COMPLETE: received connection with error\n");
3828 3826
 				tcpconn->flags|=F_CONN_FD_CLOSED;
3829 3827
 				tcpconn->state=S_CONN_BAD;
3830 3828
 				tcpconn_try_unhash(tcpconn);
... ...
@@ -3877,8 +3807,7 @@ inline static int handle_ser_child(struct process_table* p, int fd_i)
3877 3877
 			if (unlikely(
3878 3878
 					io_watch_add(&io_h, tcpconn->s, flags,
3879 3879
 												F_TCPCONN, tcpconn)<0)){
3880
-				LOG(L_CRIT, "ERROR: tcp_main: handle_ser_child: failed to add"
3881
-						" new socket to the fd list\n");
3880
+				LM_CRIT("failed to add new socket to the fd list\n");
3882 3881
 				tcpconn->flags&=~(F_CONN_WRITE_W|F_CONN_READ_W);
3883 3882
 				tcpconn_try_unhash(tcpconn); /*  unhash & dec refcnt */
3884 3883
 				tcpconn_put_destroy(tcpconn);
... ...
@@ -3887,7 +3816,7 @@ inline static int handle_ser_child(struct process_table* p, int fd_i)
3887 3887
 #endif /* TCP_CONNECT_WAIT */
3888 3888
 #endif /* TCP_ASYNC */
3889 3889
 		default:
3890
-			LOG(L_CRIT, "BUG: handle_ser_child: unknown cmd %d\n", cmd);
3890
+			LM_CRIT("unknown cmd %d\n", cmd);
3891 3891
 	}
3892 3892
 end:
3893 3893
 	return ret;
... ...
@@ -3996,26 +3925,25 @@ inline static int send2child(struct tcp_connection* tcpconn)
3996 3996
 							sizeof(tcpconn), tcpconn->s)<=0)){
3997 3997
 		if ((errno==EAGAIN)||(errno==EWOULDBLOCK)){
3998 3998
 			/* FIXME: remove after debugging */
3999
-			 LOG(L_CRIT, "INFO: tcp child %d, socket %d: queue full,"
4000
-					 	" %d requests queued (total handled %d)\n",
3999
+			 LM_CRIT("tcp child %d, socket %d: queue full, %d requests queued (total handled %d)\n",
4001 4000
 					idx, tcp_children[idx].unix_sock, min_busy,
4002 4001
 					tcp_children[idx].n_reqs-1);
4003 4002
 			if (send_fd_queue_add(&send2child_q, tcp_children[idx].unix_sock, 
4004 4003
 						tcpconn)!=0){
4005
-				LOG(L_ERR, "ERROR: send2child: queue send op. failed\n");
4004
+				LM_ERR("queue send op. failed\n");
4006 4005
 				return -1;
4007 4006
 			}
4008 4007
 		}else{
4009
-			LOG(L_ERR, "ERROR: send2child: send_fd failed for %p (flags 0x%0x)"
4010
-						", fd %d\n", tcpconn, tcpconn->flags, tcpconn->s);
4008
+			LM_ERR("send_fd failed for %p (flags 0x%0x), fd %d\n",
4009
+						tcpconn, tcpconn->flags, tcpconn->s);
4011 4010
 			return -1;
4012 4011
 		}
4013 4012
 	}
4014 4013
 #else
4015 4014
 	if (unlikely(send_fd(tcp_children[idx].unix_sock, &tcpconn,
4016 4015
 						sizeof(tcpconn), tcpconn->s)<=0)){
4017
-		LOG(L_ERR, "ERROR: send2child: send_fd failed for %p (flags 0x%0x)"
4018
-					", fd %d\n", tcpconn, tcpconn->flags, tcpconn->s);
4016
+		LM_ERR("send_fd failed for %p (flags 0x%0x), fd %d\n",
4017
+					tcpconn, tcpconn->flags, tcpconn->s);
4019 4018
 		return -1;
4020 4019
 	}
4021 4020
 #endif
... ...
@@ -4048,12 +3976,11 @@ static inline int handle_new_connect(struct socket_info* si)
4048 4048
 	if (unlikely(new_sock==-1)){
4049 4049
 		if ((errno==EAGAIN)||(errno==EWOULDBLOCK))
4050 4050
 			return 0;
4051
-		LOG(L_ERR,  "WARNING: handle_new_connect: error while accepting"
4052
-				" connection(%d): %s\n", errno, strerror(errno));
4051
+		LM_ERR("error while accepting connection(%d): %s\n", errno, strerror(errno));
4053 4052
 		return -1;
4054 4053
 	}
4055 4054
 	if (unlikely(*tcp_connections_no>=cfg_get(tcp, tcp_cfg, max_connections))){
4056
-		LOG(L_ERR, "ERROR: maximum number of connections exceeded: %d/%d\n",
4055
+		LM_ERR("maximum number of connections exceeded: %d/%d\n",
4057 4056
 					*tcp_connections_no,
4058 4057
 					cfg_get(tcp, tcp_cfg, max_connections));
4059 4058
 		tcp_safe_close(new_sock);
... ...
@@ -4071,7 +3998,7 @@ static inline int handle_new_connect(struct socket_info* si)
4071 4071
 		}
4072 4072
 	}
4073 4073
 	if (unlikely(init_sock_opt_accept(new_sock)<0)){
4074
-		LOG(L_ERR, "ERROR: handle_new_connect: init_sock_opt failed\n");
4074
+		LM_ERR("init_sock_opt failed\n");
4075 4075
 		tcp_safe_close(new_sock);
4076 4076
 		return 1; /* success, because the accept was succesfull */
4077 4077
 	}
... ...
@@ -4093,8 +4020,7 @@ static inline int handle_new_connect(struct socket_info* si)
4093 4093
 		/* INADDR_ANY => get local dst */
4094 4094
 		sock_name_len=sizeof(sock_name);
4095 4095
 		if (getsockname(new_sock, &sock_name.s, &sock_name_len)!=0){
4096
-			LOG(L_ERR, "ERROR: handle_new_connect:"
4097
-						" getsockname failed: %s(%d)\n",
4096
+			LM_ERR("getsockname failed: %s(%d)\n",
4098 4097
 						strerror(errno), errno);
4099 4098
 			/* go on with the 0.0.0.0 dst from the sock_info */
4100 4099
 		}else{
... ...
@@ -4116,8 +4042,7 @@ static inline int handle_new_connect(struct socket_info* si)
4116 4116
 		tcpconn->flags|=(F_CONN_MAIN_TIMER|F_CONN_READ_W|F_CONN_WANTS_RD);
4117 4117
 		if (unlikely(io_watch_add(&io_h, tcpconn->s, POLLIN, 
4118 4118
 													F_TCPCONN, tcpconn)<0)){
4119
-			LOG(L_CRIT, "ERROR: tcp_main: handle_new_connect: failed to add"
4120
-						" new socket to the fd list\n");
4119
+			LM_CRIT("failed to add new socket to the fd list\n");
4121 4120
 			tcpconn->flags&=~F_CONN_READ_W;
4122 4121
 			if (tcpconn_try_unhash(tcpconn))
4123 4122
 				tcpconn_put_destroy(tcpconn);
... ...
@@ -4138,8 +4063,7 @@ static inline int handle_new_connect(struct socket_info* si)
4138 4138
 		}
4139 4139
 #endif
4140 4140
 	}else{ /*tcpconn==0 */
4141
-		LOG(L_ERR, "ERROR: handle_new_connect: tcpconn_new failed, "
4142
-				"closing socket\n");
4141
+		LM_ERR("tcpconn_new failed, closing socket\n");
4143 4142
 		tcp_safe_close(new_sock);
4144 4143
 		(*tcp_connections_no)--;
4145 4144
 		if (unlikely(si->proto==PROTO_TLS))
... ...
@@ -4178,7 +4102,7 @@ inline static int handle_tcpconn_ev(struct tcp_connection* tcpconn, short ev,
4178 4178
 		/* FIXME: might be valid for sigio_rt iff fd flags are not cleared
4179 4179
 		 *        (there is a short window in which it could generate a sig
4180 4180
 		 *         that would be catched by tcp_main) */
4181
-		LOG(L_CRIT, "BUG: handle_tcpconn_ev: io event on referenced"
4181
+		LM_CRIT("handle_tcpconn_ev: io event on referenced"
4182 4182
 					" tcpconn (%p), refcnt=%d, fd=%d\n",
4183 4183
 					tcpconn, tcpconn->refcnt, tcpconn->s);
4184 4184
 		return -1;
... ...
@@ -4207,8 +4131,7 @@ inline static int handle_tcpconn_ev(struct tcp_connection* tcpconn, short ev,
4207 4207
 				 * least 2 * syscalls in the reader + ...) */
4208 4208
 				if ((ioctl(tcpconn->s, FIONREAD, &bytes)>=0) && (bytes>0)){
4209 4209
 					if (unlikely(io_watch_del(&io_h, tcpconn->s, fd_i, 0)<0)){
4210
-						LOG(L_ERR, "ERROR: handle_tcpconn_ev: io_watch_del(1)"
4211
-								" failed: for %p, fd %d\n",
4210
+						LM_ERR("io_watch_del(1) failed: for %p, fd %d\n",
4212 4211
 								tcpconn, tcpconn->s);
4213 4212
 					}
4214 4213
 					tcpconn->flags&=~(F_CONN_WRITE_W|F_CONN_READ_W|
... ...
@@ -4220,8 +4143,7 @@ inline static int handle_tcpconn_ev(struct tcp_connection* tcpconn, short ev,
4220 4220
 			}
4221 4221
 			if (unlikely(io_watch_del(&io_h, tcpconn->s, fd_i,
4222 4222
 											IO_FD_CLOSING) < 0)){
4223
-				LOG(L_ERR, "ERROR: handle_tcpconn_ev: io_watch_del() failed:"
4224
-							" for %p, fd %d\n", tcpconn, tcpconn->s);
4223
+				LM_ERR("io_watch_del() failed: for %p, fd %d\n", tcpconn, tcpconn->s);
4225 4224
 			}
4226 4225
 			tcpconn->flags&=~(F_CONN_WRITE_W|F_CONN_READ_W|
4227 4226
 								F_CONN_WANTS_RD|F_CONN_WANTS_WR);
... ...
@@ -4246,8 +4168,7 @@ inline static int handle_tcpconn_ev(struct tcp_connection* tcpconn, short ev,
4246 4246
 				}
4247 4247
 			}
4248 4248
 			if (unlikely(!tcpconn_try_unhash(tcpconn))){
4249
-				LOG(L_CRIT, "BUG: tcpconn_ev: unhashed connection %p\n",
4250
-							tcpconn);
4249
+				LM_CRIT("unhashed connection %p\n", tcpconn);
4251 4250
 			}
4252 4251
 			tcpconn_put_destroy(tcpconn);
4253 4252
 			goto error;
... ...
@@ -4256,16 +4177,14 @@ inline static int handle_tcpconn_ev(struct tcp_connection* tcpconn, short ev,
4256 4256
 			tcpconn->flags&=~F_CONN_WANTS_WR;
4257 4257
 			if (!(tcpconn->flags & F_CONN_READ_W)){
4258 4258
 				if (unlikely(io_watch_del(&io_h, tcpconn->s, fd_i, 0)==-1)){
4259
-					LOG(L_ERR, "ERROR: handle_tcpconn_ev: io_watch_del(2)"
4260
-								" failed:" " for %p, fd %d\n",
4259
+					LM_ERR("io_watch_del(2) failed: for %p, fd %d\n",
4261 4260
 								tcpconn, tcpconn->s);
4262 4261
 					goto error;
4263 4262
 				}
4264 4263
 			}else{
4265 4264
 				if (unlikely(io_watch_chg(&io_h, tcpconn->s,
4266 4265
 											POLLIN, fd_i)==-1)){
4267
-					LOG(L_ERR, "ERROR: handle_tcpconn_ev: io_watch_chg(1)"
4268
-								" failed:" " for %p, fd %d\n",
4266
+					LM_ERR("io_watch_chg(1) failed: for %p, fd %d\n",
4269 4267
 								tcpconn, tcpconn->s);
4270 4268
 					goto error;
4271 4269
 				}
... ...
@@ -4281,8 +4200,7 @@ inline static int handle_tcpconn_ev(struct tcp_connection* tcpconn, short ev,
4281 4281
 		 *  writes if needed): */
4282 4282
 		if (unlikely(tcpconn->flags & F_CONN_WRITE_W)){
4283 4283
 			if (unlikely(io_watch_chg(&io_h, tcpconn->s, POLLOUT, fd_i)==-1)){
4284
-				LOG(L_ERR, "ERROR: handle_tcpconn_ev: io_watch_chg(2)"
4285
-							" failed:" " for %p, fd %d\n",
4284
+				LM_ERR("io_watch_chg(2) failed: for %p, fd %d\n",
4286 4285
 							tcpconn, tcpconn->s);
4287 4286
 				goto error;
4288 4287
 			}
... ...
@@ -4291,8 +4209,7 @@ inline static int handle_tcpconn_ev(struct tcp_connection* tcpconn, short ev,
4291 4291
 	{
4292 4292
 #endif /* TCP_ASYNC */
4293 4293
 			if (unlikely(io_watch_del(&io_h, tcpconn->s, fd_i, 0)==-1)){
4294
-				LOG(L_ERR, "ERROR: handle_tcpconn_ev: io_watch_del(3)"
4295
-							" failed:" " for %p, fd %d\n",
4294
+				LM_ERR("io_watch_del(3) failed: for %p, fd %d\n",
4296 4295
 							tcpconn, tcpconn->s);
4297 4296
 				goto error;
4298 4297
 			}
... ...
@@ -4317,8 +4234,7 @@ send_to_child:
4317 4317
 			if (tcpconn->flags & F_CONN_WRITE_W){
4318 4318
 				if (unlikely(io_watch_del(&io_h, tcpconn->s, fd_i,
4319 4319
 														IO_FD_CLOSING) < 0)){
4320
-					LOG(L_ERR, "ERROR: handle_tcpconn_ev: io_watch_del(4)"
4321
-							" failed:" " for %p, fd %d\n",
4320
+					LM_ERR("io_watch_del(4) failed:" " for %p, fd %d\n",
4322 4321
 							tcpconn, tcpconn->s);
4323 4322
 				}
4324 4323
 				tcpconn->flags&=~F_CONN_WRITE_W;
... ...
@@ -4372,11 +4288,11 @@ inline static int handle_io(struct fd_map* fm, short ev, int idx)
4372 4372
 			ret=handle_ser_child((struct process_table*)fm->data, idx);
4373 4373
 			break;
4374 4374
 		case F_NONE:
4375
-			LOG(L_CRIT, "BUG: handle_io: empty fd map: %p {%d, %d, %p},"
4376
-						" idx %d\n", fm, fm->fd, fm->type, fm->data, idx);
4375
+			LM_CRIT("empty fd map: %p {%d, %d, %p}, idx %d\n",
4376
+						fm, fm->fd, fm->type, fm->data, idx);
4377 4377
 			goto error;
4378 4378
 		default:
4379
-			LOG(L_CRIT, "BUG: handle_io: unknown fd type %d\n", fm->type); 
4379
+			LM_CRIT("unknown fd type %d\n", fm->type); 
4380 4380
 			goto error;
4381 4381
 	}
4382 4382
 	return ret;
... ...
@@ -4452,8 +4368,7 @@ static ticks_t tcpconn_main_timeout(ticks_t t, struct timer_ln* tl, void* data)
4452 4452
 		TCPCONN_UNLOCK;
4453 4453
 	}else{
4454 4454
 		c->flags&=~F_CONN_MAIN_TIMER;
4455
-		LOG(L_CRIT, "BUG: tcp_main: timer: called with unhashed connection %p"
4456
-				"\n", c);
4455
+		LM_CRIT("timer: called with unhashed connection %p\n", c);
4457 4456
 		tcpconn_ref(c); /* ugly hack to try to go on */
4458 4457
 	}
4459 4458
 	fd=c->s;
... ...
@@ -4552,7 +4467,7 @@ void tcp_main_loop()
4552 4552
 	 *  process */
4553 4553
 #ifdef SEND_FD_QUEUE
4554 4554
 	if (init_send_fd_queues()<0){
4555
-		LOG(L_CRIT, "ERROR: init_tcp: could not init send fd queues\n");
4555
+		LM_CRIT("could not init send fd queues\n");
4556 4556
 		goto error;
4557 4557
 	}
4558 4558
 #endif
... ...
@@ -4565,7 +4480,7 @@ void tcp_main_loop()
4565 4565
 	/* init local timer */
4566 4566
 	tcp_main_prev_ticks=get_ticks_raw();
4567 4567
 	if (init_local_timer(&tcp_main_ltimer, get_ticks_raw())!=0){
4568
-		LOG(L_ERR, "ERROR: init_tcp: failed to init local timer\n");
4568
+		LM_ERR("failed to init local timer\n");
4569 4569
 		goto error;
4570 4570
 	}
4571 4571
 #ifdef TCP_FD_CACHE
... ...
@@ -4576,12 +4491,11 @@ void tcp_main_loop()
4576 4576
 	for (si=tcp_listen; si; si=si->next){
4577 4577
 		if ((si->proto==PROTO_TCP) &&(si->socket!=-1)){
4578 4578
 			if (io_watch_add(&io_h, si->socket, POLLIN, F_SOCKINFO, si)<0){
4579
-				LOG(L_CRIT, "ERROR: tcp_main_loop: init: failed to add "
4580
-							"listen socket to the fd list\n");
4579
+				LM_CRIT("failed to add listen socket to the fd list\n");
4581 4580
 				goto error;
4582 4581
 			}
4583 4582
 		}else{
4584
-			LOG(L_CRIT, "BUG: tcp_main_loop: non tcp address in tcp_listen\n");
4583
+			LM_CRIT("non tcp address in tcp_listen\n");
4585 4584
 		}
4586 4585
 	}
4587 4586
 #ifdef USE_TLS
... ...
@@ -4589,13 +4503,11 @@ void tcp_main_loop()
4589 4589
 		for (si=tls_listen; si; si=si->next){
4590 4590
 			if ((si->proto==PROTO_TLS) && (si->socket!=-1)){
4591 4591
 				if (io_watch_add(&io_h, si->socket, POLLIN, F_SOCKINFO, si)<0){
4592
-					LOG(L_CRIT, "ERROR: tcp_main_loop: init: failed to add "
4593
-							"tls listen socket to the fd list\n");
4592
+					LM_CRIT("failed to add tls listen socket to the fd list\n");
4594 4593
 					goto error;
4595 4594
 				}
4596 4595
 			}else{
4597
-				LOG(L_CRIT, "BUG: tcp_main_loop: non tls address"
4598
-						" in tls_listen\n");
4596
+				LM_CRIT("non tls address in tls_listen\n");
4599 4597
 			}
4600 4598
 		}
4601 4599
 	}
... ...
@@ -4605,8 +4517,7 @@ void tcp_main_loop()
4605 4605
 	for (r=1; r<process_no; r++){
4606 4606
 		if (pt[r].unix_sock>0) /* we can't have 0, we never close it!*/
4607 4607
 			if (io_watch_add(&io_h, pt[r].unix_sock, POLLIN,F_PROC, &pt[r])<0){
4608
-					LOG(L_CRIT, "ERROR: tcp_main_loop: init: failed to add "
4609
-							"process %d unix socket to the fd list\n", r);
4608
+					LM_CRIT("failed to add process %d unix socket to the fd list\n", r);
4610 4609
 					goto error;
4611 4610
 			}
4612 4611
 	}
... ...
@@ -4615,8 +4526,7 @@ void tcp_main_loop()
4615 4615
 		if (tcp_children[r].unix_sock>0)/*we can't have 0, we never close it!*/
4616 4616
 			if (io_watch_add(&io_h, tcp_children[r].unix_sock, POLLIN,
4617 4617
 									F_TCPCHILD, &tcp_children[r]) <0){
4618
-				LOG(L_CRIT, "ERROR: tcp_main_loop: init: failed to add "
4619
-						"tcp child %d unix socket to the fd list\n", r);
4618
+				LM_CRIT("failed to add tcp child %d unix socket to the fd list\n", r);
4620 4619
 				goto error;
4621 4620
 			}
4622 4621
 	}
... ...
@@ -4689,8 +4599,7 @@ void tcp_main_loop()
4689 4689
 			break;
4690 4690
 #endif
4691 4691
 		default:
4692
-			LOG(L_CRIT, "BUG: tcp_main_loop: no support for poll method "
4693
-					" %s (%d)\n", 
4692
+			LM_CRIT("no support for poll method %s (%d)\n", 
4694 4693
 					poll_method_name(io_h.poll_method), io_h.poll_method);
4695 4694
 			goto error;
4696 4695
 	}
... ...
@@ -4699,7 +4608,7 @@ error:
4699 4699
 	destroy_send_fd_queues();
4700 4700
 #endif
4701 4701
 	destroy_io_wait(&io_h);
4702
-	LOG(L_CRIT, "ERROR: tcp_main_loop: exiting...");
4702
+	LM_CRIT("exiting...");
4703 4703
 	exit(-1);
4704 4704
 }
4705 4705
 
... ...
@@ -4767,11 +4676,11 @@ int init_tcp()
4767 4767
 	/* init lock */
4768 4768
 	tcpconn_lock=lock_alloc();
4769 4769
 	if (tcpconn_lock==0){
4770
-		LOG(L_CRIT, "ERROR: init_tcp: could not alloc lock\n");
4770
+		LM_CRIT("could not alloc lock\n");
4771 4771
 		goto error;
4772 4772
 	}
4773 4773
 	if (lock_init(tcpconn_lock)==0){
4774
-		LOG(L_CRIT, "ERROR: init_tcp: could not init lock\n");
4774
+		LM_CRIT("could not init lock\n");
4775 4775
 		lock_dealloc((void*)tcpconn_lock);
4776 4776
 		tcpconn_lock=0;
4777 4777
 		goto error;
... ...
@@ -4779,27 +4688,27 @@ int init_tcp()
4779 4779
 	/* init globals */
4780 4780
 	tcp_connections_no=shm_malloc(sizeof(int));
4781 4781
 	if (tcp_connections_no==0){
4782
-		LOG(L_CRIT, "ERROR: init_tcp: could not alloc globals\n");
4782
+		LM_CRIT("could not alloc globals\n");
4783 4783
 		goto error;
4784 4784
 	}
4785 4785
 	*tcp_connections_no=0;
4786 4786
 	tls_connections_no=shm_malloc(sizeof(int));
4787 4787
 	if (tls_connections_no==0){
4788
-		LOG(L_CRIT, "ERROR: init_tcp: could not alloc globals\n");
4788
+		LM_CRIT("could not alloc globals\n");
4789 4789
 		goto error;
4790 4790
 	}
4791 4791
 	*tls_connections_no=0;
4792 4792
 	if (INIT_TCP_STATS()!=0) goto error;
4793 4793
 	connection_id=shm_malloc(sizeof(int));
4794 4794
 	if (connection_id==0){
4795
-		LOG(L_CRIT, "ERROR: init_tcp: could not alloc globals\n");
4795
+		LM_CRIT("could not alloc globals\n");
4796 4796
 		goto error;
4797 4797
 	}
4798 4798
 	*connection_id=1;
4799 4799
 #ifdef TCP_ASYNC
4800 4800
 	tcp_total_wq=shm_malloc(sizeof(*tcp_total_wq));
4801 4801
 	if (tcp_total_wq==0){
4802
-		LOG(L_CRIT, "ERROR: init_tcp: could not alloc globals\n");
4802
+		LM_CRIT("could not alloc globals\n");
4803 4803
 		goto error;
4804 4804
 	}
4805 4805
 #endif /* TCP_ASYNC */
... ...
@@ -4807,13 +4716,13 @@ int init_tcp()
4807 4807
 	tcpconn_aliases_hash=(struct tcp_conn_alias**)
4808 4808
 			shm_malloc(TCP_ALIAS_HASH_SIZE* sizeof(struct tcp_conn_alias*));
4809 4809
 	if (tcpconn_aliases_hash==0){
4810
-		LOG(L_CRIT, "ERROR: init_tcp: could not alloc address hashtable\n");
4810
+		LM_CRIT("could not alloc address hashtable\n");
4811 4811
 		goto error;
4812 4812
 	}
4813 4813
 	tcpconn_id_hash=(struct tcp_connection**)shm_malloc(TCP_ID_HASH_SIZE*
4814 4814
 								sizeof(struct tcp_connection*));
4815 4815
 	if (tcpconn_id_hash==0){
4816
-		LOG(L_CRIT, "ERROR: init_tcp: could not alloc id hashtable\n");
4816
+		LM_CRIT("could not alloc id hashtable\n");
4817 4817
 		goto error;
4818 4818
 	}
4819 4819
 	/* init hashtables*/
... ...
@@ -4829,14 +4738,14 @@ int init_tcp()
4829 4829
 	if (poll_err || (tcp_poll_method==0)){
4830 4830
 		tcp_poll_method=choose_poll_method();
4831 4831
 		if (poll_err){
4832
-			LOG(L_ERR, "ERROR: init_tcp: %s, using %s instead\n",
4832
+			LM_ERR("%s, using %s instead\n",
4833 4833
 					poll_err, poll_method_name(tcp_poll_method));
4834 4834
 		}else{
4835
-			LOG(L_INFO, "init_tcp: using %s as the io watch method"
4836
-					" (auto detected)\n", poll_method_name(tcp_poll_method));
4835
+			LM_INFO("using %s as the io watch method (auto detected)\n",
4836
+					poll_method_name(tcp_poll_method));
4837 4837
 		}
4838 4838
 	}else{
4839
-			LOG(L_INFO, "init_tcp: using %s io watch method (config)\n",
4839
+			LM_INFO("using %s io watch method (config)\n",
4840 4840
 					poll_method_name(tcp_poll_method));
4841 4841
 	}
4842 4842
 	
... ...
@@ -4856,13 +4765,11 @@ static int set_non_blocking(int s)
4856 4856
 	/* non-blocking */
4857 4857
 	flags=fcntl(s, F_GETFL);
4858 4858
 	if (flags==-1){
4859
-		LOG(L_ERR, "ERROR: set_non_blocking: fnctl failed: (%d) %s\n",
4860
-				errno, strerror(errno));
4859
+		LM_ERR("fnctl failed: (%d) %s\n", errno, strerror(errno));
4861 4860
 		goto error;
4862 4861
 	}
4863 4862
 	if (fcntl(s, F_SETFL, flags|O_NONBLOCK)==-1){
4864
-		LOG(L_ERR, "ERROR: set_non_blocking: fcntl: set non-blocking failed:"
4865
-				" (%d) %s\n", errno, strerror(errno));
4863
+		LM_ERR("fcntl: set non-blocking failed: (%d) %s\n", errno, strerror(errno));
4866 4864
 		goto error;
4867 4865
 	}
4868 4866
 	return 0;
... ...
@@ -4917,7 +4824,7 @@ int tcp_init_children()
4917 4917
 	/* alloc the children array */
4918 4918
 	tcp_children=pkg_malloc(sizeof(struct tcp_child)*tcp_children_no);
4919 4919
 	if (tcp_children==0){
4920
-			LOG(L_ERR, "ERROR: tcp_init_children: out of memory\n");
4920
+			LM_ERR("out of memory\n");
4921 4921
 			goto error;
4922 4922
 	}
4923 4923
 	memset(tcp_children, 0, sizeof(struct tcp_child)*tcp_children_no);
... ...
@@ -4958,8 +4865,7 @@ int tcp_init_children()
4958 4958
 					tcp_children[r].mysocket->sock_str.s:"generic");
4959 4959
 		pid=fork_tcp_process(child_rank, si_desc, r, &reader_fd_1);
4960 4960
 		if (pid<0){
4961