Index: pjproject/trunk/pjsip/src/pjsua-lib/pjsua_pres.c
===================================================================
--- pjproject/trunk/pjsip/src/pjsua-lib/pjsua_pres.c	(revision 3553)
+++ pjproject/trunk/pjsip/src/pjsua-lib/pjsua_pres.c	(revision 3753)
@@ -390,4 +390,8 @@
 		     PJ_ETOOMANY);
 
+    PJ_LOG(4,(THIS_FILE, "Adding buddy: %.*s",
+	      (int)cfg->uri.slen, cfg->uri.ptr));
+    pj_log_push_indent();
+
     PJSUA_LOCK();
 
@@ -403,4 +407,5 @@
 	/* This shouldn't happen */
 	pj_assert(!"index < PJ_ARRAY_SIZE(pjsua_var.buddy)");
+	pj_log_pop_indent();
 	return PJ_ETOOMANY;
     }
@@ -432,4 +437,5 @@
 	buddy->pool = NULL;
 	PJSUA_UNLOCK();
+	pj_log_pop_indent();
 	return PJSIP_EINVALIDURI;
     }
@@ -440,4 +446,5 @@
 	buddy->pool = NULL;
 	PJSUA_UNLOCK();
+	pj_log_pop_indent();
 	return PJSIP_EINVALIDSCHEME;
     }
@@ -470,6 +477,9 @@
     PJSUA_UNLOCK();
 
+    PJ_LOG(4,(THIS_FILE, "Buddy %d added.", index));
+
     pjsua_buddy_subscribe_pres(index, cfg->subscribe);
 
+    pj_log_pop_indent();
     return PJ_SUCCESS;
 }
@@ -495,4 +505,7 @@
     if (status != PJ_SUCCESS)
 	return status;
+
+    PJ_LOG(4,(THIS_FILE, "Buddy %d: deleting..", buddy_id));
+    pj_log_push_indent();
 
     /* Unsubscribe presence */
@@ -519,4 +532,5 @@
 
     unlock_buddy(&lck);
+    pj_log_pop_indent();
     return PJ_SUCCESS;
 }
@@ -538,4 +552,7 @@
 	return status;
 
+    PJ_LOG(4,(THIS_FILE, "Buddy %d: unsubscribing presence..", buddy_id));
+    pj_log_push_indent();
+
     lck.buddy->monitor = subscribe;
 
@@ -543,4 +560,5 @@
 
     unlock_buddy(&lck);
+    pj_log_pop_indent();
     return PJ_SUCCESS;
 }
@@ -560,4 +578,7 @@
     if (status != PJ_SUCCESS)
 	return status;
+
+    PJ_LOG(4,(THIS_FILE, "Buddy %d: updating presence..", buddy_id));
+    pj_log_push_indent();
 
     /* Is this an unsubscribe request? */
@@ -565,4 +586,5 @@
 	unsubscribe_buddy_presence(buddy_id);
 	unlock_buddy(&lck);
+	pj_log_pop_indent();
 	return PJ_SUCCESS;
     }
@@ -571,4 +593,5 @@
     if (lck.buddy->sub) {
 	unlock_buddy(&lck);
+	pj_log_pop_indent();
 	return PJ_SUCCESS;
     }
@@ -578,5 +601,5 @@
 
     unlock_buddy(&lck);
-
+    pj_log_pop_indent();
     return PJ_SUCCESS;
 }
@@ -746,4 +769,5 @@
 	PJ_LOG(4,(THIS_FILE, "Server subscription to %s is %s",
 		  uapres->remote, pjsip_evsub_get_state_name(sub)));
+	pj_log_push_indent();
 
 	state = pjsip_evsub_get_state(sub);
@@ -762,4 +786,5 @@
 	    pj_list_erase(uapres);
 	}
+	pj_log_pop_indent();
     }
 
@@ -807,4 +832,5 @@
     PJ_LOG(4,(THIS_FILE, "Creating server subscription, using account %d",
 	      acc_id));
+    pj_log_push_indent();
     
     /* Create suitable Contact header */
@@ -820,4 +846,5 @@
 	    pjsip_endpt_respond_stateless(pjsua_var.endpt, rdata, 400, NULL,
 					  NULL, NULL);
+	    pj_log_pop_indent();
 	    return PJ_TRUE;
 	}
