Index: pjproject/trunk/pjlib/include/pj/sock.h
===================================================================
--- pjproject/trunk/pjlib/include/pj/sock.h	(revision 5832)
+++ pjproject/trunk/pjlib/include/pj/sock.h	(revision 5833)
@@ -1488,4 +1488,28 @@
 #endif
 
+/*****************************************************************************
+ *
+ * Utilities.
+ *
+ *****************************************************************************
+ */
+
+/**
+ * Print socket address string. This method will enclose the address string 
+ * with square bracket if it's IPv6 address.
+ *
+ * @param host_str  The host address string.
+ * @param port	    The port address.
+ * @param buf	    Text buffer.
+ * @param size	    Size of buffer.
+ * @param flags	    Bitmask combination of these value:
+ *		    - 1: port number is included. 
+ *
+ * @return	The address string.
+ */
+PJ_DECL(char *) pj_addr_str_print( const pj_str_t *host_str, int port, 
+				   char *buf, int size, unsigned flag);
+
+
 /**
  * @}
Index: pjproject/trunk/pjlib/src/pj/sock_common.c
===================================================================
--- pjproject/trunk/pjlib/src/pj/sock_common.c	(revision 5832)
+++ pjproject/trunk/pjlib/src/pj/sock_common.c	(revision 5833)
@@ -846,5 +846,5 @@
 
 	    TRACE_((THIS_FILE, "hostname IP is %s",
-		    pj_sockaddr_print(&ai.ai_addr, strip, sizeof(strip), 0)));
+		    pj_sockaddr_print(&ai.ai_addr, strip, sizeof(strip), 3)));
 	}
     }
@@ -858,5 +858,5 @@
 	if (status == PJ_SUCCESS) {
 	    TRACE_((THIS_FILE, "default IP is %s",
-		    pj_sockaddr_print(addr, strip, sizeof(strip), 0)));
+		    pj_sockaddr_print(addr, strip, sizeof(strip), 3)));
 
 	    pj_sockaddr_set_port(addr, 0);
@@ -970,5 +970,5 @@
     for (i=0; i<cand_cnt; ++i) {
 	TRACE_((THIS_FILE, "Checking candidate IP %s, weight=%d",
-		pj_sockaddr_print(&cand_addr[i], strip, sizeof(strip), 0),
+		pj_sockaddr_print(&cand_addr[i], strip, sizeof(strip), 3),
 		cand_weight[i]));
 
@@ -995,9 +995,9 @@
 	}
 	TRACE_((THIS_FILE, "Loopback IP %s returned",
-		pj_sockaddr_print(addr, strip, sizeof(strip), 0)));
+		pj_sockaddr_print(addr, strip, sizeof(strip), 3)));
     } else {
 	pj_sockaddr_copy_addr(addr, &cand_addr[selected_cand]);
 	TRACE_((THIS_FILE, "Candidate %s selected",
-		pj_sockaddr_print(addr, strip, sizeof(strip), 0)));
+		pj_sockaddr_print(addr, strip, sizeof(strip), 3)));
     }
 
@@ -1190,4 +1190,38 @@
 
 
+PJ_DEF(char *) pj_addr_str_print( const pj_str_t *host_str, int port, 
+				  char *buf, int size, unsigned flag)
+{
+    enum {
+	WITH_PORT = 1
+    };
+    char *bquote, *equote;
+    int af = pj_AF_UNSPEC();    
+    pj_in6_addr dummy6;
+
+    /* Check if this is an IPv6 address */
+    if (pj_inet_pton(pj_AF_INET6(), host_str, &dummy6) == PJ_SUCCESS)
+	af = pj_AF_INET6();
+
+    if (af == pj_AF_INET6()) {
+	bquote = "[";
+	equote = "]";    
+    } else {
+	bquote = "";
+	equote = "";    
+    } 
+
+    if (flag & WITH_PORT) {
+	pj_ansi_snprintf(buf, size, "%s%.*s%s:%d",
+			 bquote, (int)host_str->slen, host_str->ptr, equote, 
+			 port);
+    } else {
+	pj_ansi_snprintf(buf, size, "%s%.*s%s",
+			 bquote, (int)host_str->slen, host_str->ptr, equote);
+    }
+    return buf;
+}
+
+
 /* Only need to implement these in DLL build */
 #if defined(PJ_DLL)
