servlib/bundling/BundleDaemon.cc
changeset 26 22859a6c3113
parent 25 082e0ad22355
child 27 28b7fb13e35d
--- 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(&current_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(&current_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<BlockInfo*> (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; 
     }