incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [2/3] git commit: [#5721] Add task details to taskd log lines
Date Wed, 12 Jun 2013 21:26:22 GMT
[#5721] Add task details to taskd log lines

Signed-off-by: Tim Van Steenburgh <tvansteenburgh@gmail.com>


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/504e5084
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/504e5084
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/504e5084

Branch: refs/heads/cj/6272
Commit: 504e5084aee579523be1d9aa8048d1668279d9fd
Parents: 50ea686
Author: Tim Van Steenburgh <tvansteenburgh@gmail.com>
Authored: Wed Jun 5 23:24:05 2013 +0000
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Wed Jun 12 20:33:28 2013 +0000

----------------------------------------------------------------------
 Allura/allura/lib/utils.py | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/504e5084/Allura/allura/lib/utils.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/utils.py b/Allura/allura/lib/utils.py
index 2424930..7c490e2 100644
--- a/Allura/allura/lib/utils.py
+++ b/Allura/allura/lib/utils.py
@@ -42,6 +42,7 @@ from paste.httpheaders import CACHE_CONTROL, EXPIRES
 from webhelpers.html import literal
 from webob import exc
 from pygments.formatters import HtmlFormatter
+from setproctitle import getproctitle
 
 from ew import jinja2_ew as ew
 from ming.utils import LazyProperty
@@ -150,6 +151,20 @@ class StatsHandler(TimedRotatingHandler):
         TimedRotatingHandler.emit(self, record)
 
 
+class CustomWatchedFileHandler(logging.handlers.WatchedFileHandler):
+    """Custom log handler for Allura"""
+
+    def format(self, record):
+        """Prepends current process name to ``record.name`` if running in the
+        context of a taskd process that is currently processing a task.
+
+        """
+        title = getproctitle()
+        if title.startswith('taskd:'):
+            record.name = "{0}:{1}".format(title, record.name)
+        return super(CustomWatchedFileHandler, self).format(record)
+
+
 def chunked_find(cls, query=None, pagesize=1024, sort_key='_id', sort_dir=1):
     '''
     Execute a mongo query against the specified class, yield some results at


Mime
View raw message