@@ -834,4 +861,5 @@
 	pjsip_endpt_respond_stateless(pjsua_var.endpt, rdata, 400, NULL,
 				      NULL, NULL);
+	pj_log_pop_indent();
 	return PJ_TRUE;
     }
@@ -865,4 +893,5 @@
 
 	PJSUA_UNLOCK();
+	pj_log_pop_indent();
 	return PJ_TRUE;
     }
@@ -935,4 +964,5 @@
 	    pjsip_pres_terminate(sub, PJ_FALSE);
 	    PJSUA_UNLOCK();
+	    pj_log_pop_indent();
 	    return PJ_FALSE;
 	}
@@ -953,4 +983,5 @@
 	pjsip_pres_terminate(sub, PJ_FALSE);
 	PJSUA_UNLOCK();
+	pj_log_pop_indent();
 	return PJ_TRUE;
     }
@@ -964,4 +995,5 @@
 	pjsip_pres_terminate(sub, PJ_FALSE);
 	PJSUA_UNLOCK();
+	pj_log_pop_indent();
 	return PJ_FALSE;
     }
@@ -976,5 +1008,5 @@
 
     PJSUA_UNLOCK();
-
+    pj_log_pop_indent();
     return PJ_TRUE;
 }
@@ -1007,4 +1039,8 @@
     PJ_ASSERT_RETURN(pjsua_var.acc[acc_id].valid, PJ_EINVALIDOP);
 
+    PJ_LOG(4,(THIS_FILE, "Acc %d: sending NOTIFY for srv_pres=0x%p..",
+	      acc_id, (int)(long)srv_pres));
+    pj_log_push_indent();
+
     PJSUA_LOCK();
 
@@ -1015,4 +1051,5 @@
 	/* Subscription has been terminated */
 	PJSUA_UNLOCK();
+	pj_log_pop_indent();
 	return PJ_EINVALIDOP;
     }
@@ -1056,4 +1093,5 @@
 	pjsip_pres_terminate(srv_pres->sub, PJ_FALSE);
 	PJSUA_UNLOCK();
+	pj_log_pop_indent();
 	return status;
     }
@@ -1072,5 +1110,5 @@
 
     PJSUA_UNLOCK();
-
+    pj_log_pop_indent();
     return PJ_SUCCESS;
 }
@@ -1132,4 +1170,7 @@
     pj_status_t status;
 
+    PJ_LOG(5,(THIS_FILE, "Acc %d: sending %sPUBLISH..",
+	      acc_id, (active ? "" : "un-")));
+    pj_log_push_indent();
 
     /* Create PUBLISH request */
@@ -1200,4 +1241,5 @@
 
     acc->publish_state = acc->online_status;
+    pj_log_pop_indent();
     return PJ_SUCCESS;
 
@@ -1207,4 +1249,5 @@
 	acc->publish_sess = NULL;
     }
+    pj_log_pop_indent();
     return status;
 }
@@ -1455,4 +1498,5 @@
 		  pjsua_var.buddy[buddy->index].uri.ptr, 
 		  pjsip_evsub_get_state_name(sub)));
+	pj_log_push_indent();
 
 	if (pjsip_evsub_get_state(sub) == PJSIP_EVSUB_STATE_TERMINATED) {
@@ -1574,4 +1618,6 @@
 	    pjsip_evsub_set_mod_data(sub, pjsua_var.mod.id, NULL);
 	}
+
+	pj_log_pop_indent();
     }
 }
@@ -1685,6 +1731,7 @@
     acc = &pjsua_var.acc[acc_id];
 
