Package Products :: Package ZenUtils :: Module tbdetail |
[hide private]
[frames] | no frames]

# Source Code for Module Products.ZenUtils.tbdetail

     1  ##############################################################################
     2  #
     3  # Copyright (C) Zenoss, Inc. 2012, all rights reserved.
     4  #
     5  # This content is made available according to terms specified in
     6  # License.zenoss under the directory where your Zenoss product is installed.
     7  #
     8  ##############################################################################
     9
    10
    11  import os
    12  import re
    13  import cgitb
    14  from cStringIO import StringIO
    15  import Globals
    16  from Products.ZenUtils.Utils import unused, zenPath
    17
    18  unused(Globals)
    19
    20  pattern = re.compile(r'<p> (?P<message>.* contains the description of this error.)')
    21
    22 -def log_tb(exc_info):
    23      file_ = StringIO()
    24      hook = cgitb.Hook(display=0, logdir=zenPath('log', 'tracebacks'), file=file_, format='text')
    25      os.makedirs(hook.logdir)
    26      hook.handle(exc_info)
    27      output = file_.getvalue()
    28      match = pattern.search(output)
    29      return match.group('message')
    30