Index: pjproject/trunk/pjnath/src/pjnath/ice_session.c
===================================================================
--- pjproject/trunk/pjnath/src/pjnath/ice_session.c	(revision 5832)
+++ pjproject/trunk/pjnath/src/pjnath/ice_session.c	(revision 5833)
@@ -763,5 +763,5 @@
 
     pj_ansi_strcpy(ice->tmp.txt, pj_sockaddr_print(&lcand->addr, address,
-                                                   sizeof(address), 0));
+                                                   sizeof(address), 2));
     LOG4((ice->obj_name, 
 	 "Candidate %d added: comp_id=%d, type=%s, foundation=%.*s, "
@@ -774,5 +774,5 @@
 	 ice->tmp.txt, 
 	  pj_sockaddr_get_port(&lcand->addr),
-	  pj_sockaddr_print(&lcand->base_addr, address, sizeof(address), 0),
+	  pj_sockaddr_print(&lcand->base_addr, address, sizeof(address), 2),
 	  pj_sockaddr_get_port(&lcand->base_addr),
 	 lcand->prio, lcand->prio));
@@ -922,8 +922,8 @@
 			   check->lcand->comp_id,
 			   pj_sockaddr_print(&lcand->addr, laddr,
-			                     sizeof(laddr), 0),
+			                     sizeof(laddr), 2),
 			   pj_sockaddr_get_port(&lcand->addr),
 			   pj_sockaddr_print(&rcand->addr, raddr,
-			                     sizeof(raddr), 0),
+			                     sizeof(raddr), 2),
 			   pj_sockaddr_get_port(&rcand->addr));
 
@@ -1074,5 +1074,5 @@
 		      "Base candidate %s:%d not found for srflx candidate %d",
 		      pj_sockaddr_print(&srflx->base_addr, baddr,
-		                        sizeof(baddr), 0),
+		                        sizeof(baddr), 2),
 		      pj_sockaddr_get_port(&srflx->base_addr),
 		      GET_LCAND_ID(clist->checks[i].lcand)));
@@ -2757,5 +2757,5 @@
 	LOG4((ice->obj_name, 
 	      "Added new remote candidate from the request: %s:%d",
-	      pj_sockaddr_print(&rcand->addr, raddr, sizeof(raddr), 0),
+	      pj_sockaddr_print(&rcand->addr, raddr, sizeof(raddr), 2),
 	      pj_sockaddr_get_port(&rcand->addr)));
 
Index: pjproject/trunk/pjnath/src/pjnath/ice_strans.c
===================================================================
--- pjproject/trunk/pjnath/src/pjnath/ice_strans.c	(revision 5832)
+++ pjproject/trunk/pjnath/src/pjnath/ice_strans.c	(revision 5833)
@@ -1675,5 +1675,5 @@
 	       "Component %d TX packet to %s:%d with transport %d",
 	       comp_id,
-	       pj_sockaddr_print(dst_addr, daddr, sizeof(addr), 0),
+	       pj_sockaddr_print(dst_addr, daddr, sizeof(addr), 2),
 	       pj_sockaddr_get_port(dst_addr),
 	       tp_typ));
Index: pjproject/trunk/pjnath/src/pjnath/nat_detect.c
===================================================================
--- pjproject/trunk/pjnath/src/pjnath/nat_detect.c	(revision 5832)
+++ pjproject/trunk/pjnath/src/pjnath/nat_detect.c	(revision 5833)
@@ -303,9 +303,9 @@
 
     PJ_LOG(5,(sess->pool->obj_name, "Local address is %s:%d",
-    	      pj_sockaddr_print(&sess->local_addr, addr, sizeof(addr), 0),
+    	      pj_sockaddr_print(&sess->local_addr, addr, sizeof(addr), 2),
     	      pj_sockaddr_get_port(&sess->local_addr)));
 
     PJ_LOG(5,(sess->pool->obj_name, "Server set to %s:%d",
-    	      pj_sockaddr_print(server, addr, sizeof(addr), 0),
+    	      pj_sockaddr_print(server, addr, sizeof(addr), 2),
     	      pj_sockaddr_get_port(server)));
 