-    PJ_LOG(4,(THIS_FILE, "Using account %d for buddy %d subscription",
-			 acc_id, buddy_id));
+    PJ_LOG(4,(THIS_FILE, "Buddy %d: subscribing presence,using account %d..",
+	      buddy_id, acc_id));
+    pj_log_push_indent();
 
     /* Generate suitable Contact header unless one is already set in
@@ -1702,4 +1749,5 @@
 		         status);
 	    pj_pool_release(tmp_pool);
+	    pj_log_pop_indent();
 	    return;
 	}
@@ -1716,4 +1764,5 @@
 		     status);
 	if (tmp_pool) pj_pool_release(tmp_pool);
+	pj_log_pop_indent();
 	return;
     }
@@ -1735,4 +1784,5 @@
 	if (buddy->dlg) pjsip_dlg_dec_lock(buddy->dlg);
 	if (tmp_pool) pj_pool_release(tmp_pool);
+	pj_log_pop_indent();
 	return;
     }
@@ -1774,4 +1824,5 @@
 		     status);
 	if (tmp_pool) pj_pool_release(tmp_pool);
+	pj_log_pop_indent();
 	return;
     }
@@ -1789,4 +1840,5 @@
 		     status);
 	if (tmp_pool) pj_pool_release(tmp_pool);
+	pj_log_pop_indent();
 	return;
     }
@@ -1794,4 +1846,5 @@
     pjsip_dlg_dec_lock(buddy->dlg);
     if (tmp_pool) pj_pool_release(tmp_pool);
+    pj_log_pop_indent();
 }
 
@@ -1813,4 +1866,7 @@
 	return;
     }
+
+    PJ_LOG(5,(THIS_FILE, "Buddy %d: unsubscribing..", buddy_id));
+    pj_log_push_indent();
 
     status = pjsip_pres_initiate( buddy->sub, 0, &tdata);
@@ -1826,4 +1882,6 @@
 		     status);
     }
+
+    pj_log_pop_indent();
 }
 
@@ -1915,8 +1973,13 @@
     mwi_info.rdata = rdata;
 
+    PJ_LOG(4,(THIS_FILE, "MWI got NOTIFY.."));
+    pj_log_push_indent();
+
     /* Call callback */
     if (pjsua_var.ua_cfg.cb.on_mwi_info) {
 	(*pjsua_var.ua_cfg.cb.on_mwi_info)(acc->index, &mwi_info);
     }
+
+    pj_log_pop_indent();
 }
 
@@ -1973,4 +2036,7 @@
 
     }
+
+    PJ_LOG(4,(THIS_FILE, "Starting MWI subscription.."));
+    pj_log_push_indent();
 
     /* Generate suitable Contact header unless one is already set in 
@@ -1987,4 +2053,5 @@
 		         status);
 	    pj_pool_release(tmp_pool);
+	    pj_log_pop_indent();
 	    return;
 	}
@@ -2000,4 +2067,5 @@
 	pjsua_perror(THIS_FILE, "Unable to create dialog", status);
 	if (tmp_pool) pj_pool_release(tmp_pool);
+	pj_log_pop_indent();
 	return;
     }
@@ -2015,4 +2083,5 @@
 	if (tmp_pool) pj_pool_release(tmp_pool);
 	if (acc->mwi_dlg) pjsip_dlg_dec_lock(acc->mwi_dlg);
+	pj_log_pop_indent();
 	return;
     }
@@ -2055,4 +2124,5 @@
 		     status);
 	if (tmp_pool) pj_pool_release(tmp_pool);
+	pj_log_pop_indent();
 	return;
     }
@@ -2071,4 +2141,5 @@
 		     status);
 	if (tmp_pool) pj_pool_release(tmp_pool);
+	pj_log_pop_indent();
 	return;
     }
@@ -2077,4 +2148,5 @@
     if (tmp_pool) pj_pool_release(tmp_pool);
 
+    pj_log_pop_indent();
 }
 
@@ -2106,4 +2178,8 @@
     }
 
+    PJ_LOG(4,(THIS_FILE, "Got unsolicited NOTIFY from %s:%d..",
+	      rdata->pkt_info.src_name, rdata->pkt_info.src_port));
+    pj_log_push_indent();
+
     /* Got unsolicited MWI request, respond with 200/OK first */
     pjsip_endpt_respond(pjsua_get_pjsip_endpt(), NULL, rdata, 200, NULL,
@@ -2124,5 +2200,5 @@
     }
 
-    
+    pj_log_pop_indent();
     return PJ_TRUE;
 }
@@ -2254,4 +2330,5 @@
 
     PJ_LOG(4,(THIS_FILE, "Shutting down presence.."));
+    pj_log_push_indent();
 
     if (pjsua_var.pres_timer.id != 0) {
@@ -2276,3 +2353,5 @@
 	    pjsua_pres_update_acc(i, PJ_FALSE);
     }
-}
+
+    pj_log_pop_indent();
+}
