Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove theLog and theL and replace this with a global g_log #6358

Merged
merged 1 commit into from
Mar 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/appendices/backend-writers-guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ furthermore, only about its A record:
RandomLoader()
{
BackendMakers().report(new RandomFactory);
L << Logger::Info << "[randombackend] This is the random backend version " VERSION " reporting" << endl;
g_log << Logger::Info << "[randombackend] This is the random backend version " VERSION " reporting" << endl;
}
};

Expand Down Expand Up @@ -625,7 +625,7 @@ The actual code in PowerDNS is currently:
resolver.axfr(remote,domain.c_str());

db->startTransaction(domain, domain_id);
L<<Logger::Error<<"AXFR started for '"<<domain<<"'"<<endl;
g_log<<Logger::Error<<"AXFR started for '"<<domain<<"'"<<endl;
Resolver::res_t recs;

while(resolver.axfrChunk(recs)) {
Expand All @@ -635,7 +635,7 @@ The actual code in PowerDNS is currently:
}
db->commitTransaction();
db->setFresh(domain_id);
L<<Logger::Error<<"AXFR done for '"<<domain<<"'"<<endl;
g_log<<Logger::Error<<"AXFR done for '"<<domain<<"'"<<endl;

Supermaster/Superslave capability
---------------------------------
Expand Down
68 changes: 34 additions & 34 deletions modules/bindbackend/bindbackend2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ void Bind2Backend::insertRecord(BB2DomainInfo& bb2, const DNSName &qname, const
else {
string msg = "Trying to insert non-zone data, name='"+bdr.qname.toLogString()+"', qtype="+qtype.getName()+", zone='"+bb2.d_name.toLogString()+"'";
if(s_ignore_broken_records) {
L<<Logger::Warning<<msg<< " ignored" << endl;
g_log<<Logger::Warning<<msg<< " ignored" << endl;
return;
}
else
Expand Down Expand Up @@ -604,7 +604,7 @@ string Bind2Backend::DLAddDomainHandler(const vector<string>&parts, Utility::pid

safePutBBDomainInfo(bbd);

L<<Logger::Warning<<"Zone "<<domainname<< " loaded"<<endl;
g_log<<Logger::Warning<<"Zone "<<domainname<< " loaded"<<endl;
return "Loaded zone " + domainname.toLogString() + " from " + filename;
}

Expand Down Expand Up @@ -737,7 +737,7 @@ void Bind2Backend::doEmptyNonTerminals(BB2DomainInfo& bbd, bool nsec3zone, NSEC3
{
if(!(maxent))
{
L<<Logger::Error<<"Zone '"<<bbd.d_name<<"' has too many empty non terminals."<<endl;
g_log<<Logger::Error<<"Zone '"<<bbd.d_name<<"' has too many empty non terminals."<<endl;
return;
}

Expand Down Expand Up @@ -776,7 +776,7 @@ void Bind2Backend::loadConfig(string* status)
BP.parse(getArg("config"));
}
catch(PDNSException &ae) {
L<<Logger::Error<<"Error parsing bind configuration: "<<ae.reason<<endl;
g_log<<Logger::Error<<"Error parsing bind configuration: "<<ae.reason<<endl;
throw;
}

Expand All @@ -786,7 +786,7 @@ void Bind2Backend::loadConfig(string* status)
s_binddirectory=BP.getDirectory();
// ZP.setDirectory(d_binddirectory);

L<<Logger::Warning<<d_logprefix<<" Parsing "<<domains.size()<<" domain(s), will report when done"<<endl;
g_log<<Logger::Warning<<d_logprefix<<" Parsing "<<domains.size()<<" domain(s), will report when done"<<endl;

set<DNSName> oldnames, newnames;
{
Expand Down Expand Up @@ -814,15 +814,15 @@ void Bind2Backend::loadConfig(string* status)
++i)
{
if (!(i->hadFileDirective)) {
L<<Logger::Warning<<d_logprefix<<" Zone '"<<i->name<<"' has no 'file' directive set in "<<getArg("config")<<endl;
g_log<<Logger::Warning<<d_logprefix<<" Zone '"<<i->name<<"' has no 'file' directive set in "<<getArg("config")<<endl;
rejected++;
continue;
}

if(i->type == "")
L<<Logger::Notice<<d_logprefix<<" Zone '"<<i->name<<"' has no type specified, assuming 'native'"<<endl;
g_log<<Logger::Notice<<d_logprefix<<" Zone '"<<i->name<<"' has no type specified, assuming 'native'"<<endl;
if(i->type!="master" && i->type!="slave" && i->type != "native" && i->type != "") {
L<<Logger::Warning<<d_logprefix<<" Warning! Skipping zone '"<<i->name<<"' because type '"<<i->type<<"' is invalid"<<endl;
g_log<<Logger::Warning<<d_logprefix<<" Warning! Skipping zone '"<<i->name<<"' because type '"<<i->type<<"' is invalid"<<endl;
rejected++;
continue;
}
Expand Down Expand Up @@ -853,7 +853,7 @@ void Bind2Backend::loadConfig(string* status)

newnames.insert(bbd.d_name);
if(filenameChanged || !bbd.d_loaded || !bbd.current()) {
L<<Logger::Info<<d_logprefix<<" parsing '"<<i->name<<"' from file '"<<i->filename<<"'"<<endl;
g_log<<Logger::Info<<d_logprefix<<" parsing '"<<i->name<<"' from file '"<<i->filename<<"'"<<endl;

try {
parseZoneFile(&bbd);
Expand All @@ -866,7 +866,7 @@ void Bind2Backend::loadConfig(string* status)
*status+=msg.str();
bbd.d_status=msg.str();

L<<Logger::Warning<<d_logprefix<<msg.str()<<endl;
g_log<<Logger::Warning<<d_logprefix<<msg.str()<<endl;
rejected++;
}
catch(std::system_error &ae) {
Expand All @@ -879,7 +879,7 @@ void Bind2Backend::loadConfig(string* status)
if(status)
*status+=msg.str();
bbd.d_status=msg.str();
L<<Logger::Warning<<d_logprefix<<msg.str()<<endl;
g_log<<Logger::Warning<<d_logprefix<<msg.str()<<endl;
rejected++;
}
catch(std::exception &ae) {
Expand All @@ -890,7 +890,7 @@ void Bind2Backend::loadConfig(string* status)
*status+=msg.str();
bbd.d_status=msg.str();

L<<Logger::Warning<<d_logprefix<<msg.str()<<endl;
g_log<<Logger::Warning<<d_logprefix<<msg.str()<<endl;
rejected++;
}
safePutBBDomainInfo(bbd);
Expand All @@ -916,7 +916,7 @@ void Bind2Backend::loadConfig(string* status)
if(status)
*status=msg.str();

L<<Logger::Error<<d_logprefix<<msg.str()<<endl;
g_log<<Logger::Error<<d_logprefix<<msg.str()<<endl;
}
}

Expand All @@ -931,20 +931,20 @@ void Bind2Backend::queueReloadAndStore(unsigned int id)
bbnew.d_checknow=false;
bbnew.d_wasRejectedLastReload=false;
safePutBBDomainInfo(bbnew);
L<<Logger::Warning<<"Zone '"<<bbnew.d_name<<"' ("<<bbnew.d_filename<<") reloaded"<<endl;
g_log<<Logger::Warning<<"Zone '"<<bbnew.d_name<<"' ("<<bbnew.d_filename<<") reloaded"<<endl;
}
catch(PDNSException &ae) {
ostringstream msg;
msg<<" error at "+nowTime()+" parsing '"<<bbold.d_name<<"' from file '"<<bbold.d_filename<<"': "<<ae.reason;
L<<Logger::Warning<<" error parsing '"<<bbold.d_name<<"' from file '"<<bbold.d_filename<<"': "<<ae.reason<<endl;
g_log<<Logger::Warning<<" error parsing '"<<bbold.d_name<<"' from file '"<<bbold.d_filename<<"': "<<ae.reason<<endl;
bbold.d_status=msg.str();
bbold.d_wasRejectedLastReload=true;
safePutBBDomainInfo(bbold);
}
catch(std::exception &ae) {
ostringstream msg;
msg<<" error at "+nowTime()+" parsing '"<<bbold.d_name<<"' from file '"<<bbold.d_filename<<"': "<<ae.what();
L<<Logger::Warning<<" error parsing '"<<bbold.d_name<<"' from file '"<<bbold.d_filename<<"': "<<ae.what()<<endl;
g_log<<Logger::Warning<<" error parsing '"<<bbold.d_name<<"' from file '"<<bbold.d_filename<<"': "<<ae.what()<<endl;
bbold.d_status=msg.str();
bbold.d_wasRejectedLastReload=true;
safePutBBDomainInfo(bbold);
Expand Down Expand Up @@ -1036,7 +1036,7 @@ void Bind2Backend::lookup(const QType &qtype, const DNSName &qname, DNSPacket *p

static bool mustlog=::arg().mustDo("query-logging");
if(mustlog)
L<<Logger::Warning<<"Lookup for '"<<qtype.getName()<<"' of '"<<domain<<"' within zoneID "<<zoneId<<endl;
g_log<<Logger::Warning<<"Lookup for '"<<qtype.getName()<<"' of '"<<domain<<"' within zoneID "<<zoneId<<endl;
bool found=false;
BB2DomainInfo bbd;

Expand All @@ -1046,17 +1046,17 @@ void Bind2Backend::lookup(const QType &qtype, const DNSName &qname, DNSPacket *p

if(!found) {
if(mustlog)
L<<Logger::Warning<<"Found no authoritative zone for "<<qname<<endl;
g_log<<Logger::Warning<<"Found no authoritative zone for "<<qname<<endl;
d_handle.d_list=false;
return;
}

if(mustlog)
L<<Logger::Warning<<"Found a zone '"<<domain<<"' (with id " << bbd.d_id<<") that might contain data "<<endl;
g_log<<Logger::Warning<<"Found a zone '"<<domain<<"' (with id " << bbd.d_id<<") that might contain data "<<endl;

d_handle.id=bbd.d_id;

DLOG(L<<"Bind2Backend constructing handle for search for "<<qtype.getName()<<" for "<<
DLOG(g_log<<"Bind2Backend constructing handle for search for "<<qtype.getName()<<" for "<<
qname<<endl);

if(domain.empty())
Expand All @@ -1073,7 +1073,7 @@ void Bind2Backend::lookup(const QType &qtype, const DNSName &qname, DNSPacket *p
}

if(!bbd.current()) {
L<<Logger::Warning<<"Zone '"<<bbd.d_name<<"' ("<<bbd.d_filename<<") needs reloading"<<endl;
g_log<<Logger::Warning<<"Zone '"<<bbd.d_name<<"' ("<<bbd.d_filename<<") needs reloading"<<endl;
queueReloadAndStore(bbd.d_id);
if (!safeGetBBDomainInfo(domain, &bbd))
throw DBException("Zone '"+bbd.d_name.toLogString()+"' ("+bbd.d_filename+") gone after reload"); // if we don't throw here, we crash for some reason
Expand All @@ -1082,7 +1082,7 @@ void Bind2Backend::lookup(const QType &qtype, const DNSName &qname, DNSPacket *p
d_handle.d_records = bbd.d_records.get();

if(d_handle.d_records->empty())
DLOG(L<<"Query with no results"<<endl);
DLOG(g_log<<"Query with no results"<<endl);

d_handle.mustlog = mustlog;

Expand Down Expand Up @@ -1111,20 +1111,20 @@ bool Bind2Backend::get(DNSResourceRecord &r)
{
if(!d_handle.d_records) {
if(d_handle.mustlog)
L<<Logger::Warning<<"There were no answers"<<endl;
g_log<<Logger::Warning<<"There were no answers"<<endl;
return false;
}

if(!d_handle.get(r)) {
if(d_handle.mustlog)
L<<Logger::Warning<<"End of answers"<<endl;
g_log<<Logger::Warning<<"End of answers"<<endl;

d_handle.reset();

return false;
}
if(d_handle.mustlog)
L<<Logger::Warning<<"Returning: '"<<r.qtype.getName()<<"' of '"<<r.qname<<"', content: '"<<r.content<<"'"<<endl;
g_log<<Logger::Warning<<"Returning: '"<<r.qtype.getName()<<"' of '"<<r.qname<<"', content: '"<<r.content<<"'"<<endl;
return true;
}

Expand All @@ -1146,21 +1146,21 @@ void Bind2Backend::handle::reset()
//#define DLOG(x) x
bool Bind2Backend::handle::get_normal(DNSResourceRecord &r)
{
DLOG(L << "Bind2Backend get() was called for "<<qtype.getName() << " record for '"<<
DLOG(g_log << "Bind2Backend get() was called for "<<qtype.getName() << " record for '"<<
qname<<"' - "<<d_records->size()<<" available in total!"<<endl);

if(d_iter==d_end_iter) {
return false;
}

while(d_iter!=d_end_iter && !(qtype.getCode()==QType::ANY || (d_iter)->qtype==qtype.getCode())) {
DLOG(L<<Logger::Warning<<"Skipped "<<qname<<"/"<<QType(d_iter->qtype).getName()<<": '"<<d_iter->content<<"'"<<endl);
DLOG(g_log<<Logger::Warning<<"Skipped "<<qname<<"/"<<QType(d_iter->qtype).getName()<<": '"<<d_iter->content<<"'"<<endl);
d_iter++;
}
if(d_iter==d_end_iter) {
return false;
}
DLOG(L << "Bind2Backend get() returning a rr with a "<<QType(d_iter->qtype).getCode()<<endl);
DLOG(g_log << "Bind2Backend get() returning a rr with a "<<QType(d_iter->qtype).getCode()<<endl);

r.qname=qname.empty() ? domain : (qname+domain);
r.domain_id=id;
Expand All @@ -1186,7 +1186,7 @@ bool Bind2Backend::list(const DNSName& target, int id, bool include_disabled)
return false;

d_handle.reset();
DLOG(L<<"Bind2Backend constructing handle for list of "<<id<<endl);
DLOG(g_log<<"Bind2Backend constructing handle for list of "<<id<<endl);

d_handle.d_records=bbd.d_records.get(); // give it a copy, which will stay around
d_handle.d_qname_iter= d_handle.d_records->begin();
Expand Down Expand Up @@ -1237,7 +1237,7 @@ bool Bind2Backend::superMasterBackend(const string &ip, const DNSName& domain, c

ifstream c_if(getArg("supermasters").c_str(), std::ios::in); // this was nocreate?
if (!c_if) {
L << Logger::Error << "Unable to open supermasters file for read: " << stringerror() << endl;
g_log << Logger::Error << "Unable to open supermasters file for read: " << stringerror() << endl;
return false;
}

Expand Down Expand Up @@ -1288,7 +1288,7 @@ bool Bind2Backend::createSlaveDomain(const string &ip, const DNSName& domain, co
{
string filename = getArg("supermaster-destdir")+'/'+domain.toStringNoDot();

L << Logger::Warning << d_logprefix
g_log << Logger::Warning << d_logprefix
<< " Writing bind config zone statement for superslave zone '" << domain
<< "' from supermaster " << ip << endl;

Expand All @@ -1297,7 +1297,7 @@ bool Bind2Backend::createSlaveDomain(const string &ip, const DNSName& domain, co

ofstream c_of(getArg("supermaster-config").c_str(), std::ios::app);
if (!c_of) {
L << Logger::Error << "Unable to open supermaster configfile for append: " << stringerror() << endl;
g_log << Logger::Error << "Unable to open supermaster configfile for append: " << stringerror() << endl;
throw DBException("Unable to open supermaster configfile for append: "+stringerror());
}

Expand All @@ -1323,7 +1323,7 @@ bool Bind2Backend::searchRecords(const string &pattern, int maxResults, vector<D
SimpleMatch sm(pattern,true);
static bool mustlog=::arg().mustDo("query-logging");
if(mustlog)
L<<Logger::Warning<<"Search for pattern '"<<pattern<<"'"<<endl;
g_log<<Logger::Warning<<"Search for pattern '"<<pattern<<"'"<<endl;

{
ReadLock rl(&s_state_lock);
Expand Down Expand Up @@ -1387,7 +1387,7 @@ class Bind2Loader
Bind2Loader()
{
BackendMakers().report(new Bind2Factory);
L << Logger::Info << "[bind2backend] This is the bind backend version " << VERSION
g_log << Logger::Info << "[bind2backend] This is the bind backend version " << VERSION
#ifndef REPRODUCIBLE
<< " (" __DATE__ " " __TIME__ ")"
#endif
Expand Down
4 changes: 2 additions & 2 deletions modules/bindbackend/binddnssec.cc
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,11 @@ bool Bind2Backend::getNSEC3PARAM(const DNSName& name, NSEC3PARAMRecordContent* n

if (ns3p->d_iterations > maxNSEC3Iterations) {
ns3p->d_iterations = maxNSEC3Iterations;
L<<Logger::Error<<"Number of NSEC3 iterations for zone '"<<name<<"' is above 'max-nsec3-iterations'. Value adjusted to: "<<maxNSEC3Iterations<<endl;
g_log<<Logger::Error<<"Number of NSEC3 iterations for zone '"<<name<<"' is above 'max-nsec3-iterations'. Value adjusted to: "<<maxNSEC3Iterations<<endl;
}

if (ns3p->d_algorithm != 1) {
L<<Logger::Error<<"Invalid hash algorithm for NSEC3: '"<<std::to_string(ns3p->d_algorithm)<<"', setting to 1 for zone '"<<name<<"'."<<endl;
g_log<<Logger::Error<<"Invalid hash algorithm for NSEC3: '"<<std::to_string(ns3p->d_algorithm)<<"', setting to 1 for zone '"<<name<<"'."<<endl;
ns3p->d_algorithm = 1;
}
}
Expand Down
16 changes: 8 additions & 8 deletions modules/geoipbackend/geoipbackend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ void GeoIPBackend::initialize() {
}

if (s_geoip_files.empty())
L<<Logger::Warning<<"No GeoIP database files loaded!"<<endl;
g_log<<Logger::Warning<<"No GeoIP database files loaded!"<<endl;

config = YAML::LoadFile(getArg("zones-file"));

Expand Down Expand Up @@ -138,14 +138,14 @@ void GeoIPBackend::initialize() {
} else if (attr == "weight") {
rr.weight = iter->second.as<int>();
if (rr.weight < 0) {
L<<Logger::Error<<"Weight cannot be negative for " << rr.qname << endl;
g_log<<Logger::Error<<"Weight cannot be negative for " << rr.qname << endl;
throw PDNSException(string("Weight cannot be negative for ") + rr.qname.toLogString());
}
rr.has_weight = true;
} else if (attr == "ttl") {
rr.ttl = iter->second.as<int>();
} else {
L<<Logger::Error<<"Unsupported record attribute " << attr << " for " << rr.qname << endl;
g_log<<Logger::Error<<"Unsupported record attribute " << attr << " for " << rr.qname << endl;
throw PDNSException(string("Unsupported record attribute ") + attr + string(" for ") + rr.qname.toLogString());
}
}
Expand Down Expand Up @@ -367,7 +367,7 @@ void GeoIPBackend::lookup(const QType &qtype, const DNSName& qdomain, DNSPacket
}

if (!d_result.empty()) {
L<<Logger::Error<<
g_log<<Logger::Error<<
"Cannot have static record and CNAME at the same time." <<
"Please fix your configuration for \"" << qdomain << "\", so that " <<
"it can be resolved by GeoIP backend directly."<< std::endl;
Expand Down Expand Up @@ -590,11 +590,11 @@ void GeoIPBackend::reload() {
try {
initialize();
} catch (PDNSException &pex) {
L<<Logger::Error<<"GeoIP backend reload failed: " << pex.reason << endl;
g_log<<Logger::Error<<"GeoIP backend reload failed: " << pex.reason << endl;
} catch (std::exception &stex) {
L<<Logger::Error<<"GeoIP backend reload failed: " << stex.what() << endl;
g_log<<Logger::Error<<"GeoIP backend reload failed: " << stex.what() << endl;
} catch (...) {
L<<Logger::Error<<"GeoIP backend reload failed" << endl;
g_log<<Logger::Error<<"GeoIP backend reload failed" << endl;
}
}

Expand Down Expand Up @@ -861,7 +861,7 @@ class GeoIPLoader {
public:
GeoIPLoader() {
BackendMakers().report(new GeoIPFactory);
L << Logger::Info << "[geoipbackend] This is the geoip backend version " VERSION
g_log << Logger::Info << "[geoipbackend] This is the geoip backend version " VERSION
#ifndef REPRODUCIBLE
<< " (" __DATE__ " " __TIME__ ")"
#endif
Expand Down
Loading