]> git.ipfire.org Git - thirdparty/pdns.git/blobdiff - modules/opendbxbackend/odbxbackend.cc
Logging: have a global g_log
[thirdparty/pdns.git] / modules / opendbxbackend / odbxbackend.cc
index e8d37f1cc99d0442cf342dc08ca98f26a1697916..ae05d5397b9eb46d5617ca33fd0057a8da795ed4 100644 (file)
@@ -60,7 +60,7 @@ OdbxBackend::OdbxBackend( const string& suffix )
 
                if( getArg( "host" ).size() > 0 )
                {
-                       L.log( m_myname + " WARNING: Using deprecated opendbx-host parameter", Logger::Warning );
+                       g_log.log( m_myname + " WARNING: Using deprecated opendbx-host parameter", Logger::Warning );
                        stringtok( m_hosts[READ], getArg( "host" ), ", " );
                        m_hosts[WRITE] = m_hosts[READ];
                }
@@ -75,7 +75,7 @@ OdbxBackend::OdbxBackend( const string& suffix )
         }
         catch( std::exception& e )
         {
-               L.log( m_myname + " OdbxBackend(): Caught STL exception - " + e.what(),  Logger::Error );
+               g_log.log( m_myname + " OdbxBackend(): Caught STL exception - " + e.what(),  Logger::Error );
                throw( PDNSException( "Fatal: STL exception" ) );
         }
 }
@@ -100,7 +100,7 @@ bool OdbxBackend::getDomainInfo( const DNSName& domain, DomainInfo& di )
 
         try
         {
-               DLOG( L.log( m_myname + " getDomainInfo()", Logger::Debug ) );
+               DLOG( g_log.log( m_myname + " getDomainInfo()", Logger::Debug ) );
 
                string stmt = getArg( "sql-zoneinfo" );
                string& stmtref = strbind( ":name", escape( domain.makeLowerCase().toStringRootDot(), READ ), stmt );
@@ -170,7 +170,7 @@ bool OdbxBackend::getDomainInfo( const DNSName& domain, DomainInfo& di )
         }
         catch( std::exception& e )
         {
-               L.log( m_myname + " getDomainInfo: Caught STL std::exception - " + e.what(),  Logger::Error );
+               g_log.log( m_myname + " getDomainInfo: Caught STL std::exception - " + e.what(),  Logger::Error );
                return false;
         }
 
