1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
|
diff --git a/arguments.cc b/arguments.cc
index 935c9ea..5e62d41 100644
--- a/arguments.cc
+++ b/arguments.cc
@@ -443,7 +443,7 @@ bool ArgvMap::file(const char *fname, bool lax, bool included)
set("include-dir","Directory to include configuration files from");
if(!parseFile(fname, "", lax)) {
- L << Logger::Warning << "Unable to open " << fname << std::endl;
+ g_log << Logger::Warning << "Unable to open " << fname << std::endl;
return false;
}
@@ -453,7 +453,7 @@ bool ArgvMap::file(const char *fname, bool lax, bool included)
gatherIncludes(extraConfigs);
for(const std::string& fn : extraConfigs) {
if (!file(fn.c_str(), lax, true)) {
- L << Logger::Error << fn << " could not be parsed" << std::endl;
+ g_log << Logger::Error << fn << " could not be parsed" << std::endl;
throw ArgException(fn + " could not be parsed");
}
}
@@ -471,18 +471,18 @@ void ArgvMap::gatherIncludes(std::vector<std::string> &extraConfigs) {
// stat
if (stat(params["include-dir"].c_str(), &st)) {
- L << Logger::Error << params["include-dir"] << " does not exist!" << std::endl;
+ g_log << Logger::Error << params["include-dir"] << " does not exist!" << std::endl;
throw ArgException(params["include-dir"] + " does not exist!");
}
// wonder if it's accessible directory
if (!S_ISDIR(st.st_mode)) {
- L << Logger::Error << params["include-dir"] << " is not a directory" << std::endl;
+ g_log << Logger::Error << params["include-dir"] << " is not a directory" << std::endl;
throw ArgException(params["include-dir"] + " is not a directory");
}
if (!(dir = opendir(params["include-dir"].c_str()))) {
- L << Logger::Error << params["include-dir"] << " is not accessible" << std::endl;
+ g_log << Logger::Error << params["include-dir"] << " is not accessible" << std::endl;
throw ArgException(params["include-dir"] + " is not accessible");
}
@@ -494,7 +494,7 @@ void ArgvMap::gatherIncludes(std::vector<std::string> &extraConfigs) {
namebuf << params["include-dir"].c_str() << "/" << ent->d_name; // FIXME: Use some path separator
// ensure it's readable file
if (stat(namebuf.str().c_str(), &st) || !S_ISREG(st.st_mode)) {
- L << Logger::Error << namebuf.str() << " is not a file" << std::endl;
+ g_log << Logger::Error << namebuf.str() << " is not a file" << std::endl;
closedir(dir);
throw ArgException(namebuf.str() + " does not exist!");
}
diff --git a/dns.hh b/dns.hh
index 88a658c..bce6202 100644
--- a/dns.hh
+++ b/dns.hh
@@ -225,7 +225,7 @@ inline uint16_t * getFlagsFromDNSHeader(struct dnsheader * dh)
#define FLAGS_CD_OFFSET (12)
#endif
-#define L theL()
+#define g_log theL()
extern time_t s_starttime;
uint32_t hashQuestion(const char* packet, uint16_t len, uint32_t init);
diff --git a/gss_context.cc b/gss_context.cc
index 55c54be..8ef1061 100644
--- a/gss_context.cc
+++ b/gss_context.cc
@@ -456,17 +456,17 @@ bool gss_add_signature(const DNSName& context, const std::string& message, std::
string tmp_mac;
GssContext gssctx(context);
if (!gssctx.valid()) {
- L<<Logger::Error<<"GSS context '"<<context<<"' is not valid"<<endl;
+ g_log<<Logger::Error<<"GSS context '"<<context<<"' is not valid"<<endl;
for(const string& error : gssctx.getErrorStrings()) {
- L<<Logger::Error<<"GSS error: "<<error<<endl;;
+ g_log<<Logger::Error<<"GSS error: "<<error<<endl;;
}
return false;
}
if (!gssctx.sign(message, tmp_mac)) {
- L<<Logger::Error<<"Could not sign message using GSS context '"<<context<<"'"<<endl;
+ g_log<<Logger::Error<<"Could not sign message using GSS context '"<<context<<"'"<<endl;
for(const string& error : gssctx.getErrorStrings()) {
- L<<Logger::Error<<"GSS error: "<<error<<endl;;
+ g_log<<Logger::Error<<"GSS error: "<<error<<endl;;
}
return false;
}
@@ -477,17 +477,17 @@ bool gss_add_signature(const DNSName& context, const std::string& message, std::
bool gss_verify_signature(const DNSName& context, const std::string& message, const std::string& mac) {
GssContext gssctx(context);
if (!gssctx.valid()) {
- L<<Logger::Error<<"GSS context '"<<context<<"' is not valid"<<endl;
+ g_log<<Logger::Error<<"GSS context '"<<context<<"' is not valid"<<endl;
for(const string& error : gssctx.getErrorStrings()) {
- L<<Logger::Error<<"GSS error: "<<error<<endl;;
+ g_log<<Logger::Error<<"GSS error: "<<error<<endl;;
}
return false;
}
if (!gssctx.verify(message, mac)) {
- L<<Logger::Error<<"Could not verify message using GSS context '"<<context<<"'"<<endl;
+ g_log<<Logger::Error<<"Could not verify message using GSS context '"<<context<<"'"<<endl;
for(const string& error : gssctx.getErrorStrings()) {
- L<<Logger::Error<<"GSS error: "<<error<<endl;;
+ g_log<<Logger::Error<<"GSS error: "<<error<<endl;;
}
return false;
}
diff --git a/logger.hh b/logger.hh
index 989c921..7d955ea 100644
--- a/logger.hh
+++ b/logger.hh
@@ -70,9 +70,9 @@ public:
void resetFlags(){flags=0;open();} //!< zero the flags
/** Use this to stream to your log, like this:
\code
- L<<"This is an informational message"<<endl; // logged at default loglevel (Info)
- L<<Logger::Warning<<"Out of diskspace"<<endl; // Logged as a warning
- L<<"This is an informational message"<<endl; // logged AGAIN at default loglevel (Info)
+ g_log<<"This is an informational message"<<endl; // logged at default loglevel (Info)
+ g_log<<Logger::Warning<<"Out of diskspace"<<endl; // Logged as a warning
+ g_log<<"This is an informational message"<<endl; // logged AGAIN at default loglevel (Info)
\endcode
*/
Logger& operator<<(const char *s);
diff --git a/lua-recursor4.hh b/lua-recursor4.hh
index d36fd7c..4c12022 100644
--- a/lua-recursor4.hh
+++ b/lua-recursor4.hh
@@ -43,9 +43,9 @@ unsigned int getRecursorThreadId();
class LuaContext;
#if defined(HAVE_LUA)
-#undef L
+#undef g_log
#include "ext/luawrapper/include/LuaContext.hpp"
-#define L theL()
+#define g_log theL()
#endif
// pdns_ffi_param_t is a lightuserdata
diff --git a/lwres.cc b/lwres.cc
index 270f52c..30f0650 100644
--- a/lwres.cc
+++ b/lwres.cc
@@ -236,7 +236,7 @@ int asyncresolve(const ComboAddress& ip, const DNSName& domain, int type, bool d
if(domain != mdp.d_qname) {
if(!mdp.d_qname.empty() && domain.toString().find((char)0) == string::npos /* ugly */) {// embedded nulls are too noisy, plus empty domains are too
- L<<Logger::Notice<<"Packet purporting to come from remote server "<<ip.toString()<<" contained wrong answer: '" << domain << "' != '" << mdp.d_qname << "'" << endl;
+ g_log<<Logger::Notice<<"Packet purporting to come from remote server "<<ip.toString()<<" contained wrong answer: '" << domain << "' != '" << mdp.d_qname << "'" << endl;
}
// unexpected count has already been done @ pdns_recursor.cc
goto out;
@@ -276,7 +276,7 @@ int asyncresolve(const ComboAddress& ip, const DNSName& domain, int type, bool d
}
catch(std::exception &mde) {
if(::arg().mustDo("log-common-errors"))
- L<<Logger::Notice<<"Unable to parse packet from remote server "<<ip.toString()<<": "<<mde.what()<<endl;
+ g_log<<Logger::Notice<<"Unable to parse packet from remote server "<<ip.toString()<<": "<<mde.what()<<endl;
lwr->d_rcode = RCode::FormErr;
g_stats.serverParseError++;
#ifdef HAVE_PROTOBUF
@@ -287,7 +287,7 @@ int asyncresolve(const ComboAddress& ip, const DNSName& domain, int type, bool d
return 1; // success - oddly enough
}
catch(...) {
- L<<Logger::Notice<<"Unknown error parsing packet from remote server"<<endl;
+ g_log<<Logger::Notice<<"Unknown error parsing packet from remote server"<<endl;
}
g_stats.serverParseError++;
diff --git a/pdns_recursor.cc b/pdns_recursor.cc
index 6175af2..32c0814 100644
--- a/pdns_recursor.cc
+++ b/pdns_recursor.cc
@@ -375,12 +375,12 @@ static void setSocketBuffer(int fd, int optname, uint32_t size)
socklen_t len=sizeof(psize);
if(!getsockopt(fd, SOL_SOCKET, optname, (char*)&psize, &len) && psize > size) {
- L<<Logger::Error<<"Not decreasing socket buffer size from "<<psize<<" to "<<size<<endl;
+ g_log<<Logger::Error<<"Not decreasing socket buffer size from "<<psize<<" to "<<size<<endl;
return;
}
if (setsockopt(fd, SOL_SOCKET, optname, (char*)&size, sizeof(size)) < 0 )
- L<<Logger::Error<<"Unable to raise socket buffer size to "<<size<<": "<<strerror(errno)<<endl;
+ g_log<<Logger::Error<<"Unable to raise socket buffer size to "<<size<<": "<<strerror(errno)<<endl;
}
@@ -423,7 +423,7 @@ public:
closesocket(*fd);
}
catch(const PDNSException& e) {
- L<<Logger::Error<<"Error closing UDP socket after connect() failed: "<<e.reason<<endl;
+ g_log<<Logger::Error<<"Error closing UDP socket after connect() failed: "<<e.reason<<endl;
}
if(err==ENETUNREACH) // Seth "My Interfaces Are Like A Yo Yo" Arnold special
@@ -461,7 +461,7 @@ public:
closesocket(*i);
}
catch(const PDNSException& e) {
- L<<Logger::Error<<"Error closing returned UDP socket: "<<e.reason<<endl;
+ g_log<<Logger::Error<<"Error closing returned UDP socket: "<<e.reason<<endl;
}
d_socks.erase(i++);
@@ -577,7 +577,7 @@ int arecvfrom(char *data, size_t len, int flags, const ComboAddress& fromaddr, s
*d_len=packet.size();
memcpy(data,packet.c_str(),min(len,*d_len));
if(*nearMissLimit && pident.nearMisses > *nearMissLimit) {
- L<<Logger::Error<<"Too many ("<<pident.nearMisses<<" > "<<*nearMissLimit<<") bogus answers for '"<<domain<<"' from "<<fromaddr.toString()<<", assuming spoof attempt."<<endl;
+ g_log<<Logger::Error<<"Too many ("<<pident.nearMisses<<" > "<<*nearMissLimit<<") bogus answers for '"<<domain<<"' from "<<fromaddr.toString()<<", assuming spoof attempt."<<endl;
g_stats.spoofCount++;
return -1;
}
@@ -597,7 +597,7 @@ static void writePid(void)
if(of)
of<< Utility::getpid() <<endl;
else
- L<<Logger::Error<<"Writing pid for "<<Utility::getpid()<<" to "<<s_pidfname<<" failed: "<<strerror(errno)<<endl;
+ g_log<<Logger::Error<<"Writing pid for "<<Utility::getpid()<<" to "<<s_pidfname<<" failed: "<<strerror(errno)<<endl;
}
TCPConnection::TCPConnection(int fd, const ComboAddress& addr) : d_remote(addr), d_fd(fd)
@@ -610,10 +610,10 @@ TCPConnection::~TCPConnection()
{
try {
if(closesocket(d_fd) < 0)
- L<<Logger::Error<<"Error closing socket for TCPConnection"<<endl;
+ g_log<<Logger::Error<<"Error closing socket for TCPConnection"<<endl;
}
catch(const PDNSException& e) {
- L<<Logger::Error<<"Error closing TCPConnection socket: "<<e.reason<<endl;
+ g_log<<Logger::Error<<"Error closing TCPConnection socket: "<<e.reason<<endl;
}
if(t_tcpClientCounts->count(d_remote) && !(*t_tcpClientCounts)[d_remote]--)
@@ -866,12 +866,12 @@ static void startDoResolve(void *p)
if(!g_quiet || tracedQuery) {
- L<<Logger::Warning<<t_id<<" ["<<MT->getTid()<<"/"<<MT->numProcesses()<<"] " << (dc->d_tcp ? "TCP " : "") << "question for '"<<dc->d_mdp.d_qname<<"|"
+ g_log<<Logger::Warning<<t_id<<" ["<<MT->getTid()<<"/"<<MT->numProcesses()<<"] " << (dc->d_tcp ? "TCP " : "") << "question for '"<<dc->d_mdp.d_qname<<"|"
<<DNSRecordContent::NumberToType(dc->d_mdp.d_qtype)<<"' from "<<dc->getRemote();
if(!dc->d_ednssubnet.source.empty()) {
- L<<" (ecs "<<dc->d_ednssubnet.source.toString()<<")";
+ g_log<<" (ecs "<<dc->d_ednssubnet.source.toString()<<")";
}
- L<<endl;
+ g_log<<endl;
}
sr.setId(MT->getTid());
@@ -934,7 +934,7 @@ static void startDoResolve(void *p)
}
catch(ImmediateServFailException &e) {
if(g_logCommonErrors)
- L<<Logger::Notice<<"Sending SERVFAIL to "<<dc->getRemote()<<" during resolve of '"<<dc->d_mdp.d_qname<<"' because: "<<e.reason<<endl;
+ g_log<<Logger::Notice<<"Sending SERVFAIL to "<<dc->getRemote()<<" during resolve of '"<<dc->d_mdp.d_qname<<"' because: "<<e.reason<<endl;
res = RCode::ServFail;
}
@@ -1056,7 +1056,7 @@ static void startDoResolve(void *p)
boost::split(lines, trace, boost::is_any_of("\n"));
for(const string& line : lines) {
if(!line.empty())
- L<<Logger::Warning<< line << endl;
+ g_log<<Logger::Warning<< line << endl;
}
}
}
@@ -1073,14 +1073,14 @@ static void startDoResolve(void *p)
if(!shouldNotValidate && sr.isDNSSECValidationRequested()) {
try {
if(sr.doLog()) {
- L<<Logger::Warning<<"Starting validation of answer to "<<dc->d_mdp.d_qname<<"|"<<QType(dc->d_mdp.d_qtype).getName()<<" for "<<dc->d_remote.toStringWithPort()<<endl;
+ g_log<<Logger::Warning<<"Starting validation of answer to "<<dc->d_mdp.d_qname<<"|"<<QType(dc->d_mdp.d_qtype).getName()<<" for "<<dc->d_remote.toStringWithPort()<<endl;
}
auto state = sr.getValidationState();
if(state == Secure) {
if(sr.doLog()) {
- L<<Logger::Warning<<"Answer to "<<dc->d_mdp.d_qname<<"|"<<QType(dc->d_mdp.d_qtype).getName()<<" for "<<dc->d_remote.toStringWithPort()<<" validates correctly"<<endl;
+ g_log<<Logger::Warning<<"Answer to "<<dc->d_mdp.d_qname<<"|"<<QType(dc->d_mdp.d_qtype).getName()<<" for "<<dc->d_remote.toStringWithPort()<<" validates correctly"<<endl;
}
// Is the query source interested in the value of the ad-bit?
@@ -1089,34 +1089,34 @@ static void startDoResolve(void *p)
}
else if(state == Insecure) {
if(sr.doLog()) {
- L<<Logger::Warning<<"Answer to "<<dc->d_mdp.d_qname<<"|"<<QType(dc->d_mdp.d_qtype).getName()<<" for "<<dc->d_remote.toStringWithPort()<<" validates as Insecure"<<endl;
+ g_log<<Logger::Warning<<"Answer to "<<dc->d_mdp.d_qname<<"|"<<QType(dc->d_mdp.d_qtype).getName()<<" for "<<dc->d_remote.toStringWithPort()<<" validates as Insecure"<<endl;
}
pw.getHeader()->ad=0;
}
else if(state == Bogus) {
if(g_dnssecLogBogus || sr.doLog() || g_dnssecmode == DNSSECMode::ValidateForLog) {
- L<<Logger::Warning<<"Answer to "<<dc->d_mdp.d_qname<<"|"<<QType(dc->d_mdp.d_qtype).getName()<<" for "<<dc->d_remote.toStringWithPort()<<" validates as Bogus"<<endl;
+ g_log<<Logger::Warning<<"Answer to "<<dc->d_mdp.d_qname<<"|"<<QType(dc->d_mdp.d_qtype).getName()<<" for "<<dc->d_remote.toStringWithPort()<<" validates as Bogus"<<endl;
}
// Does the query or validation mode sending out a SERVFAIL on validation errors?
if(!pw.getHeader()->cd && (g_dnssecmode == DNSSECMode::ValidateAll || dc->d_mdp.d_header.ad || DNSSECOK)) {
if(sr.doLog()) {
- L<<Logger::Warning<<"Sending out SERVFAIL for "<<dc->d_mdp.d_qname<<"|"<<QType(dc->d_mdp.d_qtype).getName()<<" because recursor or query demands it for Bogus results"<<endl;
+ g_log<<Logger::Warning<<"Sending out SERVFAIL for "<<dc->d_mdp.d_qname<<"|"<<QType(dc->d_mdp.d_qtype).getName()<<" because recursor or query demands it for Bogus results"<<endl;
}
pw.getHeader()->rcode=RCode::ServFail;
goto sendit;
} else {
if(sr.doLog()) {
- L<<Logger::Warning<<"Not sending out SERVFAIL for "<<dc->d_mdp.d_qname<<"|"<<QType(dc->d_mdp.d_qtype).getName()<<" Bogus validation since neither config nor query demands this"<<endl;
+ g_log<<Logger::Warning<<"Not sending out SERVFAIL for "<<dc->d_mdp.d_qname<<"|"<<QType(dc->d_mdp.d_qtype).getName()<<" Bogus validation since neither config nor query demands this"<<endl;
}
}
}
}
catch(ImmediateServFailException &e) {
if(g_logCommonErrors)
- L<<Logger::Notice<<"Sending SERVFAIL to "<<dc->getRemote()<<" during validation of '"<<dc->d_mdp.d_qname<<"|"<<QType(dc->d_mdp.d_qtype).getName()<<"' because: "<<e.reason<<endl;
+ g_log<<Logger::Notice<<"Sending SERVFAIL to "<<dc->getRemote()<<" during validation of '"<<dc->d_mdp.d_qname<<"|"<<QType(dc->d_mdp.d_qtype).getName()<<"' because: "<<e.reason<<endl;
pw.getHeader()->rcode=RCode::ServFail;
goto sendit;
}
@@ -1203,7 +1203,7 @@ static void startDoResolve(void *p)
addCMsgSrcAddr(&msgh, cbuf, &dc->d_local, 0);
}
if(sendmsg(dc->d_socket, &msgh, 0) < 0 && g_logCommonErrors)
- L<<Logger::Warning<<"Sending UDP reply to client "<<dc->d_remote.toStringWithPort()<<" failed with: "<<strerror(errno)<<endl;
+ g_log<<Logger::Warning<<"Sending UDP reply to client "<<dc->d_remote.toStringWithPort()<<" failed with: "<<strerror(errno)<<endl;
if(!SyncRes::s_nopacketcache && !variableAnswer && !sr.wasVariable() ) {
t_packetCache->insertResponsePacket(dc->d_tag, dc->d_qhash, dc->d_mdp.d_qname, dc->d_mdp.d_qtype, dc->d_mdp.d_qclass,
@@ -1229,11 +1229,11 @@ static void startDoResolve(void *p)
bool hadError=true;
if(wret == 0)
- L<<Logger::Error<<"EOF writing TCP answer to "<<dc->getRemote()<<endl;
+ g_log<<Logger::Error<<"EOF writing TCP answer to "<<dc->getRemote()<<endl;
else if(wret < 0 )
- L<<Logger::Error<<"Error writing TCP answer to "<<dc->getRemote()<<": "<< strerror(errno) <<endl;
+ g_log<<Logger::Error<<"Error writing TCP answer to "<<dc->getRemote()<<": "<< strerror(errno) <<endl;
else if((unsigned int)wret != 2 + packet.size())
- L<<Logger::Error<<"Oops, partial answer sent to "<<dc->getRemote()<<" for "<<dc->d_mdp.d_qname<<" (size="<< (2 + packet.size()) <<", sent "<<wret<<")"<<endl;
+ g_log<<Logger::Error<<"Oops, partial answer sent to "<<dc->getRemote()<<" for "<<dc->d_mdp.d_qname<<" (size="<< (2 + packet.size()) <<", sent "<<wret<<")"<<endl;
else
hadError=false;
@@ -1258,16 +1258,16 @@ static void startDoResolve(void *p)
}
float spent=makeFloat(sr.getNow()-dc->d_now);
if(!g_quiet) {
- L<<Logger::Error<<t_id<<" ["<<MT->getTid()<<"/"<<MT->numProcesses()<<"] answer to "<<(dc->d_mdp.d_header.rd?"":"non-rd ")<<"question '"<<dc->d_mdp.d_qname<<"|"<<DNSRecordContent::NumberToType(dc->d_mdp.d_qtype);
- L<<"': "<<ntohs(pw.getHeader()->ancount)<<" answers, "<<ntohs(pw.getHeader()->arcount)<<" additional, took "<<sr.d_outqueries<<" packets, "<<
+ g_log<<Logger::Error<<t_id<<" ["<<MT->getTid()<<"/"<<MT->numProcesses()<<"] answer to "<<(dc->d_mdp.d_header.rd?"":"non-rd ")<<"question '"<<dc->d_mdp.d_qname<<"|"<<DNSRecordContent::NumberToType(dc->d_mdp.d_qtype);
+ g_log<<"': "<<ntohs(pw.getHeader()->ancount)<<" answers, "<<ntohs(pw.getHeader()->arcount)<<" additional, took "<<sr.d_outqueries<<" packets, "<<
sr.d_totUsec/1000.0<<" netw ms, "<< spent*1000.0<<" tot ms, "<<
sr.d_throttledqueries<<" throttled, "<<sr.d_timeouts<<" timeouts, "<<sr.d_tcpoutqueries<<" tcp connections, rcode="<< res;
if(!shouldNotValidate && sr.isDNSSECValidationRequested()) {
- L<< ", dnssec="<<vStates[sr.getValidationState()];
+ g_log<< ", dnssec="<<vStates[sr.getValidationState()];
}
- L<<endl;
+ g_log<<endl;
}
@@ -1320,28 +1320,28 @@ static void startDoResolve(void *p)
dc=0;
}
catch(PDNSException &ae) {
- L<<Logger::Error<<"startDoResolve problem "<<makeLoginfo(dc)<<": "<<ae.reason<<endl;
+ g_log<<Logger::Error<<"startDoResolve problem "<<makeLoginfo(dc)<<": "<<ae.reason<<endl;
delete dc;
}
catch(MOADNSException& e) {
- L<<Logger::Error<<"DNS parser error "<<makeLoginfo(dc) <<": "<<dc->d_mdp.d_qname<<", "<<e.what()<<endl;
+ g_log<<Logger::Error<<"DNS parser error "<<makeLoginfo(dc) <<": "<<dc->d_mdp.d_qname<<", "<<e.what()<<endl;
delete dc;
}
catch(std::exception& e) {
- L<<Logger::Error<<"STL error "<< makeLoginfo(dc)<<": "<<e.what();
+ g_log<<Logger::Error<<"STL error "<< makeLoginfo(dc)<<": "<<e.what();
// Luawrapper nests the exception from Lua, so we unnest it here
try {
std::rethrow_if_nested(e);
} catch(const std::exception& ne) {
- L<<". Extra info: "<<ne.what();
+ g_log<<". Extra info: "<<ne.what();
} catch(...) {}
- L<<endl;
+ g_log<<endl;
delete dc;
}
catch(...) {
- L<<Logger::Error<<"Any other exception in a resolver context "<< makeLoginfo(dc) <<endl;
+ g_log<<Logger::Error<<"Any other exception in a resolver context "<< makeLoginfo(dc) <<endl;
}
g_stats.maxMThreadStackUsage = max(MT->getMaxStackUsage(), g_stats.maxMThreadStackUsage);
@@ -1449,7 +1449,7 @@ static void handleRunningTCPQuestion(int fd, FDMultiplexer::funcparam_t& var)
}
if(!bytes || bytes < 0) {
if(g_logCommonErrors)
- L<<Logger::Error<<"TCP client "<< conn->d_remote.toString() <<" disconnected after first byte"<<endl;
+ g_log<<Logger::Error<<"TCP client "<< conn->d_remote.toString() <<" disconnected after first byte"<<endl;
t_fdm->removeReadFD(fd);
return;
}
@@ -1457,7 +1457,7 @@ static void handleRunningTCPQuestion(int fd, FDMultiplexer::funcparam_t& var)
else if(conn->state==TCPConnection::GETQUESTION) {
ssize_t bytes=recv(conn->getFD(), conn->data + conn->bytesread, conn->qlen - conn->bytesread, 0);
if(!bytes || bytes < 0 || bytes > std::numeric_limits<std::uint16_t>::max()) {
- L<<Logger::Error<<"TCP client "<< conn->d_remote.toString() <<" disconnected while reading question body"<<endl;
+ g_log<<Logger::Error<<"TCP client "<< conn->d_remote.toString() <<" disconnected while reading question body"<<endl;
t_fdm->removeReadFD(fd);
return;
}
@@ -1472,7 +1472,7 @@ static void handleRunningTCPQuestion(int fd, FDMultiplexer::funcparam_t& var)
catch(MOADNSException &mde) {
g_stats.clientParseError++;
if(g_logCommonErrors)
- L<<Logger::Error<<"Unable to parse packet from TCP client "<< conn->d_remote.toString() <<endl;
+ g_log<<Logger::Error<<"Unable to parse packet from TCP client "<< conn->d_remote.toString() <<endl;
return;
}
dc->d_tcpConnection = conn; // carry the torch
@@ -1516,14 +1516,14 @@ static void handleRunningTCPQuestion(int fd, FDMultiplexer::funcparam_t& var)
}
catch(const std::exception& e) {
if(g_logCommonErrors)
- L<<Logger::Warning<<"Error parsing a query packet qname='"<<qname<<"' for tag determination, setting tag=0: "<<e.what()<<endl;
+ g_log<<Logger::Warning<<"Error parsing a query packet qname='"<<qname<<"' for tag determination, setting tag=0: "<<e.what()<<endl;
}
}
}
catch(const std::exception& e)
{
if(g_logCommonErrors)
- L<<Logger::Warning<<"Error parsing a query packet for tag determination, setting tag=0: "<<e.what()<<endl;
+ g_log<<Logger::Warning<<"Error parsing a query packet for tag determination, setting tag=0: "<<e.what()<<endl;
}
}
#ifdef HAVE_PROTOBUF
@@ -1543,20 +1543,20 @@ static void handleRunningTCPQuestion(int fd, FDMultiplexer::funcparam_t& var)
}
catch(std::exception& e) {
if(g_logCommonErrors)
- L<<Logger::Warning<<"Error parsing a TCP query packet for edns subnet: "<<e.what()<<endl;
+ g_log<<Logger::Warning<<"Error parsing a TCP query packet for edns subnet: "<<e.what()<<endl;
}
}
#endif
if(dc->d_mdp.d_header.qr) {
delete dc;
g_stats.ignoredCount++;
- L<<Logger::Error<<"Ignoring answer from TCP client "<< conn->d_remote.toString() <<" on server socket!"<<endl;
+ g_log<<Logger::Error<<"Ignoring answer from TCP client "<< conn->d_remote.toString() <<" on server socket!"<<endl;
return;
}
if(dc->d_mdp.d_header.opcode) {
delete dc;
g_stats.ignoredCount++;
- L<<Logger::Error<<"Ignoring non-query opcode from TCP client "<< conn->d_remote.toString() <<" on server socket!"<<endl;
+ g_log<<Logger::Error<<"Ignoring non-query opcode from TCP client "<< conn->d_remote.toString() <<" on server socket!"<<endl;
return;
}
else {
@@ -1582,7 +1582,7 @@ static void handleNewTCPQuestion(int fd, FDMultiplexer::funcparam_t& )
closesocket(newsock);
}
catch(const PDNSException& e) {
- L<<Logger::Error<<"Error closing TCP socket after an over capacity drop: "<<e.reason<<endl;
+ g_log<<Logger::Error<<"Error closing TCP socket after an over capacity drop: "<<e.reason<<endl;
}
return;
}
@@ -1591,14 +1591,14 @@ static void handleNewTCPQuestion(int fd, FDMultiplexer::funcparam_t& )
t_remotes->push_back(addr);
if(t_allowFrom && !t_allowFrom->match(&addr)) {
if(!g_quiet)
- L<<Logger::Error<<"["<<MT->getTid()<<"] dropping TCP query from "<<addr.toString()<<", address not matched by allow-from"<<endl;
+ g_log<<Logger::Error<<"["<<MT->getTid()<<"] dropping TCP query from "<<addr.toString()<<", address not matched by allow-from"<<endl;
g_stats.unauthorizedTCP++;
try {
closesocket(newsock);
}
catch(const PDNSException& e) {
- L<<Logger::Error<<"Error closing TCP socket after an ACL drop: "<<e.reason<<endl;
+ g_log<<Logger::Error<<"Error closing TCP socket after an ACL drop: "<<e.reason<<endl;
}
return;
}
@@ -1608,7 +1608,7 @@ static void handleNewTCPQuestion(int fd, FDMultiplexer::funcparam_t& )
closesocket(newsock); // don't call TCPConnection::closeAndCleanup here - did not enter it in the counts yet!
}
catch(const PDNSException& e) {
- L<<Logger::Error<<"Error closing TCP socket after an overflow drop: "<<e.reason<<endl;
+ g_log<<Logger::Error<<"Error closing TCP socket after an overflow drop: "<<e.reason<<endl;
}
return;
}
@@ -1700,14 +1700,14 @@ static string* doProcessUDPQuestion(const std::string& question, const ComboAddr
}
catch(const std::exception& e) {
if(g_logCommonErrors)
- L<<Logger::Warning<<"Error parsing a query packet qname='"<<qname<<"' for tag determination, setting tag=0: "<<e.what()<<endl;
+ g_log<<Logger::Warning<<"Error parsing a query packet qname='"<<qname<<"' for tag determination, setting tag=0: "<<e.what()<<endl;
}
}
}
catch(const std::exception& e)
{
if(g_logCommonErrors)
- L<<Logger::Warning<<"Error parsing a query packet for tag determination, setting tag=0: "<<e.what()<<endl;
+ g_log<<Logger::Warning<<"Error parsing a query packet for tag determination, setting tag=0: "<<e.what()<<endl;
}
}
@@ -1745,7 +1745,7 @@ static string* doProcessUDPQuestion(const std::string& question, const ComboAddr
}
#endif /* HAVE_PROTOBUF */
if(!g_quiet)
- L<<Logger::Notice<<t_id<< " question answered from packet cache tag="<<ctag<<" from "<<fromaddr.toString()<<endl;
+ g_log<<Logger::Notice<<t_id<< " question answered from packet cache tag="<<ctag<<" from "<<fromaddr.toString()<<endl;
g_stats.packetCacheHits++;
SyncRes::s_queries++;
@@ -1760,7 +1760,7 @@ static string* doProcessUDPQuestion(const std::string& question, const ComboAddr
addCMsgSrcAddr(&msgh, cbuf, &destaddr, 0);
}
if(sendmsg(fd, &msgh, 0) < 0 && g_logCommonErrors)
- L<<Logger::Warning<<"Sending UDP reply to client "<<fromaddr.toStringWithPort()<<" failed with: "<<strerror(errno)<<endl;
+ g_log<<Logger::Warning<<"Sending UDP reply to client "<<fromaddr.toStringWithPort()<<" failed with: "<<strerror(errno)<<endl;
if(response.length() >= sizeof(struct dnsheader)) {
struct dnsheader tmpdh;
@@ -1773,14 +1773,14 @@ static string* doProcessUDPQuestion(const std::string& question, const ComboAddr
}
}
catch(std::exception& e) {
- L<<Logger::Error<<"Error processing or aging answer packet: "<<e.what()<<endl;
+ g_log<<Logger::Error<<"Error processing or aging answer packet: "<<e.what()<<endl;
return 0;
}
if(t_pdl) {
if(t_pdl->ipfilter(fromaddr, destaddr, *dh)) {
if(!g_quiet)
- L<<Logger::Notice<<t_id<<" ["<<MT->getTid()<<"/"<<MT->numProcesses()<<"] DROPPED question from "<<fromaddr.toStringWithPort()<<" based on policy"<<endl;
+ g_log<<Logger::Notice<<t_id<<" ["<<MT->getTid()<<"/"<<MT->numProcesses()<<"] DROPPED question from "<<fromaddr.toStringWithPort()<<" based on policy"<<endl;
g_stats.policyDrops++;
return 0;
}
@@ -1788,7 +1788,7 @@ static string* doProcessUDPQuestion(const std::string& question, const ComboAddr
if(MT->numProcesses() > g_maxMThreads) {
if(!g_quiet)
- L<<Logger::Notice<<t_id<<" ["<<MT->getTid()<<"/"<<MT->numProcesses()<<"] DROPPED question from "<<fromaddr.toStringWithPort()<<", over capacity"<<endl;
+ g_log<<Logger::Notice<<t_id<<" ["<<MT->getTid()<<"/"<<MT->numProcesses()<<"] DROPPED question from "<<fromaddr.toStringWithPort()<<", over capacity"<<endl;
g_stats.overCapacityDrops++;
return 0;
@@ -1845,7 +1845,7 @@ static void handleNewUDPQuestion(int fd, FDMultiplexer::funcparam_t& var)
if(t_allowFrom && !t_allowFrom->match(&fromaddr)) {
if(!g_quiet)
- L<<Logger::Error<<"["<<MT->getTid()<<"] dropping UDP query from "<<fromaddr.toString()<<", address not matched by allow-from"<<endl;
+ g_log<<Logger::Error<<"["<<MT->getTid()<<"] dropping UDP query from "<<fromaddr.toString()<<", address not matched by allow-from"<<endl;
g_stats.unauthorizedUDP++;
return;
@@ -1853,7 +1853,7 @@ static void handleNewUDPQuestion(int fd, FDMultiplexer::funcparam_t& var)
BOOST_STATIC_ASSERT(offsetof(sockaddr_in, sin_port) == offsetof(sockaddr_in6, sin6_port));
if(!fromaddr.sin4.sin_port) { // also works for IPv6
if(!g_quiet)
- L<<Logger::Error<<"["<<MT->getTid()<<"] dropping UDP query from "<<fromaddr.toStringWithPort()<<", can't deal with port 0"<<endl;
+ g_log<<Logger::Error<<"["<<MT->getTid()<<"] dropping UDP query from "<<fromaddr.toStringWithPort()<<", can't deal with port 0"<<endl;
g_stats.clientParseError++; // not quite the best place to put it, but needs to go somewhere
return;
@@ -1864,12 +1864,12 @@ static void handleNewUDPQuestion(int fd, FDMultiplexer::funcparam_t& var)
if(dh->qr) {
g_stats.ignoredCount++;
if(g_logCommonErrors)
- L<<Logger::Error<<"Ignoring answer from "<<fromaddr.toString()<<" on server socket!"<<endl;
+ g_log<<Logger::Error<<"Ignoring answer from "<<fromaddr.toString()<<" on server socket!"<<endl;
}
else if(dh->opcode) {
g_stats.ignoredCount++;
if(g_logCommonErrors)
- L<<Logger::Error<<"Ignoring non-query opcode "<<dh->opcode<<" from "<<fromaddr.toString()<<" on server socket!"<<endl;
+ g_log<<Logger::Error<<"Ignoring non-query opcode "<<dh->opcode<<" from "<<fromaddr.toString()<<" on server socket!"<<endl;
}
else {
string question(data, (size_t)len);
@@ -1902,12 +1902,12 @@ static void handleNewUDPQuestion(int fd, FDMultiplexer::funcparam_t& var)
catch(MOADNSException& mde) {
g_stats.clientParseError++;
if(g_logCommonErrors)
- L<<Logger::Error<<"Unable to parse packet from remote UDP client "<<fromaddr.toString() <<": "<<mde.what()<<endl;
+ g_log<<Logger::Error<<"Unable to parse packet from remote UDP client "<<fromaddr.toString() <<": "<<mde.what()<<endl;
}
catch(std::runtime_error& e) {
g_stats.clientParseError++;
if(g_logCommonErrors)
- L<<Logger::Error<<"Unable to parse packet from remote UDP client "<<fromaddr.toString() <<": "<<e.what()<<endl;
+ g_log<<Logger::Error<<"Unable to parse packet from remote UDP client "<<fromaddr.toString() <<": "<<e.what()<<endl;
}
}
else {
@@ -1951,17 +1951,17 @@ static void makeTCPServerSockets(unsigned int threadId)
int tmp=1;
if(setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &tmp, sizeof tmp)<0) {
- L<<Logger::Error<<"Setsockopt failed for TCP listening socket"<<endl;
+ g_log<<Logger::Error<<"Setsockopt failed for TCP listening socket"<<endl;
exit(1);
}
if(sin.sin6.sin6_family == AF_INET6 && setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &tmp, sizeof(tmp)) < 0) {
- L<<Logger::Error<<"Failed to set IPv6 socket to IPv6 only, continuing anyhow: "<<strerror(errno)<<endl;
+ g_log<<Logger::Error<<"Failed to set IPv6 socket to IPv6 only, continuing anyhow: "<<strerror(errno)<<endl;
}
#ifdef TCP_DEFER_ACCEPT
if(setsockopt(fd, SOL_TCP, TCP_DEFER_ACCEPT, &tmp, sizeof tmp) >= 0) {
if(i==locals.begin())
- L<<Logger::Error<<"Enabled TCP data-ready filter for (slight) DoS protection"<<endl;
+ g_log<<Logger::Error<<"Enabled TCP data-ready filter for (slight) DoS protection"<<endl;
}
#endif
@@ -1979,10 +1979,10 @@ static void makeTCPServerSockets(unsigned int threadId)
#ifdef TCP_FASTOPEN
int fastOpenQueueSize = ::arg().asNum("tcp-fast-open");
if (setsockopt(fd, IPPROTO_TCP, TCP_FASTOPEN, &fastOpenQueueSize, sizeof fastOpenQueueSize) < 0) {
- L<<Logger::Error<<"Failed to enable TCP Fast Open for listening socket: "<<strerror(errno)<<endl;
+ g_log<<Logger::Error<<"Failed to enable TCP Fast Open for listening socket: "<<strerror(errno)<<endl;
}
#else
- L<<Logger::Warning<<"TCP Fast Open configured but not supported for listening socket"<<endl;
+ g_log<<Logger::Warning<<"TCP Fast Open configured but not supported for listening socket"<<endl;
#endif
}
@@ -1999,9 +1999,9 @@ static void makeTCPServerSockets(unsigned int threadId)
// we don't need to update g_listenSocketsAddresses since it doesn't work for TCP/IP:
// - fd is not that which we know here, but returned from accept()
if(sin.sin4.sin_family == AF_INET)
- L<<Logger::Error<<"Listening for TCP queries on "<< sin.toString() <<":"<<st.port<<endl;
+ g_log<<Logger::Error<<"Listening for TCP queries on "<< sin.toString() <<":"<<st.port<<endl;
else
- L<<Logger::Error<<"Listening for TCP queries on ["<< sin.toString() <<"]:"<<st.port<<endl;
+ g_log<<Logger::Error<<"Listening for TCP queries on ["<< sin.toString() <<"]:"<<st.port<<endl;
}
}
@@ -2034,7 +2034,7 @@ static void makeUDPServerSockets(unsigned int threadId)
throw PDNSException("Making a UDP server socket for resolver: "+netstringerror());
}
if (!setSocketTimestamps(fd))
- L<<Logger::Warning<<"Unable to enable timestamp reporting for socket"<<endl;
+ g_log<<Logger::Warning<<"Unable to enable timestamp reporting for socket"<<endl;
if(IsAnyAddress(sin)) {
if(sin.sin4.sin_family == AF_INET)
@@ -2046,7 +2046,7 @@ static void makeUDPServerSockets(unsigned int threadId)
g_fromtosockets.insert(fd);
#endif
if(sin.sin6.sin6_family == AF_INET6 && setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &one, sizeof(one)) < 0) {
- L<<Logger::Error<<"Failed to set IPv6 socket to IPv6 only, continuing anyhow: "<<strerror(errno)<<endl;
+ g_log<<Logger::Error<<"Failed to set IPv6 socket to IPv6 only, continuing anyhow: "<<strerror(errno)<<endl;
}
}
if( ::arg().mustDo("non-local-bind") )
@@ -2073,9 +2073,9 @@ static void makeUDPServerSockets(unsigned int threadId)
deferredAdds[threadId].push_back(make_pair(fd, handleNewUDPQuestion));
g_listenSocketsAddresses[fd]=sin; // this is written to only from the startup thread, not from the workers
if(sin.sin4.sin_family == AF_INET)
- L<<Logger::Error<<"Listening for UDP queries on "<< sin.toString() <<":"<<st.port<<endl;
+ g_log<<Logger::Error<<"Listening for UDP queries on "<< sin.toString() <<":"<<st.port<<endl;
else
- L<<Logger::Error<<"Listening for UDP queries on ["<< sin.toString() <<"]:"<<st.port<<endl;
+ g_log<<Logger::Error<<"Listening for UDP queries on ["<< sin.toString() <<"]:"<<st.port<<endl;
}
}
@@ -2088,7 +2088,7 @@ static void daemonize(void)
int i=open("/dev/null",O_RDWR); /* open stdin */
if(i < 0)
- L<<Logger::Critical<<"Unable to open /dev/null: "<<stringerror()<<endl;
+ g_log<<Logger::Critical<<"Unable to open /dev/null: "<<stringerror()<<endl;
else {
dup2(i,0); /* stdin */
dup2(i,1); /* stderr */
@@ -2118,35 +2118,35 @@ static void doStats(void)
uint64_t cacheMisses = broadcastAccFunction<uint64_t>(pleaseGetCacheMisses);
if(g_stats.qcounter && (cacheHits + cacheMisses) && SyncRes::s_queries && SyncRes::s_outqueries) {
- L<<Logger::Notice<<"stats: "<<g_stats.qcounter<<" questions, "<<
+ g_log<<Logger::Notice<<"stats: "<<g_stats.qcounter<<" questions, "<<
broadcastAccFunction<uint64_t>(pleaseGetCacheSize)<< " cache entries, "<<
broadcastAccFunction<uint64_t>(pleaseGetNegCacheSize)<<" negative entries, "<<
(int)((cacheHits*100.0)/(cacheHits+cacheMisses))<<"% cache hits"<<endl;
- L<<Logger::Notice<<"stats: throttle map: "
+ g_log<<Logger::Notice<<"stats: throttle map: "
<< broadcastAccFunction<uint64_t>(pleaseGetThrottleSize) <<", ns speeds: "
<< broadcastAccFunction<uint64_t>(pleaseGetNsSpeedsSize)<<endl;
- L<<Logger::Notice<<"stats: outpacket/query ratio "<<(int)(SyncRes::s_outqueries*100.0/SyncRes::s_queries)<<"%";
- L<<Logger::Notice<<", "<<(int)(SyncRes::s_throttledqueries*100.0/(SyncRes::s_outqueries+SyncRes::s_throttledqueries))<<"% throttled, "
+ g_log<<Logger::Notice<<"stats: outpacket/query ratio "<<(int)(SyncRes::s_outqueries*100.0/SyncRes::s_queries)<<"%";
+ g_log<<Logger::Notice<<", "<<(int)(SyncRes::s_throttledqueries*100.0/(SyncRes::s_outqueries+SyncRes::s_throttledqueries))<<"% throttled, "
<<SyncRes::s_nodelegated<<" no-delegation drops"<<endl;
- L<<Logger::Notice<<"stats: "<<SyncRes::s_tcpoutqueries<<" outgoing tcp connections, "<<
+ g_log<<Logger::Notice<<"stats: "<<SyncRes::s_tcpoutqueries<<" outgoing tcp connections, "<<
broadcastAccFunction<uint64_t>(pleaseGetConcurrentQueries)<<" queries running, "<<SyncRes::s_outgoingtimeouts<<" outgoing timeouts"<<endl;
- //L<<Logger::Notice<<"stats: "<<g_stats.ednsPingMatches<<" ping matches, "<<g_stats.ednsPingMismatches<<" mismatches, "<<
+ //g_log<<Logger::Notice<<"stats: "<<g_stats.ednsPingMatches<<" ping matches, "<<g_stats.ednsPingMismatches<<" mismatches, "<<
//g_stats.noPingOutQueries<<" outqueries w/o ping, "<< g_stats.noEdnsOutQueries<<" w/o EDNS"<<endl;
- L<<Logger::Notice<<"stats: " << broadcastAccFunction<uint64_t>(pleaseGetPacketCacheSize) <<
+ g_log<<Logger::Notice<<"stats: " << broadcastAccFunction<uint64_t>(pleaseGetPacketCacheSize) <<
" packet cache entries, "<<(int)(100.0*broadcastAccFunction<uint64_t>(pleaseGetPacketCacheHits)/SyncRes::s_queries) << "% packet cache hits"<<endl;
time_t now = time(0);
if(lastOutputTime && lastQueryCount && now != lastOutputTime) {
- L<<Logger::Notice<<"stats: "<< (SyncRes::s_queries - lastQueryCount) / (now - lastOutputTime) <<" qps (average over "<< (now - lastOutputTime) << " seconds)"<<endl;
+ g_log<<Logger::Notice<<"stats: "<< (SyncRes::s_queries - lastQueryCount) / (now - lastOutputTime) <<" qps (average over "<< (now - lastOutputTime) << " seconds)"<<endl;
}
lastOutputTime = now;
lastQueryCount = SyncRes::s_queries;
}
else if(statsWanted)
- L<<Logger::Notice<<"stats: no stats yet!"<<endl;
+ g_log<<Logger::Notice<<"stats: no stats yet!"<<endl;
statsWanted=false;
}
@@ -2193,19 +2193,19 @@ static void houseKeeping(void *)
}
catch(std::exception& e)
{
- L<<Logger::Error<<"Exception while performing security poll: "<<e.what()<<endl;
+ g_log<<Logger::Error<<"Exception while performing security poll: "<<e.what()<<endl;
}
catch(PDNSException& e)
{
- L<<Logger::Error<<"Exception while performing security poll: "<<e.reason<<endl;
+ g_log<<Logger::Error<<"Exception while performing security poll: "<<e.reason<<endl;
}
catch(ImmediateServFailException &e)
{
- L<<Logger::Error<<"Exception while performing security poll: "<<e.reason<<endl;
+ g_log<<Logger::Error<<"Exception while performing security poll: "<<e.reason<<endl;
}
catch(...)
{
- L<<Logger::Error<<"Exception while performing security poll"<<endl;
+ g_log<<Logger::Error<<"Exception while performing security poll"<<endl;
}
}
@@ -2215,7 +2215,7 @@ static void houseKeeping(void *)
catch(PDNSException& ae)
{
s_running=false;
- L<<Logger::Error<<"Fatal error in housekeeping thread: "<<ae.reason<<endl;
+ g_log<<Logger::Error<<"Fatal error in housekeeping thread: "<<ae.reason<<endl;
throw;
}
}
@@ -2260,7 +2260,7 @@ void broadcastFunction(const pipefunc_t& func)
/* This function might be called by the worker with t_id 0 during startup
for the initialization of ACLs and domain maps */
if (t_id != s_handlerThreadID && t_id != s_distributorThreadID) {
- L<<Logger::Error<<"broadcastFunction() has been called by a worker ("<<t_id<<")"<<endl;
+ g_log<<Logger::Error<<"broadcastFunction() has been called by a worker ("<<t_id<<")"<<endl;
exit(1);
}
@@ -2301,7 +2301,7 @@ void broadcastFunction(const pipefunc_t& func)
void distributeAsyncFunction(const string& packet, const pipefunc_t& func)
{
if (t_id != s_distributorThreadID) {
- L<<Logger::Error<<"distributeAsyncFunction() has been called by a worker ("<<t_id<<")"<<endl;
+ g_log<<Logger::Error<<"distributeAsyncFunction() has been called by a worker ("<<t_id<<")"<<endl;
exit(1);
}
@@ -2309,7 +2309,7 @@ void distributeAsyncFunction(const string& packet, const pipefunc_t& func)
unsigned int target = 1 + (hash % (g_pipes.size()-1));
if(target == static_cast<unsigned int>(s_distributorThreadID)) {
- L<<Logger::Error<<"distributeAsyncFunction() tried to assign a query to the distributor"<<endl;
+ g_log<<Logger::Error<<"distributeAsyncFunction() tried to assign a query to the distributor"<<endl;
exit(1);
}
@@ -2350,11 +2350,11 @@ static void handlePipeRequest(int fd, FDMultiplexer::funcparam_t& var)
}
catch(std::exception& e) {
if(g_logCommonErrors)
- L<<Logger::Error<<"PIPE function we executed created exception: "<<e.what()<<endl; // but what if they wanted an answer.. we send 0
+ g_log<<Logger::Error<<"PIPE function we executed created exception: "<<e.what()<<endl; // but what if they wanted an answer.. we send 0
}
catch(PDNSException& e) {
if(g_logCommonErrors)
- L<<Logger::Error<<"PIPE function we executed created PDNS exception: "<<e.reason<<endl; // but what if they wanted an answer.. we send 0
+ g_log<<Logger::Error<<"PIPE function we executed created PDNS exception: "<<e.reason<<endl; // but what if they wanted an answer.. we send 0
}
if(tmsg->wantAnswer) {
if(write(g_pipes[t_id].writeFromThread, &resp, sizeof(resp)) != sizeof(resp)) {
@@ -2396,7 +2396,7 @@ vector<pair<DNSName, uint16_t> >& operator+=(vector<pair<DNSName, uint16_t> >&a,
template<class T> T broadcastAccFunction(const boost::function<T*()>& func)
{
if (t_id != s_handlerThreadID) {
- L<<Logger::Error<<"broadcastFunction has been called by a worker ("<<t_id<<")"<<endl;
+ g_log<<Logger::Error<<"broadcastFunction has been called by a worker ("<<t_id<<")"<<endl;
exit(1);
}
@@ -2450,10 +2450,10 @@ static void handleRCC(int fd, FDMultiplexer::funcparam_t& var)
command();
}
catch(std::exception& e) {
- L<<Logger::Error<<"Error dealing with control socket request: "<<e.what()<<endl;
+ g_log<<Logger::Error<<"Error dealing with control socket request: "<<e.what()<<endl;
}
catch(PDNSException& ae) {
- L<<Logger::Error<<"Error dealing with control socket request: "<<ae.reason<<endl;
+ g_log<<Logger::Error<<"Error dealing with control socket request: "<<ae.reason<<endl;
}
}
@@ -2540,7 +2540,7 @@ static void handleUDPServerResponse(int fd, FDMultiplexer::funcparam_t& var)
else {
g_stats.serverParseError++;
if(g_logCommonErrors)
- L<<Logger::Error<<"Unable to parse packet from remote UDP server "<< fromaddr.toString() <<
+ g_log<<Logger::Error<<"Unable to parse packet from remote UDP server "<< fromaddr.toString() <<
": packet smaller than DNS header"<<endl;
}
@@ -2564,7 +2564,7 @@ static void handleUDPServerResponse(int fd, FDMultiplexer::funcparam_t& var)
pident.fd=fd;
if(!dh.qr && g_logCommonErrors) {
- L<<Logger::Notice<<"Not taking data from question on outgoing socket from "<< fromaddr.toStringWithPort() <<endl;
+ g_log<<Logger::Notice<<"Not taking data from question on outgoing socket from "<< fromaddr.toStringWithPort() <<endl;
}
if(!dh.qdcount || // UPC, Nominum, very old BIND on FormErr, NSD
@@ -2579,7 +2579,7 @@ static void handleUDPServerResponse(int fd, FDMultiplexer::funcparam_t& var)
}
catch(std::exception& e) {
g_stats.serverParseError++; // won't be fed to lwres.cc, so we have to increment
- L<<Logger::Warning<<"Error in packet from remote nameserver "<< fromaddr.toStringWithPort() << ": "<<e.what() << endl;
+ g_log<<Logger::Warning<<"Error in packet from remote nameserver "<< fromaddr.toStringWithPort() << ": "<<e.what() << endl;
return;
}
}
@@ -2612,7 +2612,7 @@ retryWithName:
}
g_stats.unexpectedCount++; // if we made it here, it really is an unexpected answer
if(g_logCommonErrors) {
- L<<Logger::Warning<<"Discarding unexpected packet from "<<fromaddr.toStringWithPort()<<": "<< (pident.domain.empty() ? "<empty>" : pident.domain.toString())<<", "<<pident.type<<", "<<MT->d_waiters.size()<<" waiters"<<endl;
+ g_log<<Logger::Warning<<"Discarding unexpected packet from "<<fromaddr.toStringWithPort()<<": "<< (pident.domain.empty() ? "<empty>" : pident.domain.toString())<<", "<<pident.type<<", "<<MT->d_waiters.size()<<" waiters"<<endl;
}
}
else if(fd >= 0) {
@@ -2629,13 +2629,13 @@ FDMultiplexer* getMultiplexer()
return ret;
}
catch(FDMultiplexerException &fe) {
- L<<Logger::Error<<"Non-fatal error initializing possible multiplexer ("<<fe.what()<<"), falling back"<<endl;
+ g_log<<Logger::Error<<"Non-fatal error initializing possible multiplexer ("<<fe.what()<<"), falling back"<<endl;
}
catch(...) {
- L<<Logger::Error<<"Non-fatal error initializing possible multiplexer"<<endl;
+ g_log<<Logger::Error<<"Non-fatal error initializing possible multiplexer"<<endl;
}
}
- L<<Logger::Error<<"No working multiplexer found!"<<endl;
+ g_log<<Logger::Error<<"No working multiplexer found!"<<endl;
exit(1);
}
@@ -2646,7 +2646,7 @@ static string* doReloadLuaScript()
try {
if(fname.empty()) {
t_pdl.reset();
- L<<Logger::Error<<t_id<<" Unloaded current lua script"<<endl;
+ g_log<<Logger::Error<<t_id<<" Unloaded current lua script"<<endl;
return new string("unloaded\n");
}
else {
@@ -2654,11 +2654,11 @@ static string* doReloadLuaScript()
}
}
catch(std::exception& e) {
- L<<Logger::Error<<t_id<<" Retaining current script, error from '"<<fname<<"': "<< e.what() <<endl;
+ g_log<<Logger::Error<<t_id<<" Retaining current script, error from '"<<fname<<"': "<< e.what() <<endl;
return new string("retaining current script, error from '"+fname+"': "+e.what()+"\n");
}
- L<<Logger::Warning<<t_id<<" (Re)loaded lua script from '"<<fname<<"'"<<endl;
+ g_log<<Logger::Warning<<t_id<<" (Re)loaded lua script from '"<<fname<<"'"<<endl;
return new string("(re)loaded '"+fname+"'\n");
}
@@ -2699,7 +2699,7 @@ static void checkLinuxIPv6Limits()
if(readFileIfThere("/proc/sys/net/ipv6/route/max_size", &line)) {
int lim=std::stoi(line);
if(lim < 16384) {
- L<<Logger::Error<<"If using IPv6, please raise sysctl net.ipv6.route.max_size, currently set to "<<lim<<" which is < 16384"<<endl;
+ g_log<<Logger::Error<<"If using IPv6, please raise sysctl net.ipv6.route.max_size, currently set to "<<lim<<" which is < 16384"<<endl;
}
}
#endif
@@ -2713,11 +2713,11 @@ static void checkOrFixFDS()
unsigned int hardlimit= getFilenumLimit(true);
if(hardlimit >= wantFDs) {
setFilenumLimit(wantFDs);
- L<<Logger::Warning<<"Raised soft limit on number of filedescriptors to "<<wantFDs<<" to match max-mthreads and threads settings"<<endl;
+ g_log<<Logger::Warning<<"Raised soft limit on number of filedescriptors to "<<wantFDs<<" to match max-mthreads and threads settings"<<endl;
}
else {
int newval = (hardlimit - 25) / g_numWorkerThreads;
- L<<Logger::Warning<<"Insufficient number of filedescriptors available for max-mthreads*threads setting! ("<<hardlimit<<" < "<<wantFDs<<"), reducing max-mthreads to "<<newval<<endl;
+ g_log<<Logger::Warning<<"Insufficient number of filedescriptors available for max-mthreads*threads setting! ("<<hardlimit<<" < "<<wantFDs<<"), reducing max-mthreads to "<<newval<<endl;
g_maxMThreads = newval;
setFilenumLimit(hardlimit);
}
@@ -2788,24 +2788,24 @@ void parseACLs()
allowFrom->addMask(line);
}
- L<<Logger::Warning<<"Done parsing " << allowFrom->size() <<" allow-from ranges from file '"<<::arg()["allow-from-file"]<<"' - overriding 'allow-from' setting"<<endl;
+ g_log<<Logger::Warning<<"Done parsing " << allowFrom->size() <<" allow-from ranges from file '"<<::arg()["allow-from-file"]<<"' - overriding 'allow-from' setting"<<endl;
}
else if(!::arg()["allow-from"].empty()) {
vector<string> ips;
stringtok(ips, ::arg()["allow-from"], ", ");
- L<<Logger::Warning<<"Only allowing queries from: ";
+ g_log<<Logger::Warning<<"Only allowing queries from: ";
for(vector<string>::const_iterator i = ips.begin(); i!= ips.end(); ++i) {
allowFrom->addMask(*i);
if(i!=ips.begin())
- L<<Logger::Warning<<", ";
- L<<Logger::Warning<<*i;
+ g_log<<Logger::Warning<<", ";
+ g_log<<Logger::Warning<<*i;
}
- L<<Logger::Warning<<endl;
+ g_log<<Logger::Warning<<endl;
}
else {
if(::arg()["local-address"]!="127.0.0.1" && ::arg().asNum("local-port")==53)
- L<<Logger::Error<<"WARNING: Allowing queries from all IP addresses - this can be a security risk!"<<endl;
+ g_log<<Logger::Error<<"WARNING: Allowing queries from all IP addresses - this can be a security risk!"<<endl;
allowFrom = nullptr;
}
@@ -2833,7 +2833,7 @@ static std::map<unsigned int, std::set<int> > parseCPUMap()
const std::string value = ::arg()["cpu-map"];
if (!value.empty() && !isSettingThreadCPUAffinitySupported()) {
- L<<Logger::Warning<<"CPU mapping requested but not supported, skipping"<<endl;
+ g_log<<Logger::Warning<<"CPU mapping requested but not supported, skipping"<<endl;
return result;
}
@@ -2862,7 +2862,7 @@ static std::map<unsigned int, std::set<int> > parseCPUMap()
}
}
catch(const std::exception& e) {
- L<<Logger::Error<<"Error parsing cpu-map entry '"<<part<<"': "<<e.what()<<endl;
+ g_log<<Logger::Error<<"Error parsing cpu-map entry '"<<part<<"': "<<e.what()<<endl;
}
}
@@ -2875,34 +2875,34 @@ static void setCPUMap(const std::map<unsigned int, std::set<int> >& cpusMap, uns
if (cpuMapping != cpusMap.cend()) {
int rc = mapThreadToCPUList(tid, cpuMapping->second);
if (rc == 0) {
- L<<Logger::Info<<"CPU affinity for worker "<<n<<" has been set to CPU map:";
+ g_log<<Logger::Info<<"CPU affinity for worker "<<n<<" has been set to CPU map:";
for (const auto cpu : cpuMapping->second) {
- L<<Logger::Info<<" "<<cpu;
+ g_log<<Logger::Info<<" "<<cpu;
}
- L<<Logger::Info<<endl;
+ g_log<<Logger::Info<<endl;
}
else {
- L<<Logger::Warning<<"Error setting CPU affinity for worker "<<n<<" to CPU map:";
+ g_log<<Logger::Warning<<"Error setting CPU affinity for worker "<<n<<" to CPU map:";
for (const auto cpu : cpuMapping->second) {
- L<<Logger::Info<<" "<<cpu;
+ g_log<<Logger::Info<<" "<<cpu;
}
- L<<Logger::Info<<strerror(rc)<<endl;
+ g_log<<Logger::Info<<strerror(rc)<<endl;
}
}
}
static int serviceMain(int argc, char*argv[])
{
- L.setName(s_programname);
- L.disableSyslog(::arg().mustDo("disable-syslog"));
- L.setTimestamps(::arg().mustDo("log-timestamp"));
+ g_log.setName(s_programname);
+ g_log.disableSyslog(::arg().mustDo("disable-syslog"));
+ g_log.setTimestamps(::arg().mustDo("log-timestamp"));
if(!::arg()["logging-facility"].empty()) {
int val=logFacilityToLOG(::arg().asNum("logging-facility") );
if(val >= 0)
theL().setFacility(val);
else
- L<<Logger::Error<<"Unknown logging facility "<<::arg().asNum("logging-facility") <<endl;
+ g_log<<Logger::Error<<"Unknown logging facility "<<::arg().asNum("logging-facility") <<endl;
}
showProductVersion();
@@ -2915,7 +2915,7 @@ static int serviceMain(int argc, char*argv[])
vector<string> addrs;
if(!::arg()["query-local-address6"].empty()) {
SyncRes::s_doIPv6=true;
- L<<Logger::Warning<<"Enabling IPv6 transport for outgoing queries"<<endl;
+ g_log<<Logger::Warning<<"Enabling IPv6 transport for outgoing queries"<<endl;
stringtok(addrs, ::arg()["query-local-address6"], ", ;");
for(const string& addr : addrs) {
@@ -2923,7 +2923,7 @@ static int serviceMain(int argc, char*argv[])
}
}
else {
- L<<Logger::Warning<<"NOT using IPv6 for outgoing queries - set 'query-local-address6=::' to enable"<<endl;
+ g_log<<Logger::Warning<<"NOT using IPv6 for outgoing queries - set 'query-local-address6=::' to enable"<<endl;
}
addrs.clear();
stringtok(addrs, ::arg()["query-local-address"], ", ;");
@@ -2932,7 +2932,7 @@ static int serviceMain(int argc, char*argv[])
}
}
catch(std::exception& e) {
- L<<Logger::Error<<"Assigning local query addresses: "<<e.what();
+ g_log<<Logger::Error<<"Assigning local query addresses: "<<e.what();
exit(99);
}
@@ -2948,7 +2948,7 @@ static int serviceMain(int argc, char*argv[])
else if(::arg()["dnssec"]=="log-fail")
g_dnssecmode=DNSSECMode::ValidateForLog;
else {
- L<<Logger::Error<<"Unknown DNSSEC mode "<<::arg()["dnssec"]<<endl;
+ g_log<<Logger::Error<<"Unknown DNSSEC mode "<<::arg()["dnssec"]<<endl;
exit(1);
}
@@ -2962,7 +2962,7 @@ static int serviceMain(int argc, char*argv[])
loadRecursorLuaConfig(::arg()["lua-config-file"], ::arg().mustDo("daemon"));
}
catch (PDNSException &e) {
- L<<Logger::Error<<"Cannot load Lua configuration: "<<e.reason<<endl;
+ g_log<<Logger::Error<<"Cannot load Lua configuration: "<<e.reason<<endl;
exit(1);
}
@@ -2975,21 +2975,21 @@ static int serviceMain(int argc, char*argv[])
ips.push_back("0.0.0.0");
ips.push_back("::");
- L<<Logger::Warning<<"Will not send queries to: ";
+ g_log<<Logger::Warning<<"Will not send queries to: ";
for(vector<string>::const_iterator i = ips.begin(); i!= ips.end(); ++i) {
SyncRes::addDontQuery(*i);
if(i!=ips.begin())
- L<<Logger::Warning<<", ";
- L<<Logger::Warning<<*i;
+ g_log<<Logger::Warning<<", ";
+ g_log<<Logger::Warning<<*i;
}
- L<<Logger::Warning<<endl;
+ g_log<<Logger::Warning<<endl;
}
g_quiet=::arg().mustDo("quiet");
g_weDistributeQueries = ::arg().mustDo("pdns-distributes-queries");
if(g_weDistributeQueries) {
- L<<Logger::Warning<<"PowerDNS Recursor itself will distribute queries over threads"<<endl;
+ g_log<<Logger::Warning<<"PowerDNS Recursor itself will distribute queries over threads"<<endl;
}
setupDelegationOnly();
@@ -3074,7 +3074,7 @@ static int serviceMain(int argc, char*argv[])
g_numWorkerThreads = ::arg().asNum("threads");
if (g_numWorkerThreads < 1) {
- L<<Logger::Warning<<"Asked to run with 0 threads, raising to 1 instead"<<endl;
+ g_log<<Logger::Warning<<"Asked to run with 0 threads, raising to 1 instead"<<endl;
g_numWorkerThreads = 1;
}
@@ -3112,8 +3112,8 @@ static int serviceMain(int argc, char*argv[])
}
if(::arg().mustDo("daemon")) {
- L<<Logger::Warning<<"Calling daemonize, going to background"<<endl;
- L.toConsole(Logger::Critical);
+ g_log<<Logger::Warning<<"Calling daemonize, going to background"<<endl;
+ g_log.toConsole(Logger::Critical);
daemonize();
loadRecursorLuaConfig(::arg()["lua-config-file"], false);
}
@@ -3125,7 +3125,7 @@ static int serviceMain(int argc, char*argv[])
#ifdef HAVE_LIBSODIUM
if (sodium_init() == -1) {
- L<<Logger::Error<<"Unable to initialize sodium crypto library"<<endl;
+ g_log<<Logger::Error<<"Unable to initialize sodium crypto library"<<endl;
exit(99);
}
#endif
@@ -3147,16 +3147,16 @@ static int serviceMain(int argc, char*argv[])
char *ns;
ns = getenv("NOTIFY_SOCKET");
if (ns != nullptr) {
- L<<Logger::Error<<"Unable to chroot when running from systemd. Please disable chroot= or set the 'Type' for this service to 'simple'"<<endl;
+ g_log<<Logger::Error<<"Unable to chroot when running from systemd. Please disable chroot= or set the 'Type' for this service to 'simple'"<<endl;
exit(1);
}
#endif
if (chroot(::arg()["chroot"].c_str())<0 || chdir("/") < 0) {
- L<<Logger::Error<<"Unable to chroot to '"+::arg()["chroot"]+"': "<<strerror (errno)<<", exiting"<<endl;
+ g_log<<Logger::Error<<"Unable to chroot to '"+::arg()["chroot"]+"': "<<strerror (errno)<<", exiting"<<endl;
exit(1);
}
else
- L<<Logger::Error<<"Chrooted to '"<<::arg()["chroot"]<<"'"<<endl;
+ g_log<<Logger::Error<<"Chrooted to '"<<::arg()["chroot"]<<"'"<<endl;
}
s_pidfname=::arg()["socket-dir"]+"/"+s_programname+".pid";
@@ -3186,7 +3186,7 @@ static int serviceMain(int argc, char*argv[])
std::vector<std::thread> workers(g_numThreads);
if(g_numThreads == 1) {
- L<<Logger::Warning<<"Operating unthreaded"<<endl;
+ g_log<<Logger::Warning<<"Operating unthreaded"<<endl;
#ifdef HAVE_SYSTEMD
sd_notify(0, "READY=1");
#endif
@@ -3194,7 +3194,7 @@ static int serviceMain(int argc, char*argv[])
recursorThread(0, true);
}
else {
- L<<Logger::Warning<<"Launching "<< g_numThreads <<" threads"<<endl;
+ g_log<<Logger::Warning<<"Launching "<< g_numThreads <<" threads"<<endl;
for(unsigned int n=0; n < g_numThreads; ++n) {
workers[n] = std::thread(recursorThread, n, true);
@@ -3224,16 +3224,16 @@ try
#ifdef HAVE_PROTOBUF
t_uuidGenerator = std::unique_ptr<boost::uuids::random_generator>(new boost::uuids::random_generator());
#endif
- L<<Logger::Warning<<"Done priming cache with root hints"<<endl;
+ g_log<<Logger::Warning<<"Done priming cache with root hints"<<endl;
try {
if(!::arg()["lua-dns-script"].empty()) {
t_pdl = std::make_shared<RecursorLua4>(::arg()["lua-dns-script"]);
- L<<Logger::Warning<<"Loaded 'lua' script from '"<<::arg()["lua-dns-script"]<<"'"<<endl;
+ g_log<<Logger::Warning<<"Loaded 'lua' script from '"<<::arg()["lua-dns-script"]<<"'"<<endl;
}
}
catch(std::exception &e) {
- L<<Logger::Error<<"Failed to load 'lua' script from '"<<::arg()["lua-dns-script"]<<"': "<<e.what()<<endl;
+ g_log<<Logger::Error<<"Failed to load 'lua' script from '"<<::arg()["lua-dns-script"]<<"': "<<e.what()<<endl;
_exit(99);
}
@@ -3263,16 +3263,16 @@ try
if(!worker) {
if(::arg().mustDo("webserver")) {
- L<<Logger::Warning << "Enabling web server" << endl;
+ g_log<<Logger::Warning << "Enabling web server" << endl;
try {
new RecursorWebServer(t_fdm);
}
catch(PDNSException &e) {
- L<<Logger::Error<<"Exception: "<<e.reason<<endl;
+ g_log<<Logger::Error<<"Exception: "<<e.reason<<endl;
exit(99);
}
}
- L<<Logger::Error<<"Enabled '"<< t_fdm->getName() << "' multiplexer"<<endl;
+ g_log<<Logger::Error<<"Enabled '"<< t_fdm->getName() << "' multiplexer"<<endl;
}
else {
t_fdm->addReadFD(g_pipes[t_id].readToThread, handlePipeRequest);
@@ -3320,7 +3320,7 @@ try
for(expired_t::iterator i=expired.begin() ; i != expired.end(); ++i) {
shared_ptr<TCPConnection> conn=any_cast<shared_ptr<TCPConnection> >(i->second);
if(g_logCommonErrors)
- L<<Logger::Warning<<"Timeout from remote TCP client "<< conn->d_remote.toString() <<endl;
+ g_log<<Logger::Warning<<"Timeout from remote TCP client "<< conn->d_remote.toString() <<endl;
t_fdm->removeReadFD(i->first);
}
}
@@ -3363,15 +3363,15 @@ try
}
}
catch(PDNSException &ae) {
- L<<Logger::Error<<"Exception: "<<ae.reason<<endl;
+ g_log<<Logger::Error<<"Exception: "<<ae.reason<<endl;
return 0;
}
catch(std::exception &e) {
- L<<Logger::Error<<"STL Exception: "<<e.what()<<endl;
+ g_log<<Logger::Error<<"STL Exception: "<<e.what()<<endl;
return 0;
}
catch(...) {
- L<<Logger::Error<<"any other exception in main: "<<endl;
+ g_log<<Logger::Error<<"any other exception in main: "<<endl;
return 0;
}
@@ -3505,7 +3505,7 @@ int main(int argc, char **argv)
::arg().setCmd("help","Provide a helpful message");
::arg().setCmd("version","Print version string");
::arg().setCmd("config","Output blank configuration");
- L.toConsole(Logger::Info);
+ g_log.toConsole(Logger::Info);
::arg().laxParse(argc,argv); // do a lax parse
string configname=::arg()["config-dir"]+"/recursor.conf";
@@ -3521,12 +3521,12 @@ int main(int argc, char **argv)
}
if(!::arg().file(configname.c_str()))
- L<<Logger::Warning<<"Unable to parse configuration file '"<<configname<<"'"<<endl;
+ g_log<<Logger::Warning<<"Unable to parse configuration file '"<<configname<<"'"<<endl;
::arg().parse(argc,argv);
if( !::arg()["chroot"].empty() && !::arg()["api-config-dir"].empty() && !::arg().mustDo("api-readonly") ) {
- L<<Logger::Error<<"Using chroot and a writable API is not possible"<<endl;
+ g_log<<Logger::Error<<"Using chroot and a writable API is not possible"<<endl;
exit(EXIT_FAILURE);
}
@@ -3560,21 +3560,21 @@ int main(int argc, char **argv)
if(!g_quiet && logUrgency < Logger::Info) { // Logger::Info=6, Logger::Debug=7
logUrgency = Logger::Info; // if you do --quiet=no, you need Info to also see the query log
}
- L.setLoglevel(logUrgency);
- L.toConsole(logUrgency);
+ g_log.setLoglevel(logUrgency);
+ g_log.toConsole(logUrgency);
serviceMain(argc, argv);
}
catch(PDNSException &ae) {
- L<<Logger::Error<<"Exception: "<<ae.reason<<endl;
+ g_log<<Logger::Error<<"Exception: "<<ae.reason<<endl;
ret=EXIT_FAILURE;
}
catch(std::exception &e) {
- L<<Logger::Error<<"STL Exception: "<<e.what()<<endl;
+ g_log<<Logger::Error<<"STL Exception: "<<e.what()<<endl;
ret=EXIT_FAILURE;
}
catch(...) {
- L<<Logger::Error<<"any other exception in main: "<<endl;
+ g_log<<Logger::Error<<"any other exception in main: "<<endl;
ret=EXIT_FAILURE;
}
diff --git a/randomhelper.cc b/randomhelper.cc
index 8d8b2db..97f0911 100644
--- a/randomhelper.cc
+++ b/randomhelper.cc
@@ -11,11 +11,11 @@
void seedRandom(const string& source)
{
- L<<Logger::Warning<<"Reading random entropy from '"<<source<<"'"<<endl;
+ g_log<<Logger::Warning<<"Reading random entropy from '"<<source<<"'"<<endl;
int fd=open(source.c_str(), O_RDONLY);
if(fd < 0) {
- L<<Logger::Error<<"Unable to open source of random '"<<source<<"': "<<stringerror()<<endl;
+ g_log<<Logger::Error<<"Unable to open source of random '"<<source<<"': "<<stringerror()<<endl;
exit(EXIT_FAILURE);
}
char seed[16];
@@ -24,12 +24,12 @@ void seedRandom(const string& source)
while(pos!=sizeof(seed)) {
ret = read(fd, seed+pos, sizeof(seed)-pos);
if(ret < 0) {
- L<<Logger::Error<<"Unable to read random seed from "<<source<<": "<<stringerror()<<endl;
+ g_log<<Logger::Error<<"Unable to read random seed from "<<source<<": "<<stringerror()<<endl;
close(fd);
exit(EXIT_FAILURE);
}
if(!ret) {
- L<<Logger::Error<<"Unable to read random seed from "<<source<<": end of file"<<endl;
+ g_log<<Logger::Error<<"Unable to read random seed from "<<source<<": end of file"<<endl;
close(fd);
exit(EXIT_FAILURE);
}
diff --git a/rec-carbon.cc b/rec-carbon.cc
index f8098ed..797d92b 100644
--- a/rec-carbon.cc
+++ b/rec-carbon.cc
@@ -60,20 +60,20 @@ try
int ret=asendtcp(msg, &s); // this will actually do the right thing waiting on the connect
if(ret < 0)
- L<<Logger::Warning<<"Error writing carbon data to "<<remote.toStringWithPort()<<": "<<strerror(errno)<<endl;
+ g_log<<Logger::Warning<<"Error writing carbon data to "<<remote.toStringWithPort()<<": "<<strerror(errno)<<endl;
if(ret==0)
- L<<Logger::Warning<<"Timeout connecting/writing carbon data to "<<remote.toStringWithPort()<<endl;
+ g_log<<Logger::Warning<<"Timeout connecting/writing carbon data to "<<remote.toStringWithPort()<<endl;
}
}
catch(PDNSException& e)
{
- L<<Logger::Error<<"Error in carbon thread: "<<e.reason<<endl;
+ g_log<<Logger::Error<<"Error in carbon thread: "<<e.reason<<endl;
}
catch(std::exception& e)
{
- L<<Logger::Error<<"Error in carbon thread: "<<e.what()<<endl;
+ g_log<<Logger::Error<<"Error in carbon thread: "<<e.what()<<endl;
}
catch(...)
{
- L<<Logger::Error<<"Unknown error in carbon thread"<<endl;
+ g_log<<Logger::Error<<"Unknown error in carbon thread"<<endl;
}
diff --git a/rec-lua-conf.cc b/rec-lua-conf.cc
index e68836f..a3be927 100644
--- a/rec-lua-conf.cc
+++ b/rec-lua-conf.cc
@@ -327,11 +327,11 @@ void loadRecursorLuaConfig(const std::string& fname, bool checkOnly)
t.detach();
}
catch(const std::exception& e) {
- L<<Logger::Error<<"Problem starting RPZIXFRTracker thread: "<<e.what()<<endl;
+ g_log<<Logger::Error<<"Problem starting RPZIXFRTracker thread: "<<e.what()<<endl;
exit(1); // FIXME proper exit code?
}
catch(const PDNSException& e) {
- L<<Logger::Error<<"Problem starting RPZIXFRTracker thread: "<<e.reason<<endl;
+ g_log<<Logger::Error<<"Problem starting RPZIXFRTracker thread: "<<e.reason<<endl;
exit(1); // FIXME proper exit code?
}
}
diff --git a/rec-snmp.cc b/rec-snmp.cc
index 4669755..f240550 100644
--- a/rec-snmp.cc
+++ b/rec-snmp.cc
@@ -145,12 +145,12 @@ static int handleCounter64Stats(netsnmp_mib_handler* handler,
static void registerCounter64Stat(const char* name, const oid statOID[], size_t statOIDLength)
{
if (statOIDLength != OID_LENGTH(questionsOID)) {
- L<<Logger::Error<<"Invalid OID for SNMP Counter64 statistic "<<std::string(name)<<endl;
+ g_log<<Logger::Error<<"Invalid OID for SNMP Counter64 statistic "<<std::string(name)<<endl;
return;
}
if (s_statsMap.find(statOID[statOIDLength - 1]) != s_statsMap.end()) {
- L<<Logger::Error<<"OID for SNMP Counter64 statistic "<<std::string(name)<<" has already been registered"<<endl;
+ g_log<<Logger::Error<<"OID for SNMP Counter64 statistic "<<std::string(name)<<" has already been registered"<<endl;
return;
}
diff --git a/rec_channel_rec.cc b/rec_channel_rec.cc
index 17dddd0..9b9beeb 100644
--- a/rec_channel_rec.cc
+++ b/rec_channel_rec.cc
@@ -384,7 +384,7 @@ string doSetDnssecLogBogus(T begin, T end)
if (pdns_iequals(*begin, "on") || pdns_iequals(*begin, "yes")) {
if (!g_dnssecLogBogus) {
- L<<Logger::Warning<<"Enabling DNSSEC Bogus logging, requested via control channel"<<endl;
+ g_log<<Logger::Warning<<"Enabling DNSSEC Bogus logging, requested via control channel"<<endl;
g_dnssecLogBogus = true;
return "DNSSEC Bogus logging enabled\n";
}
@@ -393,7 +393,7 @@ string doSetDnssecLogBogus(T begin, T end)
if (pdns_iequals(*begin, "off") || pdns_iequals(*begin, "no")) {
if (g_dnssecLogBogus) {
- L<<Logger::Warning<<"Disabling DNSSEC Bogus logging, requested via control channel"<<endl;
+ g_log<<Logger::Warning<<"Disabling DNSSEC Bogus logging, requested via control channel"<<endl;
g_dnssecLogBogus = false;
return "DNSSEC Bogus logging disabled\n";
}
@@ -431,7 +431,7 @@ string doAddNTA(T begin, T end)
if (begin != end)
why += " ";
}
- L<<Logger::Warning<<"Adding Negative Trust Anchor for "<<who<<" with reason '"<<why<<"', requested via control channel"<<endl;
+ g_log<<Logger::Warning<<"Adding Negative Trust Anchor for "<<who<<" with reason '"<<why<<"', requested via control channel"<<endl;
g_luaconfs.modify([who, why](LuaConfigItems& lci) {
lci.negAnchors[who] = why;
});
@@ -449,7 +449,7 @@ string doClearNTA(T begin, T end)
return "No Negative Trust Anchor specified, doing nothing.\n";
if (begin + 1 == end && *begin == "*"){
- L<<Logger::Warning<<"Clearing all Negative Trust Anchors, requested via control channel"<<endl;
+ g_log<<Logger::Warning<<"Clearing all Negative Trust Anchors, requested via control channel"<<endl;
g_luaconfs.modify([](LuaConfigItems& lci) {
lci.negAnchors.clear();
});
@@ -477,7 +477,7 @@ string doClearNTA(T begin, T end)
string removed("");
bool first(true);
for (auto const &entry : toRemove) {
- L<<Logger::Warning<<"Clearing Negative Trust Anchor for "<<entry<<", requested via control channel"<<endl;
+ g_log<<Logger::Warning<<"Clearing Negative Trust Anchor for "<<entry<<", requested via control channel"<<endl;
g_luaconfs.modify([entry](LuaConfigItems& lci) {
lci.negAnchors.erase(entry);
});
@@ -531,17 +531,17 @@ string doAddTA(T begin, T end)
}
try {
- L<<Logger::Warning<<"Adding Trust Anchor for "<<who<<" with data '"<<what<<"', requested via control channel";
+ g_log<<Logger::Warning<<"Adding Trust Anchor for "<<who<<" with data '"<<what<<"', requested via control channel";
g_luaconfs.modify([who, what](LuaConfigItems& lci) {
auto ds = unique_ptr<DSRecordContent>(dynamic_cast<DSRecordContent*>(DSRecordContent::make(what)));
lci.dsAnchors[who].insert(*ds);
});
broadcastAccFunction<uint64_t>(boost::bind(pleaseWipePacketCache, who, true));
- L<<Logger::Warning<<endl;
+ g_log<<Logger::Warning<<endl;
return "Added Trust Anchor for " + who.toStringRootDot() + " with data " + what + "\n";
}
catch(std::exception &e) {
- L<<Logger::Warning<<", failed: "<<e.what()<<endl;
+ g_log<<Logger::Warning<<", failed: "<<e.what()<<endl;
return "Unable to add Trust Anchor for " + who.toStringRootDot() + ": " + e.what() + "\n";
}
}
@@ -576,7 +576,7 @@ string doClearTA(T begin, T end)
string removed("");
bool first(true);
for (auto const &entry : toRemove) {
- L<<Logger::Warning<<"Removing Trust Anchor for "<<entry<<", requested via control channel"<<endl;
+ g_log<<Logger::Warning<<"Removing Trust Anchor for "<<entry<<", requested via control channel"<<endl;
g_luaconfs.modify([entry](LuaConfigItems& lci) {
lci.dsAnchors.erase(entry);
});
@@ -984,7 +984,7 @@ void registerAllStats()
static void doExitGeneric(bool nicely)
{
- L<<Logger::Error<<"Exiting on user request"<<endl;
+ g_log<<Logger::Error<<"Exiting on user request"<<endl;
extern RecursorControlChannel s_rcc;
s_rcc.~RecursorControlChannel();
@@ -1305,7 +1305,7 @@ string RecursorControlParser::getAnswer(const string& question, RecursorControlP
try {
loadRecursorLuaConfig(::arg()["lua-config-file"], false);
- L<<Logger::Warning<<"Reloaded Lua configuration file '"<<::arg()["lua-config-file"]<<"', requested via control channel"<<endl;
+ g_log<<Logger::Warning<<"Reloaded Lua configuration file '"<<::arg()["lua-config-file"]<<"', requested via control channel"<<endl;
return "Reloaded Lua configuration file '"+::arg()["lua-config-file"]+"'\n";
}
catch(std::exception& e) {
@@ -1330,7 +1330,7 @@ string RecursorControlParser::getAnswer(const string& question, RecursorControlP
if(cmd=="reload-acls") {
if(!::arg()["chroot"].empty()) {
- L<<Logger::Error<<"Unable to reload ACL when chroot()'ed, requested via control channel"<<endl;
+ g_log<<Logger::Error<<"Unable to reload ACL when chroot()'ed, requested via control channel"<<endl;
return "Unable to reload ACL when chroot()'ed, please restart\n";
}
@@ -1339,12 +1339,12 @@ string RecursorControlParser::getAnswer(const string& question, RecursorControlP
}
catch(std::exception& e)
{
- L<<Logger::Error<<"Reloading ACLs failed (Exception: "<<e.what()<<")"<<endl;
+ g_log<<Logger::Error<<"Reloading ACLs failed (Exception: "<<e.what()<<")"<<endl;
return e.what() + string("\n");
}
catch(PDNSException& ae)
{
- L<<Logger::Error<<"Reloading ACLs failed (PDNSException: "<<ae.reason<<")"<<endl;
+ g_log<<Logger::Error<<"Reloading ACLs failed (PDNSException: "<<ae.reason<<")"<<endl;
return ae.reason + string("\n");
}
return "ok\n";
@@ -1383,7 +1383,7 @@ string RecursorControlParser::getAnswer(const string& question, RecursorControlP
if(cmd=="reload-zones") {
if(!::arg()["chroot"].empty()) {
- L<<Logger::Error<<"Unable to reload zones and forwards when chroot()'ed, requested via control channel"<<endl;
+ g_log<<Logger::Error<<"Unable to reload zones and forwards when chroot()'ed, requested via control channel"<<endl;
return "Unable to reload zones and forwards when chroot()'ed, please restart\n";
}
return reloadAuthAndForwards();
diff --git a/recursor_cache.hh b/recursor_cache.hh
index 2e40d4b..bd6f35c 100644
--- a/recursor_cache.hh
+++ b/recursor_cache.hh
@@ -30,7 +30,7 @@
#include <iostream>
#include "dnsrecords.hh"
#include <boost/utility.hpp>
-#undef L
+#undef g_log
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/ordered_index.hpp>
#include <boost/multi_index/hashed_index.hpp>
@@ -42,7 +42,7 @@
#include "validate.hh"
#undef max
-#define L theL()
+#define g_log theL()
#include "namespaces.hh"
using namespace ::boost::multi_index;
diff --git a/reczones.cc b/reczones.cc
index 7adb343..2021ce8 100644
--- a/reczones.cc
+++ b/reczones.cc
@@ -119,10 +119,10 @@ static void makeNameToIPZone(std::shared_ptr<SyncRes::domainmap_t> newMap, const
ad.d_records.insert(dr);
if(newMap->count(dr.d_name)) {
- L<<Logger::Warning<<"Hosts file will not overwrite zone '"<<dr.d_name<<"' already loaded"<<endl;
+ g_log<<Logger::Warning<<"Hosts file will not overwrite zone '"<<dr.d_name<<"' already loaded"<<endl;
}
else {
- L<<Logger::Warning<<"Inserting forward zone '"<<dr.d_name<<"' based on hosts file"<<endl;
+ g_log<<Logger::Warning<<"Inserting forward zone '"<<dr.d_name<<"' based on hosts file"<<endl;
ad.d_name=dr.d_name;
(*newMap)[ad.d_name]=ad;
}
@@ -165,11 +165,11 @@ static void makeIPToNamesZone(std::shared_ptr<SyncRes::domainmap_t> newMap, cons
}
if(newMap->count(dr.d_name)) {
- L<<Logger::Warning<<"Will not overwrite zone '"<<dr.d_name<<"' already loaded"<<endl;
+ g_log<<Logger::Warning<<"Will not overwrite zone '"<<dr.d_name<<"' already loaded"<<endl;
}
else {
if(ipparts.size()==4)
- L<<Logger::Warning<<"Inserting reverse zone '"<<dr.d_name<<"' based on hosts file"<<endl;
+ g_log<<Logger::Warning<<"Inserting reverse zone '"<<dr.d_name<<"' based on hosts file"<<endl;
ad.d_name = dr.d_name;
(*newMap)[ad.d_name]=ad;
}
@@ -215,15 +215,15 @@ void convertServersForAD(const std::string& input, SyncRes::AuthDomain& ad, cons
for(vector<string>::const_iterator iter = servers.begin(); iter != servers.end(); ++iter) {
if(verbose && iter != servers.begin())
- L<<", ";
+ g_log<<", ";
ComboAddress addr=parseIPAndPort(*iter, 53);
if(verbose)
- L<<addr.toStringWithPort();
+ g_log<<addr.toStringWithPort();
ad.d_servers.push_back(addr);
}
if(verbose)
- L<<endl;
+ g_log<<endl;
}
void* pleaseWipeNegCache()
@@ -243,7 +243,7 @@ string reloadAuthAndForwards()
std::shared_ptr<SyncRes::domainmap_t> original=SyncRes::getDomainMap();
try {
- L<<Logger::Warning<<"Reloading zones, purging data from cache"<<endl;
+ g_log<<Logger::Warning<<"Reloading zones, purging data from cache"<<endl;
if (original) {
for(const auto& i : *original) {
@@ -302,13 +302,13 @@ string reloadAuthAndForwards()
return "ok\n";
}
catch(std::exception& e) {
- L<<Logger::Error<<"Encountered error reloading zones, keeping original data: "<<e.what()<<endl;
+ g_log<<Logger::Error<<"Encountered error reloading zones, keeping original data: "<<e.what()<<endl;
}
catch(PDNSException& ae) {
- L<<Logger::Error<<"Encountered error reloading zones, keeping original data: "<<ae.reason<<endl;
+ g_log<<Logger::Error<<"Encountered error reloading zones, keeping original data: "<<ae.reason<<endl;
}
catch(...) {
- L<<Logger::Error<<"Encountered unknown error reloading zones, keeping original data"<<endl;
+ g_log<<Logger::Error<<"Encountered unknown error reloading zones, keeping original data"<<endl;
}
return "reloading failed, see log\n";
}
@@ -336,7 +336,7 @@ std::shared_ptr<SyncRes::domainmap_t> parseAuthAndForwards()
// headers.first=toCanonic("", headers.first);
if(n==0) {
ad.d_rdForward = false;
- L<<Logger::Error<<"Parsing authoritative data for zone '"<<headers.first<<"' from file '"<<headers.second<<"'"<<endl;
+ g_log<<Logger::Error<<"Parsing authoritative data for zone '"<<headers.first<<"' from file '"<<headers.second<<"'"<<endl;
ZoneParserTNG zpt(headers.second, DNSName(headers.first));
DNSResourceRecord rr;
DNSRecord dr;
@@ -356,13 +356,13 @@ std::shared_ptr<SyncRes::domainmap_t> parseAuthAndForwards()
}
}
else {
- L<<Logger::Error<<"Redirecting queries for zone '"<<headers.first<<"' ";
+ g_log<<Logger::Error<<"Redirecting queries for zone '"<<headers.first<<"' ";
if(n == 2) {
- L<<"with recursion ";
+ g_log<<"with recursion ";
ad.d_rdForward = true;
}
else ad.d_rdForward = false;
- L<<"to: ";
+ g_log<<"to: ";
convertServersForAD(headers.second, ad, ";");
if(n == 2) {
@@ -376,7 +376,7 @@ std::shared_ptr<SyncRes::domainmap_t> parseAuthAndForwards()
}
if(!::arg()["forward-zones-file"].empty()) {
- L<<Logger::Warning<<"Reading zone forwarding information from '"<<::arg()["forward-zones-file"]<<"'"<<endl;
+ g_log<<Logger::Warning<<"Reading zone forwarding information from '"<<::arg()["forward-zones-file"]<<"'"<<endl;
SyncRes::AuthDomain ad;
FILE *rfp=fopen(::arg()["forward-zones-file"].c_str(), "r");
@@ -421,7 +421,7 @@ std::shared_ptr<SyncRes::domainmap_t> parseAuthAndForwards()
ad.d_name = DNSName(domain);
(*newMap)[ad.d_name]=ad;
}
- L<<Logger::Warning<<"Done parsing " << newMap->size() - before<<" forwarding instructions from file '"<<::arg()["forward-zones-file"]<<"'"<<endl;
+ g_log<<Logger::Warning<<"Done parsing " << newMap->size() - before<<" forwarding instructions from file '"<<::arg()["forward-zones-file"]<<"'"<<endl;
}
if(::arg().mustDo("export-etc-hosts")) {
@@ -430,7 +430,7 @@ std::shared_ptr<SyncRes::domainmap_t> parseAuthAndForwards()
ifstream ifs(fname.c_str());
if(!ifs) {
- L<<Logger::Warning<<"Could not open /etc/hosts for reading"<<endl;
+ g_log<<Logger::Warning<<"Could not open /etc/hosts for reading"<<endl;
}
else {
string searchSuffix = ::arg()["export-etc-hosts-search-suffix"];
@@ -462,7 +462,7 @@ std::shared_ptr<SyncRes::domainmap_t> parseAuthAndForwards()
}
}
if(::arg().mustDo("serve-rfc1918")) {
- L<<Logger::Warning<<"Inserting rfc 1918 private space zones"<<endl;
+ g_log<<Logger::Warning<<"Inserting rfc 1918 private space zones"<<endl;
parts.clear();
parts.push_back("127");
makeIPToNamesZone(newMap, parts);
diff --git a/remote_logger.cc b/remote_logger.cc
index 07ab13e..ce0eeb3 100644
--- a/remote_logger.cc
+++ b/remote_logger.cc
@@ -21,7 +21,7 @@ bool RemoteLogger::reconnect()
}
catch(const std::exception& e) {
#ifdef WE_ARE_RECURSOR
- L<<Logger::Warning<<"Error connecting to remote logger "<<d_remote.toStringWithPort()<<": "<<e.what()<<std::endl;
+ g_log<<Logger::Warning<<"Error connecting to remote logger "<<d_remote.toStringWithPort()<<": "<<e.what()<<std::endl;
#else
warnlog("Error connecting to remote logger %s: %s", d_remote.toStringWithPort(), e.what());
#endif
@@ -54,7 +54,7 @@ void RemoteLogger::worker()
}
catch(const std::runtime_error& e) {
#ifdef WE_ARE_RECURSOR
- L<<Logger::Info<<"Error sending data to remote logger "<<d_remote.toStringWithPort()<<": "<< e.what()<<endl;
+ g_log<<Logger::Info<<"Error sending data to remote logger "<<d_remote.toStringWithPort()<<": "<< e.what()<<endl;
#else
vinfolog("Error sending data to remote logger (%s): %s", d_remote.toStringWithPort(), e.what());
#endif
diff --git a/rpzloader.cc b/rpzloader.cc
index 815fb84..c36dbee 100644
--- a/rpzloader.cc
+++ b/rpzloader.cc
@@ -110,7 +110,7 @@ void RPZRecordToPolicy(const DNSRecord& dr, std::shared_ptr<DNSFilterEngine::Zon
else if(!crcTarget.empty() && !crcTarget.isRoot() && crcTarget.getRawLabel(crcTarget.countLabels() - 1).compare(0, rpzPrefix.length(), rpzPrefix) == 0) {
/* this is very likely an higher format number or a configuration error,
let's just ignore it. */
- L<<Logger::Info<<"Discarding unsupported RPZ entry "<<crcTarget.toString()<<" for "<<dr.d_name<<endl;
+ g_log<<Logger::Info<<"Discarding unsupported RPZ entry "<<crcTarget.toString()<<" for "<<dr.d_name<<endl;
return;
}
else {
@@ -177,9 +177,9 @@ void RPZRecordToPolicy(const DNSRecord& dr, std::shared_ptr<DNSFilterEngine::Zon
shared_ptr<SOARecordContent> loadRPZFromServer(const ComboAddress& master, const DNSName& zoneName, std::shared_ptr<DNSFilterEngine::Zone> zone, boost::optional<DNSFilterEngine::Policy> defpol, uint32_t maxTTL, const TSIGTriplet& tt, size_t maxReceivedBytes, const ComboAddress& localAddress, uint16_t axfrTimeout)
{
- L<<Logger::Warning<<"Loading RPZ zone '"<<zoneName<<"' from "<<master.toStringWithPort()<<endl;
+ g_log<<Logger::Warning<<"Loading RPZ zone '"<<zoneName<<"' from "<<master.toStringWithPort()<<endl;
if(!tt.name.empty())
- L<<Logger::Warning<<"With TSIG key '"<<tt.name<<"' of algorithm '"<<tt.algo<<"'"<<endl;
+ g_log<<Logger::Warning<<"With TSIG key '"<<tt.name<<"' of algorithm '"<<tt.algo<<"'"<<endl;
ComboAddress local(localAddress);
if (local == ComboAddress())
@@ -213,11 +213,11 @@ shared_ptr<SOARecordContent> loadRPZFromServer(const ComboAddress& master, const
throw PDNSException("Total AXFR time exceeded!");
}
if(last != time(0)) {
- L<<Logger::Info<<"Loaded & indexed "<<nrecords<<" policy records so far"<<endl;
+ g_log<<Logger::Info<<"Loaded & indexed "<<nrecords<<" policy records so far"<<endl;
last=time(0);
}
}
- L<<Logger::Info<<"Done: "<<nrecords<<" policy records active, SOA: "<<sr->getZoneRepresentation()<<endl;
+ g_log<<Logger::Info<<"Done: "<<nrecords<<" policy records active, SOA: "<<sr->getZoneRepresentation()<<endl;
return sr;
}
@@ -289,7 +289,7 @@ void RPZIXFRTracker(const ComboAddress& master, boost::optional<DNSFilterEngine:
/* we can _never_ modify this zone directly, we need to do a full copy then replace the existing zone */
std::shared_ptr<DNSFilterEngine::Zone> oldZone = luaconfsLocal->dfe.getZone(zoneIdx);
if (!oldZone) {
- L<<Logger::Error<<"Unable to retrieve RPZ zone with index "<<zoneIdx<<" from the configuration, exiting"<<endl;
+ g_log<<Logger::Error<<"Unable to retrieve RPZ zone with index "<<zoneIdx<<" from the configuration, exiting"<<endl;
return;
}
uint32_t refresh = oldZone->getRefresh();
@@ -337,7 +337,7 @@ void RPZIXFRTracker(const ComboAddress& master, boost::optional<DNSFilterEngine:
sleep(refresh);
- L<<Logger::Info<<"Getting IXFR deltas for "<<zoneName<<" from "<<master.toStringWithPort()<<", our serial: "<<getRR<SOARecordContent>(dr)->d_st.serial<<endl;
+ g_log<<Logger::Info<<"Getting IXFR deltas for "<<zoneName<<" from "<<master.toStringWithPort()<<", our serial: "<<getRR<SOARecordContent>(dr)->d_st.serial<<endl;
vector<pair<vector<DNSRecord>, vector<DNSRecord> > > deltas;
ComboAddress local(localAddress);
@@ -347,13 +347,13 @@ void RPZIXFRTracker(const ComboAddress& master, boost::optional<DNSFilterEngine:
try {
deltas = getIXFRDeltas(master, zoneName, dr, tt, &local, maxReceivedBytes);
} catch(std::runtime_error& e ){
- L<<Logger::Warning<<e.what()<<endl;
+ g_log<<Logger::Warning<<e.what()<<endl;
incRPZFailedTransfers(polName);
continue;
}
if(deltas.empty())
continue;
- L<<Logger::Info<<"Processing "<<deltas.size()<<" delta"<<addS(deltas)<<" for RPZ "<<zoneName<<endl;
+ g_log<<Logger::Info<<"Processing "<<deltas.size()<<" delta"<<addS(deltas)<<" for RPZ "<<zoneName<<endl;
oldZone = luaconfsLocal->dfe.getZone(zoneIdx);
/* we need to make a _full copy_ of the zone we are going to work on */
@@ -365,7 +365,7 @@ void RPZIXFRTracker(const ComboAddress& master, boost::optional<DNSFilterEngine:
const auto& remove = delta.first;
const auto& add = delta.second;
if(remove.empty()) {
- L<<Logger::Warning<<"IXFR update is a whole new zone"<<endl;
+ g_log<<Logger::Warning<<"IXFR update is a whole new zone"<<endl;
newZone->clear();
fullUpdate = true;
}
@@ -378,11 +378,11 @@ void RPZIXFRTracker(const ComboAddress& master, boost::optional<DNSFilterEngine:
// cout<<"Got good removal of SOA serial "<<oldsr->d_st.serial<<endl;
}
else
- L<<Logger::Error<<"GOT WRONG SOA SERIAL REMOVAL, SHOULD TRIGGER WHOLE RELOAD"<<endl;
+ g_log<<Logger::Error<<"GOT WRONG SOA SERIAL REMOVAL, SHOULD TRIGGER WHOLE RELOAD"<<endl;
}
else {
totremove++;
- L<<(g_logRPZChanges ? Logger::Info : Logger::Debug)<<"Had removal of "<<rr.d_name<<" from RPZ zone "<<zoneName<<endl;
+ g_log<<(g_logRPZChanges ? Logger::Info : Logger::Debug)<<"Had removal of "<<rr.d_name<<" from RPZ zone "<<zoneName<<endl;
RPZRecordToPolicy(rr, newZone, false, defpol, maxTTL);
}
}
@@ -392,19 +392,19 @@ void RPZIXFRTracker(const ComboAddress& master, boost::optional<DNSFilterEngine:
continue;
if(rr.d_type == QType::SOA) {
auto newsr = getRR<SOARecordContent>(rr);
- // L<<Logger::Info<<"New SOA serial for "<<zoneName<<": "<<newsr->d_st.serial<<endl;
+ // g_log<<Logger::Info<<"New SOA serial for "<<zoneName<<": "<<newsr->d_st.serial<<endl;
if (newsr) {
sr = newsr;
}
}
else {
totadd++;
- L<<(g_logRPZChanges ? Logger::Info : Logger::Debug)<<"Had addition of "<<rr.d_name<<" to RPZ zone "<<zoneName<<endl;
+ g_log<<(g_logRPZChanges ? Logger::Info : Logger::Debug)<<"Had addition of "<<rr.d_name<<" to RPZ zone "<<zoneName<<endl;
RPZRecordToPolicy(rr, newZone, true, defpol, maxTTL);
}
}
}
- L<<Logger::Info<<"Had "<<totremove<<" RPZ removal"<<addS(totremove)<<", "<<totadd<<" addition"<<addS(totadd)<<" for "<<zoneName<<" New serial: "<<sr->d_st.serial<<endl;
+ g_log<<Logger::Info<<"Had "<<totremove<<" RPZ removal"<<addS(totremove)<<", "<<totadd<<" addition"<<addS(totadd)<<" for "<<zoneName<<" New serial: "<<sr->d_st.serial<<endl;
newZone->setSerial(sr->d_st.serial);
setRPZZoneNewState(polName, sr->d_st.serial, newZone->size(), fullUpdate);
diff --git a/secpoll-recursor.cc b/secpoll-recursor.cc
index 3248b84..d88a7eb 100644
--- a/secpoll-recursor.cc
+++ b/secpoll-recursor.cc
@@ -55,7 +55,7 @@ void doSecPoll(time_t* last_secpoll)
}
if(state == Bogus) {
- L<<Logger::Error<<"Could not retrieve security status update for '" +pkgv+ "' on '"<<query<<"', DNSSEC validation result was Bogus!"<<endl;
+ g_log<<Logger::Error<<"Could not retrieve security status update for '" +pkgv+ "' on '"<<query<<"', DNSSEC validation result was Bogus!"<<endl;
if(g_security_status == 1) // If we were OK, go to unknown
g_security_status = 0;
return;
@@ -79,18 +79,18 @@ void doSecPoll(time_t* last_secpoll)
}
else {
if(pkgv.find("0.0.") != 0)
- L<<Logger::Warning<<"Could not retrieve security status update for '" +pkgv+ "' on '"<<query<<"', RCODE = "<< RCode::to_s(res)<<endl;
+ g_log<<Logger::Warning<<"Could not retrieve security status update for '" +pkgv+ "' on '"<<query<<"', RCODE = "<< RCode::to_s(res)<<endl;
else
- L<<Logger::Warning<<"Ignoring response for security status update, this is a non-release version."<<endl;
+ g_log<<Logger::Warning<<"Ignoring response for security status update, this is a non-release version."<<endl;
if(g_security_status == 1) // it was ok, now it is unknown
g_security_status = 0;
}
if(g_security_status == 2) {
- L<<Logger::Error<<"PowerDNS Security Update Recommended: "<<g_security_message<<endl;
+ g_log<<Logger::Error<<"PowerDNS Security Update Recommended: "<<g_security_message<<endl;
}
else if(g_security_status == 3) {
- L<<Logger::Error<<"PowerDNS Security Update Mandatory: "<<g_security_message<<endl;
+ g_log<<Logger::Error<<"PowerDNS Security Update Mandatory: "<<g_security_message<<endl;
}
}
diff --git a/syncres.cc b/syncres.cc
index 4449534..eabc9d9 100644
--- a/syncres.cc
+++ b/syncres.cc
@@ -76,7 +76,7 @@ bool SyncRes::s_nopacketcache;
bool SyncRes::s_rootNXTrust;
bool SyncRes::s_noEDNS;
-#define LOG(x) if(d_lm == Log) { L <<Logger::Warning << x; } else if(d_lm == Store) { d_trace << x; }
+#define LOG(x) if(d_lm == Log) { g_log <<Logger::Warning << x; } else if(d_lm == Store) { d_trace << x; }
static void accountAuthLatency(int usec, int family)
{
@@ -2859,23 +2859,23 @@ int SyncRes::getRootNS(struct timeval now, asyncresolve_t asyncCallback) {
return res;
}
catch(const PDNSException& e) {
- L<<Logger::Error<<"Failed to update . records, got an exception: "<<e.reason<<endl;
+ g_log<<Logger::Error<<"Failed to update . records, got an exception: "<<e.reason<<endl;
}
catch(const ImmediateServFailException& e) {
- L<<Logger::Error<<"Failed to update . records, got an exception: "<<e.reason<<endl;
+ g_log<<Logger::Error<<"Failed to update . records, got an exception: "<<e.reason<<endl;
}
catch(const std::exception& e) {
- L<<Logger::Error<<"Failed to update . records, got an exception: "<<e.what()<<endl;
+ g_log<<Logger::Error<<"Failed to update . records, got an exception: "<<e.what()<<endl;
}
catch(...) {
- L<<Logger::Error<<"Failed to update . records, got an exception"<<endl;
+ g_log<<Logger::Error<<"Failed to update . records, got an exception"<<endl;
}
if(!res) {
- L<<Logger::Notice<<"Refreshed . records"<<endl;
+ g_log<<Logger::Notice<<"Refreshed . records"<<endl;
}
else
- L<<Logger::Error<<"Failed to update . records, RCODE="<<res<<endl;
+ g_log<<Logger::Error<<"Failed to update . records, RCODE="<<res<<endl;
return res;
}
diff --git a/test-syncres_cc.cc b/test-syncres_cc.cc
index d02c613..01be477 100644
--- a/test-syncres_cc.cc
+++ b/test-syncres_cc.cc
@@ -101,16 +101,16 @@ LuaConfigItems::LuaConfigItems()
static void init(bool debug=false)
{
- L.setName("test");
- L.disableSyslog(true);
+ g_log.setName("test");
+ g_log.disableSyslog(true);
if (debug) {
- L.setLoglevel((Logger::Urgency)(6)); // info and up
- L.toConsole(Logger::Info);
+ g_log.setLoglevel((Logger::Urgency)(6)); // info and up
+ g_log.toConsole(Logger::Info);
}
else {
- L.setLoglevel(Logger::None);
- L.toConsole(Logger::Error);
+ g_log.setLoglevel(Logger::None);
+ g_log.toConsole(Logger::Error);
}
seedRandom("/dev/urandom");
diff --git a/validate-recursor.cc b/validate-recursor.cc
index a870c2e..4a31698 100644
--- a/validate-recursor.cc
+++ b/validate-recursor.cc
@@ -13,7 +13,7 @@ bool checkDNSSECDisabled() {
bool warnIfDNSSECDisabled(const string& msg) {
if(g_dnssecmode == DNSSECMode::Off) {
if (!msg.empty())
- L<<Logger::Warning<<msg<<endl;
+ g_log<<Logger::Warning<<msg<<endl;
return true;
}
return false;
diff --git a/validate.cc b/validate.cc
index 00afcd7..ca429de 100644
--- a/validate.cc
+++ b/validate.cc
@@ -8,7 +8,7 @@
bool g_dnssecLOG{false};
uint16_t g_maxNSEC3Iterations{0};
-#define LOG(x) if(g_dnssecLOG) { L <<Logger::Warning << x; }
+#define LOG(x) if(g_dnssecLOG) { g_log <<Logger::Warning << x; }
void dotEdge(DNSName zone, string type1, DNSName name1, string tag1, string type2, DNSName name2, string tag2, string color="");
void dotNode(string type, DNSName name, string tag, string content);
string dotName(string type, DNSName name, string tag);
diff --git a/webserver.cc b/webserver.cc
index f1a95f4..af0a17e 100644
--- a/webserver.cc
+++ b/webserver.cc
@@ -39,12 +39,12 @@ json11::Json HttpRequest::json()
{
string err;
if(this->body.empty()) {
- L<<Logger::Debug<<"HTTP: JSON document expected in request body, but body was empty" << endl;
+ g_log<<Logger::Debug<<"HTTP: JSON document expected in request body, but body was empty" << endl;
throw HttpBadRequestException();
}
json11::Json doc = json11::Json::parse(this->body, err);
if (doc.is_null()) {
- L<<Logger::Debug<<"HTTP: parsing of JSON document failed:" << err << endl;
+ g_log<<Logger::Debug<<"HTTP: parsing of JSON document failed:" << err << endl;
throw HttpBadRequestException();
}
return doc;
@@ -132,13 +132,13 @@ static void apiWrapper(WebServer::HandlerFunction handler, HttpRequest* req, Htt
resp->headers["access-control-allow-origin"] = "*";
if (api_key.empty()) {
- L<<Logger::Error<<"HTTP API Request \"" << req->url.path << "\": Authentication failed, API Key missing in config" << endl;
+ g_log<<Logger::Error<<"HTTP API Request \"" << req->url.path << "\": Authentication failed, API Key missing in config" << endl;
throw HttpUnauthorizedException("X-API-Key");
}
bool auth_ok = req->compareHeader("x-api-key", api_key) || req->getvars["api-key"]==api_key;
if (!auth_ok) {
- L<<Logger::Error<<"HTTP Request \"" << req->url.path << "\": Authentication by API Key failed" << endl;
+ g_log<<Logger::Error<<"HTTP Request \"" << req->url.path << "\": Authentication by API Key failed" << endl;
throw HttpUnauthorizedException("X-API-Key");
}
@@ -181,7 +181,7 @@ static void webWrapper(WebServer::HandlerFunction handler, HttpRequest* req, Htt
if (!web_password.empty()) {
bool auth_ok = req->compareAuthorization(web_password);
if (!auth_ok) {
- L<<Logger::Debug<<"HTTP Request \"" << req->url.path << "\": Web Authentication failed" << endl;
+ g_log<<Logger::Debug<<"HTTP Request \"" << req->url.path << "\": Web Authentication failed" << endl;
throw HttpUnauthorizedException("Basic");
}
}
@@ -206,11 +206,11 @@ void WebServer::handleRequest(HttpRequest& req, HttpResponse& resp) const
try {
if (!req.complete) {
- L<<Logger::Debug<<"HTTP: Incomplete request" << endl;
+ g_log<<Logger::Debug<<"HTTP: Incomplete request" << endl;
throw HttpBadRequestException();
}
- L<<Logger::Debug<<"HTTP: Handling request \"" << req.url.path << "\"" << endl;
+ g_log<<Logger::Debug<<"HTTP: Handling request \"" << req.url.path << "\"" << endl;
YaHTTP::strstr_map_t::iterator header;
@@ -225,33 +225,33 @@ void WebServer::handleRequest(HttpRequest& req, HttpResponse& resp) const
YaHTTP::THandlerFunction handler;
if (!YaHTTP::Router::Route(&req, handler)) {
- L<<Logger::Debug<<"HTTP: No route found for \"" << req.url.path << "\"" << endl;
+ g_log<<Logger::Debug<<"HTTP: No route found for \"" << req.url.path << "\"" << endl;
throw HttpNotFoundException();
}
try {
handler(&req, &resp);
- L<<Logger::Debug<<"HTTP: Result for \"" << req.url.path << "\": " << resp.status << ", body length: " << resp.body.size() << endl;
+ g_log<<Logger::Debug<<"HTTP: Result for \"" << req.url.path << "\": " << resp.status << ", body length: " << resp.body.size() << endl;
}
catch(HttpException&) {
throw;
}
catch(PDNSException &e) {
- L<<Logger::Error<<"HTTP ISE for \""<< req.url.path << "\": Exception: " << e.reason << endl;
+ g_log<<Logger::Error<<"HTTP ISE for \""<< req.url.path << "\": Exception: " << e.reason << endl;
throw HttpInternalServerErrorException();
}
catch(std::exception &e) {
- L<<Logger::Error<<"HTTP ISE for \""<< req.url.path << "\": STL Exception: " << e.what() << endl;
+ g_log<<Logger::Error<<"HTTP ISE for \""<< req.url.path << "\": STL Exception: " << e.what() << endl;
throw HttpInternalServerErrorException();
}
catch(...) {
- L<<Logger::Error<<"HTTP ISE for \""<< req.url.path << "\": Unknown Exception" << endl;
+ g_log<<Logger::Error<<"HTTP ISE for \""<< req.url.path << "\": Unknown Exception" << endl;
throw HttpInternalServerErrorException();
}
}
catch(HttpException &e) {
resp = e.response();
- L<<Logger::Debug<<"HTTP: Error result for \"" << req.url.path << "\": " << resp.status << endl;
+ g_log<<Logger::Debug<<"HTTP: Error result for \"" << req.url.path << "\": " << resp.status << endl;
string what = YaHTTP::Utility::status2text(resp.status);
if(req.accept_html) {
resp.headers["Content-Type"] = "text/html; charset=utf-8";
@@ -311,14 +311,14 @@ try {
client->writenWithTimeout(reply.c_str(), reply.size(), timeout);
}
catch(PDNSException &e) {
- L<<Logger::Error<<"HTTP Exception: "<<e.reason<<endl;
+ g_log<<Logger::Error<<"HTTP Exception: "<<e.reason<<endl;
}
catch(std::exception &e) {
if(strstr(e.what(), "timeout")==0)
- L<<Logger::Error<<"HTTP STL Exception: "<<e.what()<<endl;
+ g_log<<Logger::Error<<"HTTP STL Exception: "<<e.what()<<endl;
}
catch(...) {
- L<<Logger::Error<<"HTTP: Unknown exception"<<endl;
+ g_log<<Logger::Error<<"HTTP: Unknown exception"<<endl;
}
WebServer::WebServer(const string &listenaddress, int port) : d_server(nullptr)
@@ -331,10 +331,10 @@ void WebServer::bind()
{
try {
d_server = createServer();
- L<<Logger::Warning<<"Listening for HTTP requests on "<<d_server->d_local.toStringWithPort()<<endl;
+ g_log<<Logger::Warning<<"Listening for HTTP requests on "<<d_server->d_local.toStringWithPort()<<endl;
}
catch(NetworkError &e) {
- L<<Logger::Error<<"Listening on HTTP socket failed: "<<e.what()<<endl;
+ g_log<<Logger::Error<<"Listening on HTTP socket failed: "<<e.what()<<endl;
d_server = nullptr;
}
}
@@ -359,28 +359,28 @@ void WebServer::go()
} else {
ComboAddress remote;
if (client->getRemote(remote))
- L<<Logger::Error<<"Webserver closing socket: remote ("<< remote.toString() <<") does not match 'webserver-allow-from'"<<endl;
+ g_log<<Logger::Error<<"Webserver closing socket: remote ("<< remote.toString() <<") does not match 'webserver-allow-from'"<<endl;
}
}
catch(PDNSException &e) {
- L<<Logger::Error<<"PDNSException while accepting a connection in main webserver thread: "<<e.reason<<endl;
+ g_log<<Logger::Error<<"PDNSException while accepting a connection in main webserver thread: "<<e.reason<<endl;
}
catch(std::exception &e) {
- L<<Logger::Error<<"STL Exception while accepting a connection in main webserver thread: "<<e.what()<<endl;
+ g_log<<Logger::Error<<"STL Exception while accepting a connection in main webserver thread: "<<e.what()<<endl;
}
catch(...) {
- L<<Logger::Error<<"Unknown exception while accepting a connection in main webserver thread"<<endl;
+ g_log<<Logger::Error<<"Unknown exception while accepting a connection in main webserver thread"<<endl;
}
}
}
catch(PDNSException &e) {
- L<<Logger::Error<<"PDNSException in main webserver thread: "<<e.reason<<endl;
+ g_log<<Logger::Error<<"PDNSException in main webserver thread: "<<e.reason<<endl;
}
catch(std::exception &e) {
- L<<Logger::Error<<"STL Exception in main webserver thread: "<<e.what()<<endl;
+ g_log<<Logger::Error<<"STL Exception in main webserver thread: "<<e.what()<<endl;
}
catch(...) {
- L<<Logger::Error<<"Unknown exception in main webserver thread"<<endl;
+ g_log<<Logger::Error<<"Unknown exception in main webserver thread"<<endl;
}
_exit(1);
}
diff --git a/ws-recursor.cc b/ws-recursor.cc
index dbe1c07..9860d7b 100644
--- a/ws-recursor.cc
+++ b/ws-recursor.cc
@@ -585,11 +585,11 @@ void AsyncServerNewConnectionMT(void *p) {
}
} catch (NetworkError &e) {
// we're running in a shared process/thread, so can't just terminate/abort.
- L<<Logger::Warning<<"Network error in web thread: "<<e.what()<<endl;
+ g_log<<Logger::Warning<<"Network error in web thread: "<<e.what()<<endl;
return;
}
catch (...) {
- L<<Logger::Warning<<"Unknown error in web thread"<<endl;
+ g_log<<Logger::Warning<<"Unknown error in web thread"<<endl;
return;
}
@@ -639,18 +639,18 @@ try {
// now send the reply
if (asendtcp(data, client.get()) == -1 || data.empty()) {
- L<<Logger::Error<<"Failed sending reply to HTTP client"<<endl;
+ g_log<<Logger::Error<<"Failed sending reply to HTTP client"<<endl;
}
}
catch(PDNSException &e) {
- L<<Logger::Error<<"HTTP Exception: "<<e.reason<<endl;
+ g_log<<Logger::Error<<"HTTP Exception: "<<e.reason<<endl;
}
catch(std::exception &e) {
if(strstr(e.what(), "timeout")==0)
- L<<Logger::Error<<"HTTP STL Exception: "<<e.what()<<endl;
+ g_log<<Logger::Error<<"HTTP STL Exception: "<<e.what()<<endl;
}
catch(...) {
- L<<Logger::Error<<"HTTP: Unknown exception"<<endl;
+ g_log<<Logger::Error<<"HTTP: Unknown exception"<<endl;
}
void AsyncWebServer::go() {
|