You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by jo...@apache.org on 2013/06/12 23:26:22 UTC

[2/3] git commit: [#5721] Add task details to taskd log lines

[#5721] Add task details to taskd log lines

Signed-off-by: Tim Van Steenburgh <tv...@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 <tv...@gmail.com>
Authored: Wed Jun 5 23:24:05 2013 +0000
Committer: Dave Brondsema <db...@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