You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2015/02/09 18:17:10 UTC

svn commit: r1658472 - in /qpid/dispatch/trunk: python/qpid_dispatch_internal/router/engine.py src/log.c

Author: aconway
Date: Mon Feb  9 17:17:10 2015
New Revision: 1658472

URL: http://svn.apache.org/r1658472
Log:
NO-JIRA: Minor logging fixes.

- engine.py to log stack traces rather than printing to stdout.
- Logging don't use file:line if file is NULL

Modified:
    qpid/dispatch/trunk/python/qpid_dispatch_internal/router/engine.py
    qpid/dispatch/trunk/src/log.c

Modified: qpid/dispatch/trunk/python/qpid_dispatch_internal/router/engine.py
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/python/qpid_dispatch_internal/router/engine.py?rev=1658472&r1=1658471&r2=1658472&view=diff
==============================================================================
--- qpid/dispatch/trunk/python/qpid_dispatch_internal/router/engine.py (original)
+++ qpid/dispatch/trunk/python/qpid_dispatch_internal/router/engine.py Mon Feb  9 17:17:10 2015
@@ -26,7 +26,7 @@ from node import NodeTracker
 from message import Message
 
 import sys
-import traceback
+from traceback import format_exc, extract_stack
 import time
 
 ##
@@ -95,10 +95,7 @@ class RouterEngine:
             if addr[0] in 'MC':
                 self.mobile_address_engine.add_local_address(addr)
         except Exception, e:
-            self.log_ma(LOG_ERROR, "Exception in new-address processing: exception=%r" % e)
-            exc_type, exc_value, exc_traceback = sys.exc_info()
-            traceback.print_tb(exc_traceback)
-
+            self.log_ma(LOG_ERROR, "Exception in new-address processing\n%s" % format_exc())
 
     def addressRemoved(self, addr):
         """
@@ -107,10 +104,7 @@ class RouterEngine:
             if addr[0] in 'MC':
                 self.mobile_address_engine.del_local_address(addr)
         except Exception, e:
-            self.log_ma(LOG_ERROR, "Exception in del-address processing: exception=%r" % e)
-            exc_type, exc_value, exc_traceback = sys.exc_info()
-            traceback.print_tb(exc_traceback)
-
+            self.log_ma(LOG_ERROR, "Exception in del-address processing\n%s" % format_exc())
 
     def linkLost(self, link_id):
         """
@@ -127,10 +121,7 @@ class RouterEngine:
             self.link_state_engine.tick(now)
             self.node_tracker.tick(now)
         except Exception, e:
-            self.log(LOG_ERROR, "Exception in timer processing: exception=%r" % e)
-            exc_type, exc_value, exc_traceback = sys.exc_info()
-            traceback.print_tb(exc_traceback)
-
+            self.log(LOG_ERROR, "Exception in timer processing\n%s" % format_exc())
 
     def handleControlMessage(self, opcode, body, link_id):
         """
@@ -168,10 +159,7 @@ class RouterEngine:
                 self.mobile_address_engine.handle_mar(msg, now)
 
         except Exception, e:
-            self.log(LOG_ERROR, "Exception in message processing: opcode=%s body=%r exception=%r" % (opcode, body, e))
-            exc_type, exc_value, exc_traceback = sys.exc_info()
-            traceback.print_tb(exc_traceback)
-
+            self.log(LOG_ERROR, "Control message error: opcode=%s body=%r\n%s" % (opcode, body, format_exc()))
 
     def receive(self, message, link_id):
         """
@@ -180,11 +168,8 @@ class RouterEngine:
         try:
             self.handleControlMessage(message.properties['opcode'], message.body, link_id)
         except Exception, e:
-            self.log(LOG_ERROR, "Exception in raw message processing: properties=%r body=%r exception=%r" %
-                     (message.properties, message.body, e))
-            exc_type, exc_value, exc_traceback = sys.exc_info()
-            traceback.print_tb(exc_traceback)
-
+            self.log(LOG_ERROR, "Exception in raw message processing: properties=%r body=%r\n%s" %
+                     (message.properties, message.body, format_exc()))
 
     def getRouterData(self, kind):
         """
@@ -212,7 +197,7 @@ class RouterEngine:
         """
         Emit a log message to the host's event log
         """
-        info = traceback.extract_stack(limit=2)[0] # Caller frame info
+        info = extract_stack(limit=2)[0] # Caller frame info
         self._log_general.log(level, text, info[0], info[1])
 
 
@@ -220,7 +205,7 @@ class RouterEngine:
         """
         Emit a log message to the host's event log
         """
-        info = traceback.extract_stack(limit=2)[0] # Caller frame info
+        info = extract_stack(limit=2)[0] # Caller frame info
         self._log_hello.log(level, text, info[0], info[1])
 
 
@@ -228,7 +213,7 @@ class RouterEngine:
         """
         Emit a log message to the host's event log
         """
-        info = traceback.extract_stack(limit=2)[0] # Caller frame info
+        info = extract_stack(limit=2)[0] # Caller frame info
         self._log_ls.log(level, text, info[0], info[1])
 
 
@@ -236,7 +221,7 @@ class RouterEngine:
         """
         Emit a log message to the host's event log
         """
-        info = traceback.extract_stack(limit=2)[0] # Caller frame info
+        info = extract_stack(limit=2)[0] # Caller frame info
         self._log_ma.log(level, text, info[0], info[1])
 
 

Modified: qpid/dispatch/trunk/src/log.c
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/src/log.c?rev=1658472&r1=1658471&r2=1658472&view=diff
==============================================================================
--- qpid/dispatch/trunk/src/log.c (original)
+++ qpid/dispatch/trunk/src/log.c Mon Feb  9 17:17:10 2015
@@ -254,7 +254,7 @@ static void write_log(qd_log_source_t *l
         aprintf(&begin, end, "%s ", buf);
     }
     aprintf(&begin, end, "%s (%s) %s", entry->module, level->name, entry->text);
-    if (default_bool(log_source->source, default_log_source->source))
+    if (default_bool(log_source->source, default_log_source->source) && entry->file)
         aprintf(&begin, end, " (%s:%d)", entry->file, entry->line);
     aprintf(&begin, end, "\n");
 



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org