@@ -186,7 +186,7 @@ bool OdbxBackend::getSOA( const DNSName& domain, SOAData& sd, bool unmodifiedSer
 
         try
         {
-               DLOG( L.log( m_myname + " getSOA()", Logger::Debug ) );
+               DLOG( g_log.log( m_myname + " getSOA()", Logger::Debug ) );
 
                string stmt = getArg( "sql-lookupsoa" );
                string& stmtref = strbind( ":name", escape( domain.makeLowerCase().toStringRootDot(), READ ), stmt );
@@ -236,7 +236,7 @@ bool OdbxBackend::getSOA( const DNSName& domain, SOAData& sd, bool unmodifiedSer
         }
         catch( std::exception& e )
         {
-               L.log( m_myname + " getSOA: Caught STL exception - " + e.what(),  Logger::Error );
+               g_log.log( m_myname + " getSOA: Caught STL exception - " + e.what(),  Logger::Error );
                return false;
         }
 
@@ -249,7 +249,7 @@ bool OdbxBackend::list( const DNSName& target, int zoneid, bool include_disabled
 {
         try
         {
-               DLOG( L.log( m_myname + " list()", Logger::Debug ) );
+               DLOG( g_log.log( m_myname + " list()", Logger::Debug ) );
 
                m_qname.clear();
                m_result = NULL;
@@ -258,13 +258,13 @@ bool OdbxBackend::list( const DNSName& target, int zoneid, bool include_disabled
 
                if( len < 0 )
                {
-                       L.log( m_myname + " list: Unable to convert zone id to string - format error",  Logger::Error );
+                       g_log.log( m_myname + " list: Unable to convert zone id to string - format error",  Logger::Error );
                        return false;
                }
 
                if( len > static_cast<int>(sizeof( m_buffer )) - 1 )
                {
-                       L.log( m_myname + " list: Unable to convert zone id to string - insufficient buffer space",  Logger::Error );
+                       g_log.log( m_myname + " list: Unable to convert zone id to string - insufficient buffer space",  Logger::Error );
                        return false;
                }
 
@@ -275,7 +275,7 @@ bool OdbxBackend::list( const DNSName& target, int zoneid, bool include_disabled
         }
         catch( std::exception& e )
         {
-               L.log( m_myname + " list: Caught STL exception - " + e.what(),  Logger::Error );
+               g_log.log( m_myname + " list: Caught STL exception - " + e.what(),  Logger::Error );
                return false;
         }
 
@@ -288,7 +288,7 @@ void OdbxBackend::lookup( const QType& qtype, const DNSName& qname, DNSPacket* d
 {
         try
         {
-               DLOG( L.log( m_myname + " lookup()", Logger::Debug ) );
+               DLOG( g_log.log( m_myname + " lookup()", Logger::Debug ) );
 
                string stmt;
                string& stmtref = stmt;
@@ -320,13 +320,13 @@ void OdbxBackend::lookup( const QType& qtype, const DNSName& qname, DNSPacket* d
 
                        if( len < 0 )
                        {
-                               L.log( m_myname + " lookup: Unable to convert zone id to string - format error",  Logger::Error );
+                               g_log.log( m_myname + " lookup: Unable to convert zone id to string - format error",  Logger::Error );
                                throw( DBException( "Error: Libc error" ) );
                        }
 
                        if( len > static_cast<int>(sizeof( m_buffer )) - 1 )
                        {
-                               L.log( m_myname + " lookup: Unable to convert zone id to string - insufficient buffer space",  Logger::Error );
+                               g_log.log( m_myname + " lookup: Unable to convert zone id to string - insufficient buffer space",  Logger::Error );
                                throw( DBException( "Error: Libc error" ) );
                }
 
@@ -342,7 +342,7 @@ void OdbxBackend::lookup( const QType& qtype, const DNSName& qname, DNSPacket* d
         }
         catch( std::exception& e )
         {
-               L.log( m_myname + " lookup: Caught STL exception - " + e.what(),  Logger::Error );
+               g_log.log( m_myname + " lookup: Caught STL exception - " + e.what(),  Logger::Error );
                throw( DBException( "Error: STL exception" ) );
         }
 }
@@ -356,7 +356,7 @@ bool OdbxBackend::get( DNSResourceRecord& rr )
 
         try
         {
-               DLOG( L.log( m_myname + " get()", Logger::Debug ) );
+               DLOG( g_log.log( m_myname + " get()", Logger::Debug ) );
 
                if( getRecord( READ ) )
                {
@@ -405,7 +405,7 @@ bool OdbxBackend::get( DNSResourceRecord& rr )
         }
         catch( std::exception& e )
         {
-               L.log( m_myname + " get: Caught STL exception - " + e.what(),  Logger::Error );
+               g_log.log( m_myname + " get: Caught STL exception - " + e.what(),  Logger::Error );
                return false;
         }
 
@@ -420,11 +420,11 @@ void OdbxBackend::setFresh( uint32_t domain_id )
 
         try
         {
-               DLOG( L.log( m_myname + " setFresh()", Logger::Debug ) );
+               DLOG( g_log.log( m_myname + " setFresh()", Logger::Debug ) );
 
                if( !m_handle[WRITE] && !connectTo( m_hosts[WRITE], WRITE ) )
                {
-                       L.log( m_myname + " setFresh: Master server is unreachable",  Logger::Error );
+                       g_log.log( m_myname + " setFresh: Master server is unreachable",  Logger::Error );
                        throw( DBException( "Error: Server unreachable" ) );
                }
 
@@ -432,13 +432,13 @@ void OdbxBackend::setFresh( uint32_t domain_id )
 
                if( len < 0 )
                {
-                       L.log( m_myname + " setFresh: Unable to insert values into statement '" + getArg( "sql-update-lastcheck" ) + "' - format error",  Logger::Error );
+                       g_log.log( m_myname + " setFresh: Unable to insert values into statement '" + getArg( "sql-update-lastcheck" ) + "' - format error",  Logger::Error );
                        throw( DBException( "Error: Libc error" ) );
                }
 
                if( len > static_cast<int>(sizeof( m_buffer )) - 1 )
                {
-                       L.log( m_myname + " setFresh: Unable to insert values into statement '" + getArg( "sql-update-lastcheck" ) + "' - insufficient buffer space",  Logger::Error );
+                       g_log.log( m_myname + " setFresh: Unable to insert values into statement '" + getArg( "sql-update-lastcheck" ) + "' - insufficient buffer space",  Logger::Error );
                        throw( DBException( "Error: Libc error" ) );
                }
 
@@ -449,7 +449,7 @@ void OdbxBackend::setFresh( uint32_t domain_id )
         }
         catch ( std::exception& e )
         {
-               L.log( m_myname + " setFresh: Caught STL exception - " + e.what(),  Logger::Error );
+               g_log.log( m_myname + " setFresh: Caught STL exception - " + e.what(),  Logger::Error );
                throw( DBException( "Error: STL exception" ) );
         }
 }
@@ -460,11 +460,11 @@ void OdbxBackend::setNotified( uint32_t domain_id, uint32_t serial )
 {
         try
         {
-               DLOG( L.log( m_myname + " setNotified()", Logger::Debug ) );
+               DLOG( g_log.log( m_myname + " setNotified()", Logger::Debug ) );
 
                if( !m_handle[WRITE] && !connectTo( m_hosts[WRITE], WRITE ) )
                {
-                       L.log( m_myname + " setFresh: Master server is unreachable",  Logger::Error );
+                       g_log.log( m_myname + " setFresh: Master server is unreachable",  Logger::Error );
                        throw( DBException( "Error: Server unreachable" ) );
                }
 
@@ -472,13 +472,13 @@ void OdbxBackend::setNotified( uint32_t domain_id, uint32_t serial )
 
                if( len < 0 )
                {
-                       L.log( m_myname + " setNotified: Unable to insert values into statement '" + getArg( "sql-update-serial" ) + "' - format error",  Logger::Error );
+                       g_log.log( m_myname + " setNotified: Unable to insert values into statement '" + getArg( "sql-update-serial" ) + "' - format error",  Logger::Error );
                        throw( DBException( "Error: Libc error" ) );
                }
 
                if( len > static_cast<int>(sizeof( m_buffer )) - 1 )
                {
-                       L.log( m_myname + " setNotified: Unable to insert values into statement '" + getArg( "sql-update-serial" ) + "' - insufficient buffer space",  Logger::Error );
+                       g_log.log( m_myname + " setNotified: Unable to insert values into statement '" + getArg( "sql-update-serial" ) + "' - insufficient buffer space",  Logger::Error );
                        throw( DBException( "Error: Libc error" ) );
                }
 
@@ -489,7 +489,7 @@ void OdbxBackend::setNotified( uint32_t domain_id, uint32_t serial )
         }
         catch ( std::exception& e )
         {
-               L.log( m_myname + " setNotified: Caught STL exception - " + e.what(),  Logger::Error );
+               g_log.log( m_myname + " setNotified: Caught STL exception - " + e.what(),  Logger::Error );
                throw( DBException( "Error: STL exception" ) );
         }
 }
@@ -500,7 +500,7 @@ bool OdbxBackend::isMaster( const DNSName& domain, const string& ip )
 {
         try
         {
-               DLOG( L.log( m_myname + " isMaster()", Logger::Debug ) );
+               DLOG( g_log.log( m_myname + " isMaster()", Logger::Debug ) );
 
                string stmt = getArg( "sql-master" );
                string& stmtref = strbind( ":name", escape( domain.makeLowerCase().toStringRootDot(), READ ), stmt );
@@ -523,7 +523,7 @@ bool OdbxBackend::isMaster( const DNSName& domain, const string& ip )
         }
         catch ( std::exception& e )
         {
-               L.log( m_myname + " isMaster: Caught STL exception - " + e.what(),  Logger::Error );
+               g_log.log( m_myname + " isMaster: Caught STL exception - " + e.what(),  Logger::Error );
                return false;
         }
 
@@ -536,11 +536,11 @@ void OdbxBackend::getUnfreshSlaveInfos( vector<DomainInfo>* unfresh )
 {
         try
         {
-               DLOG( L.log( m_myname + " getUnfreshSlaveInfos()", Logger::Debug ) );
+               DLOG( g_log.log( m_myname + " getUnfreshSlaveInfos()", Logger::Debug ) );
 
                if( unfresh == NULL )
                {
-                       L.log( m_myname + " getUnfreshSlaveInfos: invalid parameter - NULL pointer",  Logger::Error );
+                       g_log.log( m_myname + " getUnfreshSlaveInfos: invalid parameter - NULL pointer",  Logger::Error );
                        return;
                }
 
@@ -548,7 +548,7 @@ void OdbxBackend::getUnfreshSlaveInfos( vector<DomainInfo>* unfresh )
         }
         catch ( std::exception& e )
         {
-               L.log( m_myname + " getUnfreshSlaveInfo: Caught STL exception - " + e.what(),  Logger::Error );
+               g_log.log( m_myname + " getUnfreshSlaveInfo: Caught STL exception - " + e.what(),  Logger::Error );
         }
 }
 
@@ -558,11 +558,11 @@ void OdbxBackend::getUpdatedMasters( vector<DomainInfo>* updated )
 {
         try
         {
-               DLOG( L.log( m_myname + " getUpdatedMasters()", Logger::Debug ) );
+               DLOG( g_log.log( m_myname + " getUpdatedMasters()", Logger::Debug ) );
 
                if( updated == NULL )
                {
-                       L.log( m_myname + " getUpdatedMasters: invalid parameter - NULL pointer",  Logger::Error );
+                       g_log.log( m_myname + " getUpdatedMasters: invalid parameter - NULL pointer",  Logger::Error );
                        return;
                }
 
@@ -570,7 +570,7 @@ void OdbxBackend::getUpdatedMasters( vector<DomainInfo>* updated )
         }
         catch ( std::exception& e )
         {
-               L.log( m_myname + " getUpdatedMasters: Caught STL exception - " + e.what(),  Logger::Error );
+               g_log.log( m_myname + " getUpdatedMasters: Caught STL exception - " + e.what(),  Logger::Error );
         }
 }
 
@@ -580,7 +580,7 @@ bool OdbxBackend::superMasterBackend( const string& ip, const DNSName& domain, c
 {
         try
         {
-               DLOG( L.log( m_myname + " superMasterBackend()", Logger::Debug ) );
+               DLOG( g_log.log( m_myname + " superMasterBackend()", Logger::Debug ) );
 
                if( account != NULL && ddb != NULL )
                {
@@ -611,7 +611,7 @@ bool OdbxBackend::superMasterBackend( const string& ip, const DNSName& domain, c
         }
         catch ( std::exception& e )
         {
-               L.log( m_myname + " superMasterBackend: Caught STL exception - " + e.what(),  Logger::Error );
+               g_log.log( m_myname + " superMasterBackend: Caught STL exception - " + e.what(),  Logger::Error );
                return false;
         }
 
@@ -624,11 +624,11 @@ bool OdbxBackend::createSlaveDomain( const string& ip, const DNSName& domain, co
 {
         try
         {
-               DLOG( L.log( m_myname + " createSlaveDomain()", Logger::Debug ) );
+               DLOG( g_log.log( m_myname + " createSlaveDomain()", Logger::Debug ) );
 
                if( !m_handle[WRITE] && !connectTo( m_hosts[WRITE], WRITE ) )
                {
-                       L.log( m_myname + " createSlaveDomain: Master server is unreachable",  Logger::Error );
+                       g_log.log( m_myname + " createSlaveDomain: Master server is unreachable",  Logger::Error );
                        return false;
                }
 
@@ -637,13 +637,13 @@ bool OdbxBackend::createSlaveDomain( const string& ip, const DNSName& domain, co
 
                if( len < 0 )
                {
-                       L.log( m_myname + " createSlaveDomain: Unable to insert values in statement '" + getArg( "sql-insert-slave" ) + "' - format error",  Logger::Error );
+                       g_log.log( m_myname + " createSlaveDomain: Unable to insert values in statement '" + getArg( "sql-insert-slave" ) + "' - format error",  Logger::Error );
                        return false;
                }
 
                if( len > static_cast<int>(sizeof( m_buffer )) - 1 )
                {
-                       L.log( m_myname + " createSlaveDomain: Unable to insert values in statement '" + getArg( "sql-insert-slave" ) + "' - insufficient buffer space",  Logger::Error );
+                       g_log.log( m_myname + " createSlaveDomain: Unable to insert values in statement '" + getArg( "sql-insert-slave" ) + "' - insufficient buffer space",  Logger::Error );
                        return false;
                }
 
@@ -651,7 +651,7 @@ bool OdbxBackend::createSlaveDomain( const string& ip, const DNSName& domain, co
         }
         catch ( std::exception& e )
         {
-               L.log( m_myname + " createSlaveDomain: Caught STL exception - " + e.what(),  Logger::Error );
+               g_log.log( m_myname + " createSlaveDomain: Caught STL exception - " + e.what(),  Logger::Error );
                return false;
         }
 
@@ -664,11 +664,11 @@ bool OdbxBackend::feedRecord( const DNSResourceRecord& rr, const DNSName& ordern
 {
         try
         {
-               DLOG( L.log( m_myname + " feedRecord()", Logger::Debug ) );
+               DLOG( g_log.log( m_myname + " feedRecord()", Logger::Debug ) );
 
                if( !m_handle[WRITE] && !connectTo( m_hosts[WRITE], WRITE ) )
                {
-                       L.log( m_myname + " feedRecord: Master server is unreachable",  Logger::Error );
+                       g_log.log( m_myname + " feedRecord: Master server is unreachable",  Logger::Error );
                        return false;
                }
 
@@ -689,13 +689,13 @@ bool OdbxBackend::feedRecord( const DNSResourceRecord& rr, const DNSName& ordern
 
                if( len < 0 )
                {
-                       L.log( m_myname + " feedRecord: Unable to insert values in statement '" + getArg( "sql-insert-record" ) + "' - format error",  Logger::Error );
+                       g_log.log( m_myname + " feedRecord: Unable to insert values in statement '" + getArg( "sql-insert-record" ) + "' - format error",  Logger::Error );
                        return false;
                }
 
                if( len > static_cast<int>(sizeof( m_buffer )) - 1 )
                {
-                       L.log( m_myname + " feedRecord: Unable to insert values in statement '" + getArg( "sql-insert-record" ) + "' - insufficient buffer space",  Logger::Error );
+                       g_log.log( m_myname + " feedRecord: Unable to insert values in statement '" + getArg( "sql-insert-record" ) + "' - insufficient buffer space",  Logger::Error );
                        return false;
                }
 
@@ -703,7 +703,7 @@ bool OdbxBackend::feedRecord( const DNSResourceRecord& rr, const DNSName& ordern
         }
         catch ( std::exception& e )
         {
-               L.log( m_myname + " feedRecord: Caught STL exception - " + e.what(),  Logger::Error );
+               g_log.log( m_myname + " feedRecord: Caught STL exception - " + e.what(),  Logger::Error );
                return false;
         }
 
@@ -716,11 +716,11 @@ bool OdbxBackend::startTransaction( const DNSName& domain, int zoneid )
 {
         try
         {
-               DLOG( L.log( m_myname + " startTransaction()", Logger::Debug ) );
+               DLOG( g_log.log( m_myname + " startTransaction()", Logger::Debug ) );
 
                if( !m_handle[WRITE] && !connectTo( m_hosts[WRITE], WRITE ) )
                {
-                       L.log( m_myname + " startTransaction: Master server is unreachable",  Logger::Error );
+                       g_log.log( m_myname + " startTransaction: Master server is unreachable",  Logger::Error );
                        return false;
                }
 
@@ -730,13 +730,13 @@ bool OdbxBackend::startTransaction( const DNSName& domain, int zoneid )
 
                if( len < 0 )
                {
-                       L.log( m_myname + " startTransaction: Unable to convert zone id to string - format error",  Logger::Error );
+                       g_log.log( m_myname + " startTransaction: Unable to convert zone id to string - format error",  Logger::Error );
                        return false;
                }
 
                if( len > static_cast<int>(sizeof( m_buffer )) - 1 )
                {
-                       L.log( m_myname + " startTransaction: Unable to convert zone id to string - insufficient buffer space",  Logger::Error );
+                       g_log.log( m_myname + " startTransaction: Unable to convert zone id to string - insufficient buffer space",  Logger::Error );
                        return false;
                }
 
@@ -748,7 +748,7 @@ bool OdbxBackend::startTransaction( const DNSName& domain, int zoneid )
         }
         catch ( std::exception& e )
         {
-               L.log( m_myname + " startTransaction: Caught STL exception - " + e.what(),  Logger::Error );
+               g_log.log( m_myname + " startTransaction: Caught STL exception - " + e.what(),  Logger::Error );
                return false;
         }
 
@@ -761,11 +761,11 @@ bool OdbxBackend::commitTransaction()
 {
         try
         {
-               DLOG( L.log( m_myname + " commitTransaction()", Logger::Debug ) );
+               DLOG( g_log.log( m_myname + " commitTransaction()", Logger::Debug ) );
 
                if( !m_handle[WRITE] && !connectTo( m_hosts[WRITE], WRITE ) )
                {
-                       L.log( m_myname + " commitTransaction: Master server is unreachable",  Logger::Error );
+                       g_log.log( m_myname + " commitTransaction: Master server is unreachable",  Logger::Error );
                        return false;
                }
 
@@ -774,7 +774,7 @@ bool OdbxBackend::commitTransaction()
         }
         catch ( std::exception& e )
         {
-               L.log( m_myname + " commitTransaction: Caught STL exception - " + e.what(),  Logger::Error );
+               g_log.log( m_myname + " commitTransaction: Caught STL exception - " + e.what(),  Logger::Error );
                return false;
         }
 
@@ -787,11 +787,11 @@ bool OdbxBackend::abortTransaction()
 {
         try
         {
-               DLOG( L.log( m_myname + " abortTransaction()", Logger::Debug ) );
+               DLOG( g_log.log( m_myname + " abortTransaction()", Logger::Debug ) );
 
                if( !m_handle[WRITE] && !connectTo( m_hosts[WRITE], WRITE ) )
                {
-                       L.log( m_myname + " abortTransaction: Master server is unreachable",  Logger::Error );
+                       g_log.log( m_myname + " abortTransaction: Master server is unreachable",  Logger::Error );
                        return false;
                }
 
@@ -800,7 +800,7 @@ bool OdbxBackend::abortTransaction()
         }
         catch ( std::exception& e )
         {
-               L.log( m_myname + " abortTransaction: Caught STL exception - " + e.what(),  Logger::Error );
+               g_log.log( m_myname + " abortTransaction: Caught STL exception - " + e.what(),  Logger::Error );
                return false;
         }