Browse code

main.c: logging: convert LOG to LM_*

Ovidiu Sas authored on 03/10/2014 21:39:30
Showing 1 changed files
... ...
@@ -660,7 +660,7 @@ static void kill_all_children(int signum)
660 660
 			if (pt[r].pid) {
661 661
 				kill(pt[r].pid, signum);
662 662
 			}
663
-			else LOG(L_CRIT, "BUG: killing: %s > %d no pid!!!\n",
663
+			else LM_CRIT("killing: %s > %d no pid!!!\n",
664 664
 							pt[r].desc, pt[r].pid);
665 665
 		}
666 666
 		if (!is_main) lock_release(process_lock);
... ...
@@ -686,7 +686,7 @@ static void sig_alarm_kill(int signo)
686 686
 static void sig_alarm_abort(int signo)
687 687
 {
688 688
 	/* LOG is not signal safe, but who cares, we are abort-ing anyway :-) */
689
-	LOG(L_CRIT, "BUG: shutdown timeout triggered, dying...");
689
+	LM_CRIT("shutdown timeout triggered, dying...");
690 690
 	abort();
691 691
 }
692 692
 
... ...
@@ -696,7 +696,7 @@ static void shutdown_children(int sig, int show_status)
696 696
 {
697 697
 	kill_all_children(sig);
698 698
 	if (set_sig_h(SIGALRM, sig_alarm_kill) == SIG_ERR ) {
699
-		LOG(L_ERR, "ERROR: shutdown: could not install SIGALARM handler\n");
699
+		LM_ERR("could not install SIGALARM handler\n");
700 700
 		/* continue, the process will die anyway if no
701 701
 		 * alarm is installed which is exactly what we want */
702 702
 	}
... ...
@@ -723,7 +723,7 @@ void handle_sigs(void)
723 723
 				/* SIGPIPE might be rarely received on use of
724 724
 				   exec module; simply ignore it
725 725
 				 */
726
-				LOG(L_WARN, "WARNING: SIGPIPE received and ignored\n");
726
+				LM_WARN("SIGPIPE received and ignored\n");
727 727
 				break;
728 728
 		case SIGINT:
729 729
 		case SIGTERM:
... ...
@@ -732,7 +732,7 @@ void handle_sigs(void)
732 732
 				DBG("INT received, program terminates\n");
733 733
 			else
734 734
 				DBG("SIGTERM received, program terminates\n");
735
-			LOG(L_NOTICE, "Thank you for flying " NAME "!!!\n");
735
+			LM_NOTICE("Thank you for flying " NAME "!!!\n");
736 736
 			/* shutdown/kill all the children */
737 737
 			shutdown_children(SIGTERM, 1);
738 738
 			exit(0);
... ...
@@ -772,27 +772,27 @@ void handle_sigs(void)
772 772
 		case SIGCHLD:
773 773
 			while ((chld=waitpid( -1, &chld_status, WNOHANG ))>0) {
774 774
 				if (WIFEXITED(chld_status))
775
-					LOG(L_ALERT, "child process %ld exited normally,"
775
+					LM_ALERT("child process %ld exited normally,"
776 776
 							" status=%d\n", (long)chld,
777 777
 							WEXITSTATUS(chld_status));
778 778
 				else if (WIFSIGNALED(chld_status)) {
779
-					LOG(L_ALERT, "child process %ld exited by a signal"
779
+					LM_ALERT("child process %ld exited by a signal"
780 780
 							" %d\n", (long)chld, WTERMSIG(chld_status));
781 781
 #ifdef WCOREDUMP
782
-					LOG(L_ALERT, "core was %sgenerated\n",
782
+					LM_ALERT("core was %sgenerated\n",
783 783
 							 WCOREDUMP(chld_status) ?  "" : "not " );
784 784
 #endif
785 785
 				}else if (WIFSTOPPED(chld_status))
786
-					LOG(L_ALERT, "child process %ld stopped by a"
786
+					LM_ALERT("child process %ld stopped by a"
787 787
 								" signal %d\n", (long)chld,
788 788
 								 WSTOPSIG(chld_status));
789 789
 			}
790 790
 #ifndef STOP_JIRIS_CHANGES
791 791
 			if (dont_fork) {
792
-				LOG(L_INFO, "INFO: dont_fork turned on, living on\n");
792
+				LM_INFO("dont_fork turned on, living on\n");
793 793
 				break;
794 794
 			}
795
-			LOG(L_INFO, "INFO: terminating due to SIGCHLD\n");
795
+			LM_INFO("terminating due to SIGCHLD\n");
796 796
 #endif
797 797
 			/* exit */
798 798
 			shutdown_children(SIGTERM, 1);
... ...
@@ -804,7 +804,7 @@ void handle_sigs(void)
804 804
 					DBG("SIGHUP received, ignoring it\n");
805 805
 					break;
806 806
 		default:
807
-			LOG(L_CRIT, "WARNING: unhandled signal %d\n", sig_flag);
807
+			LM_CRIT("unhandled signal %d\n", sig_flag);
808 808
 	}
809 809
 	sig_flag=0;
810 810
 }
... ...
@@ -837,13 +837,13 @@ void sig_usr(int signo)
837 837
 		switch(signo){
838 838
 			case SIGPIPE:
839 839
 #ifdef SIG_DEBUG /* signal unsafe stuff follows */
840
-					LOG(L_INFO, "INFO: signal %d received\n", signo);
840
+					LM_INFO("signal %d received\n", signo);
841 841
 #endif
842 842
 				break;
843 843
 			case SIGINT:
844 844
 			case SIGTERM:
845 845
 #ifdef SIG_DEBUG /* signal unsafe stuff follows */
846
-					LOG(L_INFO, "INFO: signal %d received\n", signo);
846
+					LM_INFO("signal %d received\n", signo);
847 847
 					/* print memory stats for non-main too */
848 848
 					#ifdef PKG_MALLOC
849 849
 					/* make sure we have current cfg values, but update only
... ...
@@ -1170,16 +1170,16 @@ int parse_phostport(char* s, char** host, int* hlen,
1170 1170
 end:
1171 1171
 	return 0;
1172 1172
 error_brackets:
1173
-	LOG(L_ERR, "ERROR: parse_phostport: too many brackets in %s\n", s);
1173
+	LM_ERR("too many brackets in %s\n", s);
1174 1174
 	return -1;
1175 1175
 error_colons:
1176
-	LOG(L_ERR, "ERROR: parse_phostport: too many colons in %s\n", s);
1176
+	LM_ERR("too many colons in %s\n", s);
1177 1177
 	return -1;
1178 1178
 error_proto:
1179
-	LOG(L_ERR, "ERROR: parse_phostport: bad protocol in %s\n", s);
1179
+	LM_ERR("bad protocol in %s\n", s);
1180 1180
 	return -1;
1181 1181
 error_port:
1182
-	LOG(L_ERR, "ERROR: parse_phostport: bad port number in %s\n", s);
1182
+	LM_ERR("bad port number in %s\n", s);
1183 1183
 	return -1;
1184 1184
 }
1185 1185
 
... ...
@@ -1277,7 +1277,7 @@ int main_loop(void)
1277 1277
 		setstats( 0 );
1278 1278
 #endif
1279 1279
 		if (udp_listen==0){
1280
-			LOG(L_ERR, "ERROR: no fork mode requires at least one"
1280
+			LM_ERR("no fork mode requires at least one"
1281 1281
 					" udp listen address, exiting...\n");
1282 1282
 			goto error;
1283 1283
 		}
... ...
@@ -1322,8 +1322,7 @@ int main_loop(void)
1322 1322
 		} else
1323 1323
 			sendipv6=bind_address;
1324 1324
 		if (udp_listen->next){
1325
-			LOG(L_WARN, "WARNING: using only the first listen address"
1326
-						" (no fork)\n");
1325
+			LM_WARN("using only the first listen address (no fork)\n");
1327 1326
 		}
1328 1327
 
1329 1328
 		/* delay cfg_shmize to the last moment (it must be called _before_
... ...
@@ -1331,7 +1330,7 @@ int main_loop(void)
1331 1331
 		   ignored.
1332 1332
 		*/
1333 1333
 		if (cfg_shmize() < 0) {
1334
-			LOG(L_CRIT, "could not initialize shared configuration\n");
1334
+			LM_CRIT("could not initialize shared configuration\n");
1335 1335
 			goto error;
1336 1336
 		}
1337 1337
 	
... ...
@@ -1365,8 +1364,7 @@ int main_loop(void)
1365 1365
 		 * for the "main" process with rank PROC_MAIN (make sure things are
1366 1366
 		 * not initialized twice)*/
1367 1367
 		if (init_child(PROC_INIT) < 0) {
1368
-			LOG(L_ERR, "ERROR: main_dontfork: init_child(PROC_INT) --"
1369
-						" exiting\n");
1368
+			LM_ERR("init_child(PROC_INT) -- exiting\n");
1370 1369
 			cfg_main_reset_local();
1371 1370
 			goto error;
1372 1371
 		}
... ...
@@ -1377,7 +1375,7 @@ int main_loop(void)
1377 1377
 		/* we need another process to act as the "slow" timer*/
1378 1378
 				pid = fork_process(PROC_TIMER, "slow timer", 0);
1379 1379
 				if (pid<0){
1380
-					LOG(L_CRIT,  "ERROR: main_loop: Cannot fork\n");
1380
+					LM_CRIT("Cannot fork\n");
1381 1381
 					goto error;
1382 1382
 				}
1383 1383
 				if (pid==0){
... ...
@@ -1396,7 +1394,7 @@ int main_loop(void)
1396 1396
 				/* we need another process to act as the "main" timer*/
1397 1397
 				pid = fork_process(PROC_TIMER, "timer", 0);
1398 1398
 				if (pid<0){
1399
-					LOG(L_CRIT,  "ERROR: main_loop: Cannot fork\n");
1399
+					LM_CRIT("Cannot fork\n");
1400 1400
 					goto error;
1401 1401
 				}
1402 1402
 				if (pid==0){
... ...
@@ -1420,8 +1418,7 @@ int main_loop(void)
1420 1420
 		/* call it also w/ PROC_MAIN to make sure modules that init things 
1421 1421
 		 * only in PROC_MAIN get a chance to run */
1422 1422
 		if (init_child(PROC_MAIN) < 0) {
1423
-			LOG(L_ERR, "ERROR: main_dontfork: init_child(PROC_MAIN) "
1424
-						"-- exiting\n");
1423
+			LM_ERR("init_child(PROC_MAIN) -- exiting\n");
1425 1424
 			goto error;
1426 1425
 		}
1427 1426
 
... ...
@@ -1431,7 +1428,7 @@ int main_loop(void)
1431 1431
 		 */
1432 1432
 
1433 1433
 		if (init_child(PROC_SIPINIT) < 0) {
1434
-			LOG(L_ERR, "main_dontfork: init_child failed\n");
1434
+			LM_ERR("init_child failed\n");
1435 1435
 			goto error;
1436 1436
 		}
1437 1437
 		return udp_rcv_loop();
... ...
@@ -1561,7 +1558,7 @@ int main_loop(void)
1561 1561
 		   ignored (cfg_shmize() will copy the default cfgs into shmem).
1562 1562
 		*/
1563 1563
 		if (cfg_shmize() < 0) {
1564
-			LOG(L_CRIT, "could not initialize shared configuration\n");
1564
+			LM_CRIT("could not initialize shared configuration\n");
1565 1565
 			goto error;
1566 1566
 		}
1567 1567
 
... ...
@@ -1581,8 +1578,7 @@ int main_loop(void)
1581 1581
 		 * for the "main" process with rank PROC_MAIN (make sure things are
1582 1582
 		 * not initialized twice)*/
1583 1583
 		if (init_child(PROC_INIT) < 0) {
1584
-			LOG(L_ERR, "ERROR: main: error in init_child(PROC_INT) --"
1585
-					" exiting\n");
1584
+			LM_ERR("error in init_child(PROC_INT) -- exiting\n");
1586 1585
 			cfg_main_reset_local();
1587 1586
 			goto error;
1588 1587
 		}
... ...
@@ -1618,7 +1614,7 @@ int main_loop(void)
1618 1618
 				child_rank++;
1619 1619
 				pid = fork_process(child_rank, si_desc, 1);
1620 1620
 				if (pid<0){
1621
-					LOG(L_CRIT,  "main_loop: Cannot fork\n");
1621
+					LM_CRIT("Cannot fork\n");
1622 1622
 					goto error;
1623 1623
 				}else if (pid==0){
1624 1624
 					/* child */
... ...
@@ -1650,7 +1646,7 @@ int main_loop(void)
1650 1650
 					child_rank++;
1651 1651
 					pid = fork_process(child_rank, si_desc, 1);
1652 1652
 					if (pid<0){
1653
-						LOG(L_CRIT,  "main_loop: Cannot fork\n");
1653
+						LM_CRIT("Cannot fork\n");
1654 1654
 						goto error;
1655 1655
 					}else if (pid==0){
1656 1656
 						/* child */
... ...
@@ -1674,7 +1670,7 @@ int main_loop(void)
1674 1674
 		/* fork again for the "slow" timer process*/
1675 1675
 		pid = fork_process(PROC_TIMER, "slow timer", 1);
1676 1676
 		if (pid<0){
1677
-			LOG(L_CRIT, "main_loop: cannot fork \"slow\" timer process\n");
1677
+			LM_CRIT("cannot fork \"slow\" timer process\n");
1678 1678
 			goto error;
1679 1679
 		}else if (pid==0){
1680 1680
 			/* child */
... ...
@@ -1690,7 +1686,7 @@ int main_loop(void)
1690 1690
 		/* fork again for the "main" timer process*/
1691 1691
 		pid = fork_process(PROC_TIMER, "timer", 1);
1692 1692
 		if (pid<0){
1693
-			LOG(L_CRIT, "main_loop: cannot fork timer process\n");
1693
+			LM_CRIT("cannot fork timer process\n");
1694 1694
 			goto error;
1695 1695
 		}else if (pid==0){
1696 1696
 			/* child */
... ...
@@ -1704,7 +1700,7 @@ int main_loop(void)
1704 1704
 	 * to fork  a tcp capable process, the corresponding tcp. comm. fds in
1705 1705
 	 * pt[] must be set before calling tcp_main_loop()) */
1706 1706
 		if (init_child(PROC_MAIN) < 0) {
1707
-			LOG(L_ERR, "ERROR: main: error in init_child\n");
1707
+			LM_ERR("error in init_child\n");
1708 1708
 			goto error;
1709 1709
 		}
1710 1710
 
... ...
@@ -1715,8 +1711,7 @@ int main_loop(void)
1715 1715
 				/* start tcp+tls master proc */
1716 1716
 			pid = fork_process(PROC_TCP_MAIN, "tcp main process", 0);
1717 1717
 			if (pid<0){
1718
-				LOG(L_CRIT, "main_loop: cannot fork tcp main process: %s\n",
1719
-							strerror(errno));
1718
+				LM_CRIT("cannot fork tcp main process: %s\n", strerror(errno));
1720 1719
 				goto error;
1721 1720
 			}else if (pid==0){
1722 1721
 				/* child */
... ...
@@ -1910,8 +1905,7 @@ int main(int argc, char** argv)
1910 1910
 	
1911 1911
 	/*init pkg mallocs (before parsing cfg or the rest of the cmd line !)*/
1912 1912
 	if (pkg_mem_size)
1913
-		LOG(L_INFO, " private (per process) memory: %ld bytes\n",
1914
-								pkg_mem_size );
1913
+		LM_INFO("private (per process) memory: %ld bytes\n", pkg_mem_size );
1915 1914
 	if (init_pkg_mallocs()==-1)
1916 1915
 		goto error;
1917 1916
 
... ...
@@ -1949,8 +1943,7 @@ int main(int argc, char** argv)
1949 1949
 										optarg);
1950 1950
 						goto error;
1951 1951
 					};
1952
-					LOG(L_INFO, "ser: shared memory: %ld bytes\n",
1953
-									shm_mem_size );
1952
+					LM_INFO("shared memory: %ld bytes\n", shm_mem_size );
1954 1953
 					break;
1955 1954
 			case 'M':
1956 1955
 					/* ignore it, it was parsed immediately after startup,
... ...
@@ -2087,13 +2080,12 @@ int main(int argc, char** argv)
2087 2087
 try_again:
2088 2088
 		if (read(rfd, (void*)&seed, sizeof(seed))==-1){
2089 2089
 			if (errno==EINTR) goto try_again; /* interrupted by signal */
2090
-			LOG(L_WARN, "WARNING: could not read from /dev/urandom (%d)\n",
2091
-						errno);
2090
+			LM_WARN("could not read from /dev/urandom (%d)\n", errno);
2092 2091
 		}
2093 2092
 		DBG("read %u from /dev/urandom\n", seed);
2094 2093
 			close(rfd);
2095 2094
 	}else{
2096
-		LOG(L_WARN, "WARNING: could not open /dev/urandom (%d)\n", errno);
2095
+		LM_WARN("could not open /dev/urandom (%d)\n", errno);
2097 2096
 	}
2098 2097
 	seed+=getpid()+time(0);
2099 2098
 	DBG("seeding PRNG with %u\n", seed);
... ...
@@ -2409,53 +2401,53 @@ try_again:
2409 2409
 	if (init_atomic_ops()==-1)
2410 2410
 		goto error;
2411 2411
 	if (init_basex() != 0){
2412
-		LOG(L_CRIT, "could not initialize base* framework\n");
2412
+		LM_CRIT("could not initialize base* framework\n");
2413 2413
 		goto error;
2414 2414
 	}
2415 2415
 	if (sr_cfg_init() < 0) {
2416
-		LOG(L_CRIT, "could not initialize configuration framework\n");
2416
+		LM_CRIT("could not initialize configuration framework\n");
2417 2417
 		goto error;
2418 2418
 	}
2419 2419
 	/* declare the core cfg before the module configs */
2420 2420
 	if (cfg_declare("core", core_cfg_def, &default_core_cfg, cfg_sizeof(core),
2421 2421
 			&core_cfg)
2422 2422
 	) {
2423
-		LOG(L_CRIT, "could not declare the core configuration\n");
2423
+		LM_CRIT("could not declare the core configuration\n");
2424 2424
 		goto error;
2425 2425
 	}
2426 2426
 #ifdef USE_TCP
2427 2427
 	if (tcp_register_cfg()){
2428
-		LOG(L_CRIT, "could not register the tcp configuration\n");
2428
+		LM_CRIT("could not register the tcp configuration\n");
2429 2429
 		goto error;
2430 2430
 	}
2431 2431
 #endif /* USE_TCP */
2432 2432
 	/*init timer, before parsing the cfg!*/
2433 2433
 	if (init_timer()<0){
2434
-		LOG(L_CRIT, "could not initialize timer, exiting...\n");
2434
+		LM_CRIT("could not initialize timer, exiting...\n");
2435 2435
 		goto error;
2436 2436
 	}
2437 2437
 #ifdef USE_DNS_CACHE
2438 2438
 	if (init_dns_cache()<0){
2439
-		LOG(L_CRIT, "could not initialize the dns cache, exiting...\n");
2439
+		LM_CRIT("could not initialize the dns cache, exiting...\n");
2440 2440
 		goto error;
2441 2441
 	}
2442 2442
 #ifdef USE_DNS_CACHE_STATS
2443 2443
 	/* preinitializing before the nubmer of processes is determined */
2444 2444
 	if (init_dns_cache_stats(1)<0){
2445
-		LOG(L_CRIT, "could not initialize the dns cache measurement\n");
2445
+		LM_CRIT("could not initialize the dns cache measurement\n");
2446 2446
 		goto error;
2447 2447
 	}
2448 2448
 #endif /* USE_DNS_CACHE_STATS */
2449 2449
 #endif
2450 2450
 #ifdef USE_DST_BLACKLIST
2451 2451
 	if (init_dst_blacklist()<0){
2452
-		LOG(L_CRIT, "could not initialize the dst blacklist, exiting...\n");
2452
+		LM_CRIT("could not initialize the dst blacklist, exiting...\n");
2453 2453
 		goto error;
2454 2454
 	}
2455 2455
 #ifdef USE_DST_BLACKLIST_STATS
2456 2456
 	/* preinitializing before the number of processes is determined */
2457 2457
 	if (init_dst_blacklist_stats(1)<0){
2458
-		LOG(L_CRIT, "could not initialize the dst blacklist measurement\n");
2458
+		LM_CRIT("could not initialize the dst blacklist measurement\n");
2459 2459
 		goto error;
2460 2460
 	}
2461 2461
 #endif /* USE_DST_BLACKLIST_STATS */
... ...
@@ -2467,7 +2459,7 @@ try_again:
2467 2467
 	if (!tcp_disable){
2468 2468
 		/*init tcp*/
2469 2469
 		if (init_tcp()<0){
2470
-			LOG(L_CRIT, "could not initialize tcp, exiting...\n");
2470
+			LM_CRIT("could not initialize tcp, exiting...\n");
2471 2471
 			goto error;
2472 2472
 		}
2473 2473
 	}
... ...
@@ -2475,7 +2467,7 @@ try_again:
2475 2475
 #ifdef USE_SCTP
2476 2476
 	if (!sctp_disable){
2477 2477
 		if (sctp_core_init()<0){
2478
-			LOG(L_CRIT, "Could not initialize sctp, exiting...\n");
2478
+			LM_CRIT("Could not initialize sctp, exiting...\n");
2479 2479
 			goto error;
2480 2480
 		}
2481 2481
 	}
... ...
@@ -2516,14 +2508,14 @@ try_again:
2516 2516
 #ifdef USE_TLS
2517 2517
 	if (!tls_disable){
2518 2518
 		if (!tls_loaded()){
2519
-			LOG(L_WARN, "WARNING: tls support enabled, but no tls engine "
2519
+			LM_WARN("tls support enabled, but no tls engine "
2520 2520
 						" available (forgot to load the tls module?)\n");
2521
-			LOG(L_WARN, "WARNING: disabling tls...\n");
2521
+			LM_WARN("disabling tls...\n");
2522 2522
 			tls_disable=1;
2523 2523
 		}
2524 2524
 		/* init tls*/
2525 2525
 		if (init_tls()<0){
2526
-			LOG(L_CRIT, "could not initialize tls, exiting...\n");
2526
+			LM_CRIT("could not initialize tls, exiting...\n");
2527 2527
 			goto error;
2528 2528
 		}
2529 2529
 	}
... ...
@@ -2539,13 +2531,13 @@ try_again:
2539 2539
 
2540 2540
 #if defined USE_DNS_CACHE && defined USE_DNS_CACHE_STATS
2541 2541
 	if (init_dns_cache_stats(get_max_procs())<0){
2542
-		LOG(L_CRIT, "could not initialize the dns cache measurement\n");
2542
+		LM_CRIT("could not initialize the dns cache measurement\n");
2543 2543
 		goto error;
2544 2544
 	}
2545 2545
 #endif
2546 2546
 #if defined USE_DST_BLACKLIST && defined USE_DST_BLACKLIST_STATS
2547 2547
 	if (init_dst_blacklist_stats(get_max_procs())<0){
2548
-		LOG(L_CRIT, "could not initialize the dst blacklist measurement\n");
2548
+		LM_CRIT("could not initialize the dst blacklist measurement\n");
2549 2549
 		goto error;
2550 2550
 	}
2551 2551
 #endif