# HG changeset patch # User aidan # Date 1309443973 -3600 # Node ID 22859a6c31132f1a51f924f4f5fa9c1bb4cb5496 # Parent 082e0ad223553ed113f4c30b45b8e2312367c497 updated daemon logging diff -r 082e0ad22355 -r 22859a6c3113 servlib/bundling/BundleDaemon.cc --- a/servlib/bundling/BundleDaemon.cc Thu Jun 30 15:16:43 2011 +0100 +++ b/servlib/bundling/BundleDaemon.cc Thu Jun 30 15:26:13 2011 +0100 @@ -384,7 +384,7 @@ BPQBlock* bpq_block, bool add_to_store) { - log_info("accept_bpq_response bundle *%p", bundle); + log_info_p("/dtn/daemon/bpq", "accept_bpq_response bundle *%p", bundle); ASSERT ( bpq_block->kind() == BPQBlock::KIND_RESPONSE ); @@ -404,7 +404,8 @@ // or just leave the cache as is and don't add the received bundle if ( bpq_block->match(¤t_bpq) ) { if ( current_bundle->creation_ts() < bundle->creation_ts() ) { - log_info("accept_bpq_response: remove old copy from cache"); + log_info_p("/dtn/daemon/bpq", + "accept_bpq_response: remove old copy from cache"); if ( current_bundle->in_datastore() ) { actions_->store_del(current_bundle); @@ -418,7 +419,7 @@ } } - log_debug("accept_bpq_response: check expiration for bundle"); + log_debug_p("/dtn/daemon/bpq", "accept_bpq_response: check expiration for bundle"); struct timeval now; gettimeofday(&now, 0); @@ -432,19 +433,19 @@ long int when = expiration_time.tv_sec - now.tv_sec; if (when > 0) { - log_debug("scheduling expiration for bundle id %d at %u.%u " + log_debug_p("/dtn/daemon/bpq", "scheduling expiration for bundle id %d at %u.%u " "(in %lu seconds)", bundle->bundleid(), (u_int)expiration_time.tv_sec, (u_int)expiration_time.tv_usec, when); - log_info("accept_bpq_response: add new response to cache - Query: %s", + log_info_p("/dtn/daemon/bpq", "accept_bpq_response: add new response to cache - Query: %s", (char*)bpq_block->query_val()); add_bundle_to_bpq_cache(bundle, add_to_store); } else { - log_warn("scheduling IMMEDIATE expiration for bundle id %d: " + log_warn_p("/dtn/daemon/bpq", "scheduling IMMEDIATE expiration for bundle id %d: " "[expiration %llu, creation time %llu.%llu, offset %u, now %u.%u]", bundle->bundleid(), bundle->expiration(), bundle->creation_ts().seconds_, @@ -457,7 +458,7 @@ bundle->set_expiration_timer(new ExpirationTimer(bundle)); bundle->expiration_timer()->schedule_at(&expiration_time); - log_info("BPQ bundle cache now contains %d bundle(s)", bpq_bundles_->size()); + log_info_p("/dtn/daemon/bpq", "BPQ bundle cache now contains %d bundle(s)", bpq_bundles_->size()); return true; } @@ -521,7 +522,7 @@ bool BundleDaemon::answer_bpq_query(Bundle* bundle, BPQBlock* bpq_block) { - log_info("answer_bpq_query bundle *%p", bundle); + log_info_p("/dtn/daemon/bpq", "answer_bpq_query bundle *%p", bundle); ASSERT ( bpq_block->kind() == BPQBlock::KIND_QUERY ); @@ -537,7 +538,7 @@ BPQBlock current_bpq(current_bundle); if ( bpq_block->match(¤t_bpq) ) { - log_info("answer_bpq_query: match successful"); + log_info_p("/dtn/daemon/bpq", "answer_bpq_query: match successful"); Bundle* response = new Bundle(); BPQResponse::create_bpq_response(response, @@ -554,54 +555,10 @@ } } - log_info("answer_bpq_query: no response was found for the BPQ query"); + log_info_p("/dtn/daemon/bpq", "answer_bpq_query: no response was found for the BPQ query"); return false; } -//TODO: remvoe this function -void -BundleDaemon::print_cache() -{ - oasys::ScopeLock l(bpq_bundles_->lock(), - "BundleDaemon::accept_bpq_response"); - - int i=0; - BundleList::iterator iter; - for (iter = bpq_bundles_->begin(); - iter != bpq_bundles_->end(); - ++iter) - { -/* - Bundle* bundle = *iter; - if (log_enabled(oasys::LOG_DEBUG)) { - oasys::StaticStringBuffer<1024> buf; - buf.appendf("_CACHE_ BUNDLE\n"); - bundle->format_verbose(&buf); - log_multiline(oasys::LOG_DEBUG, buf.c_str()); - } -*/ - - Bundle* current_bundle = *iter; - - if ( (! current_bundle->recv_blocks(). - has_block(BundleProtocol::QUERY_EXTENSION_BLOCK) ) && - (! current_bundle->api_blocks()-> - has_block(BundleProtocol::QUERY_EXTENSION_BLOCK) ) ) { - - log_debug("_CACHE_ error cache bundle does not contain BPQ block"); - } - - BPQBlock bpq(current_bundle); - log_debug("_CACHE_ (%d) kind(%d) query_len(%d) query(%s)", - i+1, bpq.kind(), bpq.query_len(), bpq.query_val()); - i++; - } - if ( i==0 ) - log_debug("_CACHE_ empty"); -} - - - //---------------------------------------------------------------------- void BundleDaemon::deliver_to_registration(Bundle* bundle, @@ -2680,13 +2637,13 @@ } else if ( event->source_ == EVENTSRC_STORE && bundle->in_bpq_cache() ) { - log_info("handle_bpq_block: cache bundle from STORE"); + log_info_p("/dtn/daemon/bpq", "handle_bpq_block: cache bundle from STORE"); BPQBlock bpq_block(bundle); accept_bpq_response(bundle, &bpq_block, false); return true; } else { - log_debug("BPQ Block not found in bundle"); + log_debug_p("/dtn/daemon/bpq", "BPQ Block not found in bundle"); return false; } @@ -2696,7 +2653,7 @@ ASSERT ( block != NULL ); BPQBlock bpq_block(const_cast (block) ); - log_info("handle_bpq_block: Kind: %d Query: %s", + log_info_p("/dtn/daemon/bpq", "handle_bpq_block: Kind: %d Query: %s", (int) bpq_block.kind(), (char*)bpq_block.query_val()); @@ -2709,7 +2666,7 @@ accept_bpq_response(bundle, &bpq_block, event->source_ != EVENTSRC_STORE); } else { - log_err("ERROR - BPQ Block: invalid kind %d", bpq_block.kind()); + log_err_p("/dtn/daemon/bpq", "ERROR - BPQ Block: invalid kind %d", bpq_block.kind()); return false; }