@@ -871,5 +871,5 @@
               "Performing %s to %s:%d", 
 	      test_names[test_id],
-	      pj_sockaddr_print(sess->cur_server, addr, sizeof(addr), 0),
+	      pj_sockaddr_print(sess->cur_server, addr, sizeof(addr), 2),
 	      pj_sockaddr_get_port(sess->cur_server)));
 
Index: pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c
===================================================================
--- pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c	(revision 5832)
+++ pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c	(revision 5833)
@@ -873,9 +873,6 @@
     char host_port[128];
 
-    pj_ansi_snprintf(host_port, sizeof(host_port), "[%.*s:%d]",
-		     (int)tp->remote_name.host.slen,
-		     tp->remote_name.host.ptr,
-		     tp->remote_name.port);
-
+    pj_addr_str_print(&tp->remote_name.host, 
+		      tp->remote_name.port, host_port, sizeof(host_port), 1);
     switch (state) {
     case PJSIP_TP_STATE_CONNECTED:
Index: pjproject/trunk/pjsip/src/pjsip/sip_transport_tcp.c
===================================================================
--- pjproject/trunk/pjsip/src/pjsip/sip_transport_tcp.c	(revision 5832)
+++ pjproject/trunk/pjsip/src/pjsip/sip_transport_tcp.c	(revision 5833)
@@ -329,4 +329,5 @@
     enum { INFO_LEN = 100 };
     char local_addr[PJ_INET6_ADDRSTRLEN + 10];
+    char pub_addr[PJ_INET6_ADDRSTRLEN + 10];
     pj_sockaddr *listener_addr = &listener->factory.local_addr;
 
@@ -337,17 +338,19 @@
     }
     pj_sockaddr_print(listener_addr, local_addr, sizeof(local_addr), 3);
