const int max_address_resolution_attempts,
const std::string &cache_file)
{
- GlobalLogger.info() << "Creating DNS Cache";
+ GlobalLogger.info() << "DnsMaster: Creating cache";
DnsCacheItem cache( new DnsCache(io_serv, cache_file) );
create_master(io_serv, default_name_server, resolved_ip_ttl_threshold,
max_address_resolution_attempts, cache);
{
if (TheOnlyInstance)
{
- GlobalLogger.warning()
- << "Blocking attempt to create another DnsMaster instance!";
+ GlobalLogger.warning() << "DnsMaster: "
+ << "Blocking attempt to create another instance!";
return;
}
- GlobalLogger.info() << "Creating DNS Master";
+ GlobalLogger.info() << "DNS Master: creating instance";
TheOnlyInstance.reset( new DnsMaster(io_serv,
default_name_server,
resolved_ip_ttl_threshold,
DnsMasterItem& DnsMaster::get_instance()
{
if ( !TheOnlyInstance )
- GlobalLogger.error()
- << "Request to return DnsMaster instance before creating it!";
+ GlobalLogger.error() << "DnsMaster: "
+ << "Request to return instance before creating it!";
return TheOnlyInstance;
}
DnsMaster::~DnsMaster()
{
- GlobalLogger.info() << "DnsMaster is being destructed";
+ GlobalLogger.info() << "DnsMaster: being destructed";
if (DnsMaster::TheOnlyInstance)
{ // apparently, this static variable still exists while itself is
// destructed...
- //GlobalLogger.warning() << "DnsMaster is being destructed that is not "
+ //GlobalLogger.warning() << "DnsMaster: being destructed but not "
// << "singleton instance TheOnlyInstance!";
DnsMaster::TheOnlyInstance.reset();
}
= boost::asio::ip::address::from_string(hostname);
if ( (protocol == DNS_IPv4 && !ip.is_v4()) ||
(protocol == DNS_IPv6 && !ip.is_v6()) )
- GlobalLogger.warning() << "Asked to create a DNS resolver "
+ GlobalLogger.warning() << "DnsMaster:"
+ << "Asked to create a DNS resolver "
<< "for wrong IP protocol: v4 != v6! "
<< "We will comply.";
- GlobalLogger.info() << "Creating PseudoResolver for IP " << ip;
+ GlobalLogger.info() << "DnsMaster: Creating PseudoResolver for IP "
+ << ip;
ResolverItem new_resolver( new IpPseudoResolver(IoService,
hostname,
Cache) );
case PingProtocol_TCP: return DNS_IPv4; break;
case PingProtocol_TCP_IPv6: return DNS_IPv6; break;
default:
- GlobalLogger.warning() << "Unexpected ping protocol: "
+ GlobalLogger.warning() << "DnsMaster: Unexpected ping protocol: "
<< static_cast<int>(pprot);
return DNS_IPALL;
break;
return "Unexpected Protocol"; break;
}
}
-// (created using vim -- the world's best text editor)
-
* @brief Parameterized constructor.
*
* @param io_serv The one @c io_serv object that controls async processing
- * @param network_interface The name of the network interface originating the pings.
+ * @param network_interface The name of the network interface sending the pings.
* @param destination_address The remote address to ping.
* @param destination_port The remote port to ping.
* @param ping_protocol_list A list of protocols to use.
NextPingTimer( *io_serv ),
TimeSentLastPing( microsec_clock::universal_time() ),
PingReplyTimeout( ping_reply_timeout ),
- HostAnalyzer( destination_address, ping_fail_percentage_limit, link_analyzer ),
+ HostAnalyzer( destination_address, ping_fail_percentage_limit,
+ link_analyzer ),
Resolver(),
Ping(),
WantToPing( false ),
void PingScheduler::stop_pinging()
{
- // stop pinger, which will probably call ping_done_handler --> re-new NextPingTimer
- GlobalLogger.debug() << "scheduler: stop pinging" << endl;
+ // stop pinger and resolver
+ GlobalLogger.debug() << LogPrefix << "scheduler: stop pinging";
Ping->stop_pinging();
Resolver->cancel_resolve();
- // now cancel the own timer
- GlobalLogger.debug() << "scheduler: cancel timer" << endl;
+ // now cancel the own timer in case that pinger cancelation called callback
+ GlobalLogger.debug() << LogPrefix << "scheduler: cancel timer";
NextPingTimer.cancel();
}
void PingScheduler::start_pinging()
{
if ( FirstDelay > 0 )
- GlobalLogger.info() << "Delaying first ping by " << FirstDelay << "s";
+ GlobalLogger.info() << LogPrefix << "Delaying first ping by "
+ << FirstDelay << "s";
else
- GlobalLogger.info() << "Schedule ping as soon as possible";
+ GlobalLogger.info() << LogPrefix << "Schedule ping as soon as possible";
(void) NextPingTimer.expires_from_now( seconds( FirstDelay ) );
NextPingTimer.async_wait( bind( &PingScheduler::ping, this,
if ( error )
{ // get here, e.g. by NextPingTimer.cancel in stop_pinging
if ( error == boost::asio::error::operation_aborted )
- GlobalLogger.error() << "Timer for ping was cancelled! "
- << "Stopping" << endl;
+ GlobalLogger.error() << LogPrefix << "Timer for ping was cancelled!"
+ << " --> Stopping";
else
- GlobalLogger.error() << "Received error " << error
- << " waiting for ping! Stopping"
- << endl;
+ GlobalLogger.error() << LogPrefix << "Received error " << error
+ << " waiting for ping! Stopping";
return;
}
{
if ( !WantToPing )
{
- GlobalLogger.info() << "PingScheduler: not pinging (not requested to)";
+ GlobalLogger.info() << LogPrefix << "not pinging (not requested to)";
return;
}
else if ( Resolver && Resolver->is_resolving() )
{
- GlobalLogger.info() << "PingScheduler: not pinging (DNS not finished)";
+ GlobalLogger.info() << LogPrefix << "not pinging (DNS not finished)";
return;
}
else if ( !Resolver )
// should not happen, but check anyway
GlobalLogger.warning() << LogPrefix << "Have no resolver!";
- GlobalLogger.info() << "PingScheduler: start ping";
+ GlobalLogger.info() << LogPrefix << "start ping";
WantToPing = false;
// try to get an up-to-date IP
{
PingIntervalInSec.speed_up();
- GlobalLogger.debug() << "- Speeding up ping interval to: " << PingIntervalInSec << "s"
- << endl;
+ GlobalLogger.debug() << LogPrefix << "- Speeding up ping interval to: "
+ << PingIntervalInSec << "s";
}
else
{
PingIntervalInSec.back_to_original();
- GlobalLogger.debug() << "- Stick to the original ping interval: " << PingIntervalInSec << "s"
- << endl;
+ GlobalLogger.debug() << LogPrefix << "- Stick to the original ping "
+ << "interval: " << PingIntervalInSec << "s";
}
}
ptime now = microsec_clock::universal_time();
time_resolution_traits_adapted64_impl::int_type elapsed_time_in_sec =
(now - TimeSentLastPing).total_seconds();
- GlobalLogger.debug() << "- Time elapsed since last ping: " << elapsed_time_in_sec << "s" << endl;
+ GlobalLogger.debug() << LogPrefix << "- Time elapsed since last ping: "
+ << elapsed_time_in_sec << "s";
TimeSentLastPing = microsec_clock::universal_time();
}
bool PingScheduler::can_change_ping_protocol() const
{
- // TODO can_change_ping_protocol() and get_next_ping_protocol() may be implemented in a Algorithm
- // class that can be exchanged in this class to provide an algorithm neutral class
+ // TODO can_change_ping_protocol() and get_next_ping_protocol() may be
+ // implemented in a Algorithm class that can be exchanged in this class to
+ // provide an algorithm neutral class
return true;
}
{
if (Resolver && Resolver->is_resolving())
{
- GlobalLogger.warning() << "Resolver still seems to be resolving "
- << "--> cancel!";
+ GlobalLogger.warning() << LogPrefix
+ << "Resolver still seems to be resolving --> cancel!";
Resolver->cancel_resolve();
}
if ( Resolver->have_up_to_date_ip() )
{
if (!Resolver->is_resolving())
- GlobalLogger.warning() << "PingScheduler: have up to date IPs but "
+ GlobalLogger.warning() << LogPrefix << "have up to date IPs but "
<< "resolver seems to be resolving all the same... "
<< "Start pinging anyway!";
ping_when_ready();
void PingScheduler::dns_resolve_callback(const bool was_success,
const int cname_count)
{
- GlobalLogger.info() << "PingScheduler: dns resolution finished "
+ GlobalLogger.info() << LogPrefix << "dns resolution finished "
<< "with success = " << was_success << " "
<< "and cname_count = " << cname_count;