incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tvansteenbu...@apache.org
Subject git commit: [#5721] Add task details to taskd log lines
Date Wed, 05 Jun 2013 23:24:24 GMT
Updated Branches:
  refs/heads/tv/5721 [created] 76c0532a7


[#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/76c0532a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/76c0532a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/76c0532a

Branch: refs/heads/tv/5721
Commit: 76c0532a7c300ed239edd193a6abab17bdf38867
Parents: 028d1e3
Author: Tim Van Steenburgh <tvansteenburgh@gmail.com>
Authored: Wed Jun 5 23:24:05 2013 +0000
Committer: Tim Van Steenburgh <tvansteenburgh@gmail.com>
Committed: Wed Jun 5 23:24:05 2013 +0000

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


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/76c0532a/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