Commit fcc1b5e1 authored by Michal 'vorner' Vaner's avatar Michal 'vorner' Vaner

[trac901] Port asiodns library to new log interface

parent b6d140b6
...@@ -10,10 +10,15 @@ AM_CXXFLAGS = $(B10_CXXFLAGS) ...@@ -10,10 +10,15 @@ AM_CXXFLAGS = $(B10_CXXFLAGS)
CLEANFILES = *.gcno *.gcda CLEANFILES = *.gcno *.gcda
# Define rule to build logging source files from message file
asiodef.h asiodef.cc: asiodef.msg
$(top_builddir)/src/lib/log/compiler/message $(top_srcdir)/src/lib/asiodns/asiodef.msg
BUILT_SOURCES = asiodef.h asiodef.cc
lib_LTLIBRARIES = libasiodns.la lib_LTLIBRARIES = libasiodns.la
libasiodns_la_SOURCES = dns_answer.h libasiodns_la_SOURCES = dns_answer.h
libasiodns_la_SOURCES += asiodns.h libasiodns_la_SOURCES += asiodns.h
libasiodns_la_SOURCES += asiodef.cc asiodef.h
libasiodns_la_SOURCES += dns_lookup.h libasiodns_la_SOURCES += dns_lookup.h
libasiodns_la_SOURCES += dns_server.h libasiodns_la_SOURCES += dns_server.h
libasiodns_la_SOURCES += dns_service.cc dns_service.h libasiodns_la_SOURCES += dns_service.cc dns_service.h
...@@ -21,6 +26,8 @@ libasiodns_la_SOURCES += tcp_server.cc tcp_server.h ...@@ -21,6 +26,8 @@ libasiodns_la_SOURCES += tcp_server.cc tcp_server.h
libasiodns_la_SOURCES += udp_server.cc udp_server.h libasiodns_la_SOURCES += udp_server.cc udp_server.h
libasiodns_la_SOURCES += io_fetch.cc io_fetch.h libasiodns_la_SOURCES += io_fetch.cc io_fetch.h
nodist_libasiodns_la_SOURCES = asiodef.cc asiodef.h
EXTRA_DIST = asiodef.msg EXTRA_DIST = asiodef.msg
# Note: the ordering matters: -Wno-... must follow -Wextra (defined in # Note: the ordering matters: -Wno-... must follow -Wextra (defined in
......
// File created from asiodef.msg on Mon Feb 28 17:15:30 2011
#include <cstddef>
#include <log/message_types.h>
#include <log/message_initializer.h>
namespace isc {
namespace asiodns {
extern const isc::log::MessageID ASIODNS_FETCHCOMP = "FETCHCOMP";
extern const isc::log::MessageID ASIODNS_FETCHSTOP = "FETCHSTOP";
extern const isc::log::MessageID ASIODNS_OPENSOCK = "OPENSOCK";
extern const isc::log::MessageID ASIODNS_RECVSOCK = "RECVSOCK";
extern const isc::log::MessageID ASIODNS_RECVTMO = "RECVTMO";
extern const isc::log::MessageID ASIODNS_SENDSOCK = "SENDSOCK";
extern const isc::log::MessageID ASIODNS_UNKORIGIN = "UNKORIGIN";
extern const isc::log::MessageID ASIODNS_UNKRESULT = "UNKRESULT";
} // namespace asiodns
} // namespace isc
namespace {
const char* values[] = {
"FETCHCOMP", "upstream fetch to %s(%d) has now completed",
"FETCHSTOP", "upstream fetch to %s(%d) has been stopped",
"OPENSOCK", "error %d opening %s socket to %s(%d)",
"RECVSOCK", "error %d reading %s data from %s(%d)",
"RECVTMO", "receive timeout while waiting for data from %s(%d)",
"SENDSOCK", "error %d sending data using %s to %s(%d)",
"UNKORIGIN", "unknown origin for ASIO error code %d (protocol: %s, address %s)",
"UNKRESULT", "unknown result (%d) when IOFetch::stop() was executed for I/O to %s(%d)",
NULL
};
const isc::log::MessageInitializer initializer(values);
} // Anonymous namespace
// File created from asiodef.msg on Mon Feb 28 17:15:30 2011
#ifndef __ASIODEF_H
#define __ASIODEF_H
#include <log/message_types.h>
namespace isc {
namespace asiodns {
extern const isc::log::MessageID ASIODNS_FETCHCOMP;
extern const isc::log::MessageID ASIODNS_FETCHSTOP;
extern const isc::log::MessageID ASIODNS_OPENSOCK;
extern const isc::log::MessageID ASIODNS_RECVSOCK;
extern const isc::log::MessageID ASIODNS_RECVTMO;
extern const isc::log::MessageID ASIODNS_SENDSOCK;
extern const isc::log::MessageID ASIODNS_UNKORIGIN;
extern const isc::log::MessageID ASIODNS_UNKRESULT;
} // namespace asiodns
} // namespace isc
#endif // __ASIODEF_H
...@@ -15,42 +15,42 @@ ...@@ -15,42 +15,42 @@
$PREFIX ASIODNS_ $PREFIX ASIODNS_
$NAMESPACE isc::asiodns $NAMESPACE isc::asiodns
FETCHCOMP upstream fetch to %s(%d) has now completed FETCHCOMP upstream fetch to %1(%2) has now completed
+ A debug message, this records the the upstream fetch (a query made by the + A debug message, this records the the upstream fetch (a query made by the
+ resolver on behalf of its client) to the specified address has completed. + resolver on behalf of its client) to the specified address has completed.
FETCHSTOP upstream fetch to %s(%d) has been stopped FETCHSTOP upstream fetch to %1(%2) has been stopped
+ An external component has requested the halting of an upstream fetch. This + An external component has requested the halting of an upstream fetch. This
+ is an allowed operation, and the message should only appear if debug is + is an allowed operation, and the message should only appear if debug is
+ enabled. + enabled.
OPENSOCK error %d opening %s socket to %s(%d) OPENSOCK error %1 opening %2 socket to %3(%4)
+ The asynchronous I/O code encountered an error when trying to open a socket + The asynchronous I/O code encountered an error when trying to open a socket
+ of the specified protocol in order to send a message to the target address. + of the specified protocol in order to send a message to the target address.
+ The the number of the system error that cause the problem is given in the + The the number of the system error that cause the problem is given in the
+ message. + message.
RECVSOCK error %d reading %s data from %s(%d) RECVSOCK error %1 reading %2 data from %3(%4)
+ The asynchronous I/O code encountered an error when trying read data from + The asynchronous I/O code encountered an error when trying read data from
+ the specified address on the given protocol. The the number of the system + the specified address on the given protocol. The the number of the system
+ error that cause the problem is given in the message. + error that cause the problem is given in the message.
SENDSOCK error %d sending data using %s to %s(%d) SENDSOCK error %1 sending data using %2 to %3(%4)
+ The asynchronous I/O code encountered an error when trying send data to + The asynchronous I/O code encountered an error when trying send data to
+ the specified address on the given protocol. The the number of the system + the specified address on the given protocol. The the number of the system
+ error that cause the problem is given in the message. + error that cause the problem is given in the message.
RECVTMO receive timeout while waiting for data from %s(%d) RECVTMO receive timeout while waiting for data from %1(%2)
+ An upstream fetch from the specified address timed out. This may happen for + An upstream fetch from the specified address timed out. This may happen for
+ any number of reasons and is most probably a problem at the remote server + any number of reasons and is most probably a problem at the remote server
+ or a problem on the network. The message will only appear if debug is + or a problem on the network. The message will only appear if debug is
+ enabled. + enabled.
UNKORIGIN unknown origin for ASIO error code %d (protocol: %s, address %s) UNKORIGIN unknown origin for ASIO error code %1 (protocol: %2, address %3)
+ This message should not appear and indicates an internal error if it does. + This message should not appear and indicates an internal error if it does.
+ Please enter a bug report. + Please enter a bug report.
UNKRESULT unknown result (%d) when IOFetch::stop() was executed for I/O to %s(%d) UNKRESULT unknown result (%1) when IOFetch::stop() was executed for I/O to %2(%3)
+ The termination method of the resolver's upstream fetch class was called with + The termination method of the resolver's upstream fetch class was called with
+ an unknown result code (which is given in the message). This message should + an unknown result code (which is given in the message). This message should
+ not appear and may indicate an internal error. Please enter a bug report. + not appear and may indicate an internal error. Please enter a bug report.
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include <dns/opcode.h> #include <dns/opcode.h>
#include <dns/rcode.h> #include <dns/rcode.h>
#include <log/logger.h> #include <log/logger.h>
#include <log/macros.h>
#include <asiodns/asiodef.h> #include <asiodns/asiodef.h>
#include <asiodns/io_fetch.h> #include <asiodns/io_fetch.h>
...@@ -339,34 +340,30 @@ IOFetch::stop(Result result) { ...@@ -339,34 +340,30 @@ IOFetch::stop(Result result) {
data_->stopped = true; data_->stopped = true;
switch (result) { switch (result) {
case TIME_OUT: case TIME_OUT:
if (logger.isDebugEnabled(1)) { LOG_DEBUG(logger, 20, ASIODNS_RECVTMO).
logger.debug(20, ASIODNS_RECVTMO, arg(data_->remote_snd->getAddress().toText()).
data_->remote_snd->getAddress().toText().c_str(), arg(data_->remote_snd->getPort());
static_cast<int>(data_->remote_snd->getPort()));
}
break; break;
case SUCCESS: case SUCCESS:
if (logger.isDebugEnabled(50)) { LOG_DEBUG(logger, 50, ASIODNS_FETCHCOMP).
logger.debug(30, ASIODNS_FETCHCOMP, arg(data_->remote_rcv->getAddress().toText()).
data_->remote_rcv->getAddress().toText().c_str(), arg(data_->remote_rcv->getPort());
static_cast<int>(data_->remote_rcv->getPort()));
}
break; break;
case STOPPED: case STOPPED:
// Fetch has been stopped for some other reason. This is // Fetch has been stopped for some other reason. This is
// allowed but as it is unusual it is logged, but with a lower // allowed but as it is unusual it is logged, but with a lower
// debug level than a timeout (which is totally normal). // debug level than a timeout (which is totally normal).
logger.debug(1, ASIODNS_FETCHSTOP, LOG_DEBUG(logger, 1, ASIODNS_FETCHSTOP).
data_->remote_snd->getAddress().toText().c_str(), arg(data_->remote_snd->getAddress().toText()).
static_cast<int>(data_->remote_snd->getPort())); arg(data_->remote_snd->getPort());
break; break;
default: default:
logger.error(ASIODNS_UNKRESULT, static_cast<int>(result), LOG_ERROR(logger, ASIODNS_UNKRESULT).
data_->remote_snd->getAddress().toText().c_str(), arg(data_->remote_snd->getAddress().toText()).
static_cast<int>(data_->remote_snd->getPort())); arg(data_->remote_snd->getPort());
} }
// Stop requested, cancel and I/O's on the socket and shut it down, // Stop requested, cancel and I/O's on the socket and shut it down,
...@@ -394,12 +391,11 @@ void IOFetch::logIOFailure(asio::error_code ec) { ...@@ -394,12 +391,11 @@ void IOFetch::logIOFailure(asio::error_code ec) {
(data_->origin == ASIODNS_UNKORIGIN)); (data_->origin == ASIODNS_UNKORIGIN));
static const char* PROTOCOL[2] = {"TCP", "UDP"}; static const char* PROTOCOL[2] = {"TCP", "UDP"};
logger.error(data_->origin, LOG_ERROR(logger, data_->origin).arg(ec.value()).
ec.value(), arg((data_->remote_snd->getProtocol() == IPPROTO_TCP) ?
((data_->remote_snd->getProtocol() == IPPROTO_TCP) ? PROTOCOL[0] : PROTOCOL[1]).
PROTOCOL[0] : PROTOCOL[1]), arg(data_->remote_snd->getAddress().toText()).
data_->remote_snd->getAddress().toText().c_str(), arg(data_->remote_snd->getPort());
static_cast<int>(data_->remote_snd->getPort()));
} }
} // namespace asiodns } // namespace asiodns
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment