Index: pjproject/trunk/pjsip/src/pjsip-simple/publishc.c
===================================================================
--- pjproject/trunk/pjsip/src/pjsip-simple/publishc.c	(revision 5983)
+++ pjproject/trunk/pjsip/src/pjsip-simple/publishc.c	(revision 5984)
@@ -804,5 +804,5 @@
 	// cause accessing freed memory location.
 	//--pubc->pending_tsx;
-	PJ_LOG(4,(THIS_FILE, "Error sending request, status=%d", status));
+	PJ_PERROR(4,(THIS_FILE, status, "Error sending request"));
     }
 
Index: pjproject/trunk/pjsip/src/pjsip-ua/sip_inv.c
===================================================================
--- pjproject/trunk/pjsip/src/pjsip-ua/sip_inv.c	(revision 5983)
+++ pjproject/trunk/pjsip/src/pjsip-ua/sip_inv.c	(revision 5984)
@@ -1948,5 +1948,5 @@
     status = pjmedia_sdp_neg_negotiate(inv->pool_prov, inv->neg, 0);
 
-    PJ_LOG(5,(inv->obj_name, "SDP negotiation done, status=%d", status));
+    PJ_PERROR(4,(inv->obj_name, status, "SDP negotiation done"));
 
     if (mod_inv.cb.on_media_update && inv->notify)
Index: pjproject/trunk/pjsip/src/pjsip-ua/sip_reg.c
===================================================================
--- pjproject/trunk/pjsip/src/pjsip-ua/sip_reg.c	(revision 5983)
+++ pjproject/trunk/pjsip/src/pjsip-ua/sip_reg.c	(revision 5984)
@@ -1440,5 +1440,5 @@
 	regc->has_tsx = PJ_FALSE;
 
-	PJ_LOG(4,(THIS_FILE, "Error sending request, status=%d", status));
+	PJ_PERROR(4,(THIS_FILE, status, "Error sending request"));
     }
 
Index: pjproject/trunk/pjsip/src/pjsip/sip_endpoint.c
===================================================================
--- pjproject/trunk/pjsip/src/pjsip/sip_endpoint.c	(revision 5983)
+++ pjproject/trunk/pjsip/src/pjsip/sip_endpoint.c	(revision 5984)
@@ -524,5 +524,6 @@
     status = pjsip_resolver_create(endpt->pool, &endpt->resolver);
     if (status != PJ_SUCCESS) {
-	PJ_LOG(4, (THIS_FILE, "Error creating resolver instance"));
+	PJ_PERROR(4, (THIS_FILE, status,
+		      "Error creating resolver instance"));
 	goto on_error;
     }
@@ -568,5 +569,5 @@
     pj_pool_release( endpt->pool );
 
-    PJ_LOG(4, (THIS_FILE, "Error creating endpoint"));
+    PJ_PERROR(4, (THIS_FILE, status, "Error creating endpoint"));
     return status;
 }
@@ -580,5 +581,5 @@
     exit_cb *ecb;
 
-    PJ_LOG(5, (THIS_FILE, "Destroying endpoing instance.."));
+    PJ_LOG(5, (THIS_FILE, "Destroying endpoint instance.."));
 
     /* Phase 1: stop all modules */
Index: pjproject/trunk/pjsip/src/pjsip/sip_resolve.c
===================================================================
--- pjproject/trunk/pjsip/src/pjsip/sip_resolve.c	(revision 5983)
+++ pjproject/trunk/pjsip/src/pjsip/sip_resolve.c	(revision 5984)
@@ -513,10 +513,8 @@
 on_error:
     if (status != PJ_SUCCESS) {
-	char errmsg[PJ_ERR_MSG_SIZE];
-	PJ_LOG(4,(THIS_FILE, "Failed to resolve '%.*s'. Err=%d (%s)",
-			     (int)target->addr.host.slen,
-			     target->addr.host.ptr,
-			     status,
-			     pj_strerror(status,errmsg,sizeof(errmsg)).ptr));
+	PJ_PERROR(4,(THIS_FILE, status,
+		     "Failed to resolve '%.*s'",
+		     (int)target->addr.host.slen,
+		     target->addr.host.ptr));
 	(*cb)(status, token, NULL);
 	return;
@@ -568,10 +566,6 @@
     
     if (status != PJ_SUCCESS) {
-	char errmsg[PJ_ERR_MSG_SIZE];
-
-	/* Log error */
-	pj_strerror(status, errmsg, sizeof(errmsg));
-	PJ_LOG(4,(query->objname, "DNS A record resolution failed: %s", 
-		  errmsg));
+	PJ_PERROR(4,(query->objname, status,
+		     "DNS A record resolution failed"));
 
 	query->last_error = status;
@@ -631,10 +625,6 @@
     
     if (status != PJ_SUCCESS) {
-	char errmsg[PJ_ERR_MSG_SIZE];
-
-	/* Log error */
-	pj_strerror(status, errmsg, sizeof(errmsg));
-	PJ_LOG(4,(query->objname, "DNS AAAA record resolution failed: %s", 
-		  errmsg));
+	PJ_PERROR(4,(query->objname, status,
+		     "DNS AAAA record resolution failed"));
 
 	query->last_error = status;
@@ -661,10 +651,6 @@
 
     if (status != PJ_SUCCESS) {
-	char errmsg[PJ_ERR_MSG_SIZE];
-
-	/* Log error */
-	pj_strerror(status, errmsg, sizeof(errmsg));
-	PJ_LOG(4,(query->objname, "DNS A/AAAA record resolution failed: %s",
-		  errmsg));
+	PJ_PERROR(4,(query->objname, status,
+		     "DNS A/AAAA record resolution failed"));
 
 	/* Call the callback */
Index: pjproject/trunk/pjsip/src/pjsip/sip_transaction.c
===================================================================
--- pjproject/trunk/pjsip/src/pjsip/sip_transaction.c	(revision 5983)
+++ pjproject/trunk/pjsip/src/pjsip/sip_transaction.c	(revision 5984)
@@ -776,9 +776,9 @@
      */
     if (pj_hash_count(mod_tsx_layer.htable) != 0) {
-	if (pjsip_endpt_atexit(mod_tsx_layer.endpt, &tsx_layer_destroy) !=
-	    PJ_SUCCESS)
-	{
-	    PJ_LOG(3,(THIS_FILE, "Failed to register transaction layer "
-				 "module destroy."));
+	pj_status_t status;
+	status = pjsip_endpt_atexit(mod_tsx_layer.endpt, &tsx_layer_destroy);
+	if (status != PJ_SUCCESS) {
+	    PJ_PERROR(3,(THIS_FILE, status,
+		    "Failed to register transaction layer module destroy."));
 	}
 	return PJ_EBUSY;
@@ -2038,10 +2038,8 @@
     if (sent < 0) {
 	pj_time_val delay = {0, 0};
-	char errmsg[PJ_ERR_MSG_SIZE];
-
-	pj_strerror((pj_status_t)-sent, errmsg, sizeof(errmsg));
-
-	PJ_LOG(2,(tsx->obj_name, "Transport failed to send %s! Err=%d (%s)",
-		pjsip_tx_data_get_info(tdata), -sent, errmsg));
+
+	PJ_PERROR(2,(tsx->obj_name, (pj_status_t)-sent,
+		      "Transport failed to send %s!",
+		      pjsip_tx_data_get_info(tdata)));
 
 	/* Post the event for later processing, to avoid deadlock.
Index: pjproject/trunk/pjsip/src/pjsip/sip_transport.c
===================================================================
--- pjproject/trunk/pjsip/src/pjsip/sip_transport.c	(revision 5983)
+++ pjproject/trunk/pjsip/src/pjsip/sip_transport.c	(revision 5984)
@@ -1507,6 +1507,7 @@
 	     * just fallback using pj_gethostip(), see ticket #1660.
 	     */
-	    PJ_LOG(5,(THIS_FILE,"Warning: unable to determine local "
-				"interface, fallback to default interface!"));
+	    PJ_PERROR(5,(THIS_FILE, status,
+			 "Warning: unable to determine local interface, "
+			 "fallback to default interface!"));
 	    status = pj_gethostip(af, &itf_addr);
 	    if (status != PJ_SUCCESS)
Index: pjproject/trunk/pjsip/src/pjsip/sip_transport_tcp.c
===================================================================
--- pjproject/trunk/pjsip/src/pjsip/sip_transport_tcp.c	(revision 5983)
+++ pjproject/trunk/pjsip/src/pjsip/sip_transport_tcp.c	(revision 5984)
@@ -167,9 +167,5 @@
 		       pj_status_t status)
 {
-    char errmsg[PJ_ERR_MSG_SIZE];
-
-    pj_strerror(status, errmsg, sizeof(errmsg));
-
-    PJ_LOG(3,(sender, "%s: %s [code=%d]", title, errmsg, status));
+    PJ_PERROR(3,(sender, status, "%s: [code=%d]", title, status));
 }
 
@@ -966,7 +962,6 @@
 				       readbuf, 0);
     if (status != PJ_SUCCESS && status != PJ_EPENDING) {
-	PJ_LOG(4, (tcp->base.obj_name, 
-		   "pj_activesock_start_read() error, status=%d", 
-		   status));
+	PJ_PERROR(4, (tcp->base.obj_name, status,
+		      "pj_activesock_start_read() error"));
 	return status;
     }
@@ -1687,7 +1682,6 @@
 				    &enabled, sizeof(enabled));
 	if (status != PJ_SUCCESS) {
-	    PJ_LOG(1, ("TRACE", "fail set reuseaddr"));
 	    PJ_PERROR(4, (listener->factory.obj_name, status,
-		"Warning: error applying SO_REUSEADDR"));
+			  "Warning: error applying SO_REUSEADDR"));
 	}
     }
Index: pjproject/trunk/pjsip/src/pjsip/sip_transport_tls.c
===================================================================
--- pjproject/trunk/pjsip/src/pjsip/sip_transport_tls.c	(revision 5983)
+++ pjproject/trunk/pjsip/src/pjsip/sip_transport_tls.c	(revision 5984)
@@ -173,9 +173,5 @@
 		       pj_status_t status)
 {
-    char errmsg[PJ_ERR_MSG_SIZE];
-
-    pj_strerror(status, errmsg, sizeof(errmsg));
-
-    PJ_LOG(3,(sender, "%s: %s [code=%d]", title, errmsg, status));
+    PJ_PERROR(3,(sender, status, "%s: [code=%d]", title, status));
 }
 
@@ -1106,7 +1102,6 @@
 				     readbuf, 0);
     if (status != PJ_SUCCESS && status != PJ_EPENDING) {
-	PJ_LOG(4, (tls->base.obj_name, 
-		   "pj_ssl_sock_start_read() error, status=%d", 
-		   status));
+	PJ_PERROR(4, (tls->base.obj_name, status,
+		     "pj_ssl_sock_start_read() error"));
 	return status;
     }
Index: pjproject/trunk/pjsip/src/pjsip/sip_transport_udp.c
===================================================================
--- pjproject/trunk/pjsip/src/pjsip/sip_transport_udp.c	(revision 5983)
+++ pjproject/trunk/pjsip/src/pjsip/sip_transport_udp.c	(revision 5984)
@@ -645,8 +645,5 @@
 				&sobuf_size, sizeof(sobuf_size));
     if (status != PJ_SUCCESS) {
-	char errmsg[PJ_ERR_MSG_SIZE];
-	pj_strerror(status, errmsg, sizeof(errmsg));
-	PJ_LOG(4,(THIS_FILE, "Error setting SO_RCVBUF: %s [%d]", errmsg,
-		  status));
+	PJ_PERROR(4,(THIS_FILE, status, "Error setting SO_RCVBUF"));
     }
 #endif
@@ -658,8 +655,5 @@
 				&sobuf_size, sizeof(sobuf_size));
     if (status != PJ_SUCCESS) {
-	char errmsg[PJ_ERR_MSG_SIZE];
-	pj_strerror(status, errmsg, sizeof(errmsg));
-	PJ_LOG(4,(THIS_FILE, "Error setting SO_SNDBUF: %s [%d]", errmsg,
-		  status));
+	PJ_PERROR(4,(THIS_FILE, status, "Error setting SO_SNDBUF"));
     }
 #endif