+    pj_addr_str_print(&listener->factory.addr_name.host, 
+		      listener->factory.addr_name.port, pub_addr, 
+		      sizeof(pub_addr), 1);
     pj_ansi_snprintf(
-	    listener->factory.info, INFO_LEN, "tcp %s [published as %.*s:%d]",
-	    local_addr,
-	    (int)listener->factory.addr_name.host.slen,
-	    listener->factory.addr_name.host.ptr,
-	    listener->factory.addr_name.port);
-
-    if (listener->asock) {
+	    listener->factory.info, INFO_LEN, "tcp %s [published as %s]",
+	    local_addr, pub_addr);
+
+    if (listener->asock) {	
+	char addr[PJ_INET6_ADDRSTRLEN+10];
+
 	PJ_LOG(4, (listener->factory.obj_name,
-	       "SIP TCP listener ready for incoming connections at %.*s:%d",
-	       (int)listener->factory.addr_name.host.slen,
-	       listener->factory.addr_name.host.ptr,
-	       listener->factory.addr_name.port));
+		   "SIP TCP listener ready for incoming connections at %s",
+		   pj_addr_str_print(&listener->factory.addr_name.host,
+				     listener->factory.addr_name.port, addr,
+				     sizeof(addr), 1)));
     } else {
 	PJ_LOG(4, (listener->factory.obj_name, "SIP TCP is ready "
@@ -1030,4 +1033,7 @@
 
     if (tcp->has_pending_connect) {
+	char local_addr_buf[PJ_INET6_ADDRSTRLEN+10];
+	char remote_addr_buf[PJ_INET6_ADDRSTRLEN+10];
+
 	/* Update (again) local address, just in case local address currently
 	 * set is different now that asynchronous connect() is started.
@@ -1051,11 +1057,11 @@
 	
 	PJ_LOG(4,(tcp->base.obj_name, 
-		  "TCP transport %.*s:%d is connecting to %.*s:%d...",
-		  (int)tcp->base.local_name.host.slen,
-		  tcp->base.local_name.host.ptr,
-		  tcp->base.local_name.port,
-		  (int)tcp->base.remote_name.host.slen,
-		  tcp->base.remote_name.host.ptr,
-		  tcp->base.remote_name.port));
+		  "TCP transport %s is connecting to %s...",
+		  pj_addr_str_print(&tcp->base.local_name.host, 
+				    tcp->base.local_name.port, 
+				    local_addr_buf, sizeof(local_addr_buf), 1),
+		  pj_addr_str_print(&tcp->base.remote_name.host, 
+			        tcp->base.remote_name.port, 
+				remote_addr_buf, sizeof(remote_addr_buf), 1)));
     }
 
@@ -1083,4 +1089,5 @@
     int addr_len;
     pj_status_t status;
+    char addr_buf[PJ_INET6_ADDRSTRLEN+10];    
 
     PJ_UNUSED_ARG(src_addr_len);
@@ -1094,9 +1101,9 @@
 
     PJ_LOG(4,(listener->factory.obj_name, 
-	      "TCP listener %.*s:%d: got incoming TCP connection "
+	      "TCP listener %s: got incoming TCP connection "
 	      "from %s, sock=%d",
-	      (int)listener->factory.addr_name.host.slen,
-	      listener->factory.addr_name.host.ptr,
-	      listener->factory.addr_name.port,
+	      pj_addr_str_print(&listener->factory.addr_name.host, 
+				listener->factory.addr_name.port, addr_buf, 
+				sizeof(addr_buf), 1),
 	      pj_sockaddr_print(src_addr, addr, sizeof(addr), 3),
 	      sock));
@@ -1423,4 +1430,6 @@
     int addrlen;
     pjsip_tp_state_callback state_cb;
+    char local_addr_buf[PJ_INET6_ADDRSTRLEN+10];
+    char remote_addr_buf[PJ_INET6_ADDRSTRLEN+10];
 
     tcp = (struct tcp_transport*) pj_activesock_get_user_data(asock);
@@ -1463,11 +1472,11 @@
 
     PJ_LOG(4,(tcp->base.obj_name, 
-	      "TCP transport %.*s:%d is connected to %.*s:%d",
-	      (int)tcp->base.local_name.host.slen,
-	      tcp->base.local_name.host.ptr,
-	      tcp->base.local_name.port,
-	      (int)tcp->base.remote_name.host.slen,
-	      tcp->base.remote_name.host.ptr,
-	      tcp->base.remote_name.port));
+	      "TCP transport %s is connected to %s",
+	      pj_addr_str_print(&tcp->base.local_name.host, 
+				tcp->base.local_name.port, local_addr_buf, 
+				sizeof(local_addr_buf), 1),
+	      pj_addr_str_print(&tcp->base.remote_name.host, 
+				tcp->base.remote_name.port, remote_addr_buf, 
+				sizeof(remote_addr_buf), 1)));
 
 
@@ -1529,4 +1538,5 @@
     pj_ssize_t size;
     pj_status_t status;
+    char addr[PJ_INET6_ADDRSTRLEN+10];        
 
     PJ_UNUSED_ARG(th);
@@ -1548,8 +1558,9 @@
     }
 
-    PJ_LOG(5,(tcp->base.obj_name, "Sending %d byte(s) keep-alive to %.*s:%d", 
-	      (int)tcp->ka_pkt.slen, (int)tcp->base.remote_name.host.slen,
-	      tcp->base.remote_name.host.ptr,
-	      tcp->base.remote_name.port));
+    PJ_LOG(5,(tcp->base.obj_name, "Sending %d byte(s) keep-alive to %s", 
+	      (int)tcp->ka_pkt.slen, 
+	      pj_addr_str_print(&tcp->base.remote_name.host, 
+				tcp->base.remote_name.port, addr, 
+				sizeof(addr), 1)));
 
     /* Send the data */
Index: pjproject/trunk/pjsip/src/pjsip/sip_transport_tls.c
===================================================================
--- pjproject/trunk/pjsip/src/pjsip/sip_transport_tls.c	(revision 5832)
+++ pjproject/trunk/pjsip/src/pjsip/sip_transport_tls.c	(revision 5833)
@@ -413,4 +413,5 @@
     enum { INFO_LEN = 100 };
     char local_addr[PJ_INET6_ADDRSTRLEN + 10];
+    char pub_addr[PJ_INET6_ADDRSTRLEN + 10];
     pj_sockaddr *listener_addr = &listener->factory.local_addr;
 
@@ -420,18 +421,19 @@
     }
     pj_sockaddr_print(listener_addr, local_addr, sizeof(local_addr), 3);
+    pj_addr_str_print(&listener->factory.addr_name.host, 
+		      listener->factory.addr_name.port, pub_addr, 
+		      sizeof(pub_addr), 1);
     pj_ansi_snprintf(
-	    listener->factory.info, INFO_LEN, "tls %s [published as %.*s:%d]",
-	    local_addr,
-	    (int)listener->factory.addr_name.host.slen,
-	    listener->factory.addr_name.host.ptr,
-	    listener->factory.addr_name.port);
+	    listener->factory.info, INFO_LEN, "tls %s [published as %s]",
+	    local_addr, pub_addr);
 
     if (listener->ssock) {
+	char addr[PJ_INET6_ADDRSTRLEN+10];
+
 	PJ_LOG(4, (listener->factory.obj_name,
-	       "SIP TLS listener is ready for incoming connections "
-	       "at %.*s:%d",
-	       (int)listener->factory.addr_name.host.slen,
-	       listener->factory.addr_name.host.ptr,
-	       listener->factory.addr_name.port));
+	       "SIP TLS listener is ready for incoming connections at %s",
+	       pj_addr_str_print(&listener->factory.addr_name.host,
+			         listener->factory.addr_name.port, addr,
+				 sizeof(addr), 1)));
     } else {
 	PJ_LOG(4, (listener->factory.obj_name, "SIP TLS is ready "
@@ -1252,4 +1254,6 @@
     if (tls->has_pending_connect) {
 	pj_ssl_sock_info info;
+	char local_addr_buf[PJ_INET6_ADDRSTRLEN+10];
+	char remote_addr_buf[PJ_INET6_ADDRSTRLEN+10];
 
 	/* Update local address, just in case local address currently set is 
@@ -1281,11 +1285,11 @@
 
 	PJ_LOG(4,(tls->base.obj_name, 
-		  "TLS transport %.*s:%d is connecting to %.*s:%d...",
-		  (int)tls->base.local_name.host.slen,
-		  tls->base.local_name.host.ptr,
-		  tls->base.local_name.port,
-		  (int)tls->base.remote_name.host.slen,
-		  tls->base.remote_name.host.ptr,
-		  tls->base.remote_name.port));
+		  "TLS transport %s is connecting to %s...",
+		  pj_addr_str_print(&tls->base.local_name.host, 
+				    tls->base.local_name.port, 
+				    local_addr_buf, sizeof(local_addr_buf), 1),
+		  pj_addr_str_print(&tls->base.remote_name.host, 
+			        tls->base.remote_name.port, 
+				remote_addr_buf, sizeof(remote_addr_buf), 1)));
     }
 
@@ -1314,4 +1318,5 @@
     pj_bool_t is_shutdown;
     pj_status_t status;
+    char addr_buf[PJ_INET6_ADDRSTRLEN+10];        
 
     PJ_UNUSED_ARG(src_addr_len);
@@ -1325,9 +1330,9 @@
 
     PJ_LOG(4,(listener->factory.obj_name, 
-	      "TLS listener %.*s:%d: got incoming TLS connection "
+	      "TLS listener %s: got incoming TLS connection "
 	      "from %s, sock=%d",
-	      (int)listener->factory.addr_name.host.slen,
-	      listener->factory.addr_name.host.ptr,
-	      listener->factory.addr_name.port,
+	      pj_addr_str_print(&listener->factory.addr_name.host, 
+				listener->factory.addr_name.port, addr_buf, 
+				sizeof(addr_buf), 1),
 	      pj_sockaddr_print(src_addr, addr, sizeof(addr), 3),
 	      new_ssock));
@@ -1696,4 +1701,6 @@
     pjsip_tp_state_callback state_cb;
     pj_bool_t is_shutdown;
+    char local_addr_buf[PJ_INET6_ADDRSTRLEN+10];
+    char remote_addr_buf[PJ_INET6_ADDRSTRLEN+10];
 
     tls = (struct tls_transport*) pj_ssl_sock_get_user_data(ssock);
@@ -1881,10 +1888,10 @@
     PJ_LOG(4,(tls->base.obj_name, 
 	      "TLS transport %.*s:%d is connected to %.*s:%d",
-	      (int)tls->base.local_name.host.slen,
-	      tls->base.local_name.host.ptr,
-	      tls->base.local_name.port,
-	      (int)tls->base.remote_name.host.slen,
-	      tls->base.remote_name.host.ptr,
-	      tls->base.remote_name.port));
+	      pj_addr_str_print(&tls->base.local_name.host, 
+				tls->base.local_name.port, local_addr_buf, 
+				sizeof(local_addr_buf), 1),
+	      pj_addr_str_print(&tls->base.remote_name.host, 
+				tls->base.remote_name.port, remote_addr_buf, 
+				sizeof(remote_addr_buf), 1)));
 
     /* Start pending read */
@@ -1923,4 +1930,5 @@
     pj_ssize_t size;
     pj_status_t status;
+    char addr[PJ_INET6_ADDRSTRLEN+10];    
 
     PJ_UNUSED_ARG(th);
@@ -1942,8 +1950,9 @@
     }
 
-    PJ_LOG(5,(tls->base.obj_name, "Sending %d byte(s) keep-alive to %.*s:%d", 
-	      (int)tls->ka_pkt.slen, (int)tls->base.remote_name.host.slen,
-	      tls->base.remote_name.host.ptr,
-	      tls->base.remote_name.port));
+    PJ_LOG(5,(tls->base.obj_name, "Sending %d byte(s) keep-alive to %s", 
+	      (int)tls->ka_pkt.slen, 
+	      pj_addr_str_print(&tls->base.remote_name.host, 
+				tls->base.remote_name.port, addr, 
+				sizeof(addr), 1)));
 
     /* Send the data */
Index: pjproject/trunk/pjsip/src/pjsip/sip_transport_udp.c
===================================================================
--- pjproject/trunk/pjsip/src/pjsip/sip_transport_udp.c	(revision 5832)
+++ pjproject/trunk/pjsip/src/pjsip/sip_transport_udp.c	(revision 5833)
@@ -601,4 +601,5 @@
     enum { INFO_LEN = 80 };
     char local_addr[PJ_INET6_ADDRSTRLEN+10];
+    char pub_addr[PJ_INET6_ADDRSTRLEN+10];
 
     pj_assert(a_name->host.slen != 0);
@@ -620,10 +621,10 @@
 
     pj_sockaddr_print(&tp->base.local_addr, local_addr, sizeof(local_addr), 3);
-
-    pj_ansi_snprintf( 
-	tp->base.info, INFO_LEN, "udp %s [published as %s:%d]",
-	local_addr,
-	tp->base.local_name.host.ptr,
-	tp->base.local_name.port);
+    pj_addr_str_print(&tp->base.local_name.host, 
+		      tp->base.local_name.port, 
+		      pub_addr, sizeof(pub_addr), 1),
+
+    pj_ansi_snprintf( tp->base.info, INFO_LEN, "udp %s [published as %s]",
+		      local_addr, pub_addr);
 }
 
@@ -1147,4 +1148,5 @@
     struct udp_transport *tp;
     pj_status_t status;
+    char addr[PJ_INET6_ADDRSTRLEN+10];
 
     PJ_ASSERT_RETURN(transport != NULL, PJ_EINVAL);
@@ -1242,9 +1244,9 @@
     tp->is_paused = PJ_FALSE;
 
-    PJ_LOG(4,(tp->base.obj_name, 
-	      "SIP UDP transport restarted, published address is %.*s:%d",
-	      (int)tp->base.local_name.host.slen,
-	      tp->base.local_name.host.ptr,
-	      tp->base.local_name.port));
+    PJ_LOG(4, (tp->base.obj_name,
+	       "SIP UDP transport restarted, published address is %s",
+	       pj_addr_str_print(&tp->base.local_name.host,
+				 tp->base.local_name.port,
+				 addr, sizeof(addr), 1)));
 
     return PJ_SUCCESS;
Index: pjproject/trunk/pjsip/src/pjsua-lib/pjsua_acc.c
===================================================================
--- pjproject/trunk/pjsip/src/pjsua-lib/pjsua_acc.c	(revision 5832)
+++ pjproject/trunk/pjsip/src/pjsua-lib/pjsua_acc.c	(revision 5833)
@@ -534,7 +534,7 @@
     pjsua_acc_config cfg;
     pjsua_transport_data *t = &pjsua_var.tpdata[tid];
-    const char *beginquote, *endquote;
     char transport_param[32];
     char uri[PJSIP_MAX_URL_SIZE];
+    char addr_buf[PJ_INET6_ADDRSTRLEN+10];
     pjsua_acc_id acc_id;
     pj_status_t status;
@@ -551,12 +551,4 @@
     /* Lower the priority of local account */
     --cfg.priority;
-
-    /* Enclose IPv6 address in square brackets */
-    if (get_ip_addr_ver(&t->local_name.host) == 6) {
-	beginquote = "[";
-	endquote = "]";
-    } else {
-	beginquote = endquote = "";
-    }
 
     /* Don't add transport parameter if it's UDP */
@@ -570,11 +562,8 @@
 
     /* Build URI for the account */
-    pj_ansi_snprintf(uri, PJSIP_MAX_URL_SIZE,
-		     "<sip:%s%.*s%s:%d%s>", 
-		     beginquote,
-		     (int)t->local_name.host.slen,
-		     t->local_name.host.ptr,
-		     endquote,
-		     t->local_name.port,
+    pj_ansi_snprintf(uri, PJSIP_MAX_URL_SIZE,		     
+		     "<sip:%s%s>", 
+		     pj_addr_str_print(&t->local_name.host, t->local_name.port, 
+				       addr_buf, sizeof(addr_buf), 1),
 		     transport_param);
 
@@ -1611,4 +1600,6 @@
     pj_str_t srv_ip;
     pjsip_contact_hdr *contact_hdr;
+    char host_addr_buf[PJ_INET6_ADDRSTRLEN+10];
+    char via_addr_buf[PJ_INET6_ADDRSTRLEN+10];
     const pj_str_t STR_CONTACT = { "Contact", 7 };
 
@@ -1777,16 +1768,12 @@
 	return PJ_FALSE;
     }
-
+    pj_addr_str_print(&uri->host, uri->port, host_addr_buf, 
+		      sizeof(host_addr_buf), 1);
+    pj_addr_str_print(via_addr, rport, via_addr_buf, 
+		      sizeof(via_addr_buf), 1);
     PJ_LOG(3,(THIS_FILE, "IP address change detected for account %d "
-			 "(%.*s:%d --> %.*s:%d). Updating registration "
+			 "(%s --> %s). Updating registration "
 			 "(using method %d)",
-			 acc->index,
-			 (int)uri->host.slen,
-			 uri->host.ptr,
-			 uri->port,
-			 (int)via_addr->slen,
-			 via_addr->ptr,
-			 rport,
-			 contact_rewrite_method));
+			 acc->index, host_addr_buf, via_addr_buf));
 
     pj_assert(contact_rewrite_method == PJSUA_CONTACT_REWRITE_UNREGISTER ||
@@ -1817,12 +1804,12 @@
 	secure = pjsip_transport_get_flag_from_type(tp->key.type) &
 		 PJSIP_TRANSPORT_SECURE;
-
-	/* Enclose IPv6 address in square brackets */
-	if (tp->key.type & PJSIP_TRANSPORT_IPV6) {
-	    beginquote = "[";
-	    endquote = "]";
-	} else {
-	    beginquote = endquote = "";
-	}
+  	
+        /* Enclose IPv6 address in square brackets */
+        if (tp->key.type & PJSIP_TRANSPORT_IPV6) {
+            beginquote = "[";
+            endquote = "]";
+        } else {
+            beginquote = endquote = "";
+        }
 
 	/* Don't add transport parameter if it's UDP */
@@ -2134,11 +2121,13 @@
 					    &delay);
 	if (status == PJ_SUCCESS) {
+	    char addr[PJ_INET6_ADDRSTRLEN+10];
+	    pj_str_t input_str = pj_str(param->rdata->pkt_info.src_name);
 	    acc->ka_timer.id = PJ_TRUE;
+
+	    pj_addr_str_print(&input_str, param->rdata->pkt_info.src_port, 
+			      addr, sizeof(addr), 1);
 	    PJ_LOG(4,(THIS_FILE, "Keep-alive timer started for acc %d, "
 				 "destination:%s:%d, interval:%ds",
-				 acc->index,
-				 param->rdata->pkt_info.src_name,
-				 param->rdata->pkt_info.src_port,
-				 acc->cfg.ka_interval));
+				 acc->index, addr, acc->cfg.ka_interval));
 	} else {
 	    acc->ka_timer.id = PJ_FALSE;
Index: pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c
===================================================================
--- pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c	(revision 5832)
+++ pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c	(revision 5833)
@@ -388,12 +388,18 @@
 static pj_bool_t logging_on_rx_msg(pjsip_rx_data *rdata)
 {
-    PJ_LOG(4,(THIS_FILE, "RX %d bytes %s from %s %s:%d:\n"
+    char addr[PJ_INET6_ADDRSTRLEN+10];
+    pj_str_t input_str = pj_str(rdata->pkt_info.src_name);
+
+    PJ_LOG(4,(THIS_FILE, "RX %d bytes %s from %s %s:\n"
 			 "%.*s\n"
 			 "--end msg--",
 			 rdata->msg_info.len,
 			 pjsip_rx_data_get_info(rdata),
-			 rdata->tp_info.transport->type_name,
-			 rdata->pkt_info.src_name,
-			 rdata->pkt_info.src_port,
+			 rdata->tp_info.transport->type_name,	      
+			 pj_addr_str_print(&input_str, 
+					   rdata->pkt_info.src_port, 
+					   addr,
+					   sizeof(addr), 
+					   1),
 			 (int)rdata->msg_info.len,
 			 rdata->msg_info.msg_buf));
@@ -406,4 +412,6 @@
 static pj_status_t logging_on_tx_msg(pjsip_tx_data *tdata)
 {
+    char addr[PJ_INET6_ADDRSTRLEN+10];
+    pj_str_t input_str = pj_str(tdata->tp_info.dst_name);
     
     /* Important note:
@@ -412,6 +420,5 @@
      *	has lower priority than transport layer.
      */
-
-    PJ_LOG(4,(THIS_FILE, "TX %d bytes %s to %s %s:%d:\n"
+    PJ_LOG(4,(THIS_FILE, "TX %d bytes %s to %s %s:\n"
 			 "%.*s\n"
 			 "--end msg--",
@@ -419,8 +426,12 @@
 			 pjsip_tx_data_get_info(tdata),
 			 tdata->tp_info.transport->type_name,
-			 tdata->tp_info.dst_name,
-			 tdata->tp_info.dst_port,
+			 pj_addr_str_print(&input_str, 
+					   tdata->tp_info.dst_port, 
+					   addr,
+					   sizeof(addr), 
+					   1),
 			 (int)(tdata->buf.cur - tdata->buf.start),
 			 tdata->buf.start));
+
 
     /* Always return success, otherwise message will not get sent! */
