當前位置: 首頁>>代碼示例>>Python>>正文


Python Logger.getFormattedStackTrace方法代碼示例

本文整理匯總了Python中pyaid.debug.Logger.Logger.getFormattedStackTrace方法的典型用法代碼示例。如果您正苦於以下問題:Python Logger.getFormattedStackTrace方法的具體用法?Python Logger.getFormattedStackTrace怎麽用?Python Logger.getFormattedStackTrace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pyaid.debug.Logger.Logger的用法示例。


在下文中一共展示了Logger.getFormattedStackTrace方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from pyaid.debug.Logger import Logger [as 別名]
# 或者: from pyaid.debug.Logger.Logger import getFormattedStackTrace [as 別名]
    def __init__(self, **kwargs):
        """Creates a new instance of MarkupError."""

        self._thrown     = Logger.getFormattedStackTrace(2, 3)
        self._definition = ArgsUtils.get('errorDef', None, kwargs)
        self._tag        = ArgsUtils.get('tag', None, kwargs)
        self._block      = ArgsUtils.get('block', self._tag.block if self._tag else None, kwargs)
        self._processor  = ArgsUtils.get('processor', self._tag.processor if self._tag else None, kwargs)
        self._code       = ArgsUtils.get('code', self._definition.code, kwargs, allowNone=False)
        self.label       = ArgsUtils.get('label', self._definition.label, kwargs, allowNone=False)
        self.message     = ArgsUtils.get('message', self._definition.message, kwargs, allowNone=False)
        self._critical   = ArgsUtils.get('critical', False, kwargs)

        replacements = ArgsUtils.getAsList('replacements', kwargs)
        replacements.append([u'#TAG#', unicode(self._tag.tagName if self._tag else u'???')])

        for r in replacements:
            if self.message:
                self.message = self.message.replace(unicode(r[0]), unicode(r[1]))

            if self.label:
                self.label = self.label.replace(unicode(r[0]), unicode(r[1]))

        self._verbose   = ArgsUtils.get('verbose', False, kwargs)
        self._line      = None
        self._character = None
        self._source    = None
        self._logSource = None
        self._populateData()
開發者ID:sernst,項目名稱:StaticFlow,代碼行數:31,代碼來源:MarkupError.py

示例2: writeLog

# 需要導入模塊: from pyaid.debug.Logger import Logger [as 別名]
# 或者: from pyaid.debug.Logger.Logger import getFormattedStackTrace [as 別名]
    def writeLog(
            self, header, message, extras =None, headerColor =None, headerBackColor =None,
            color =None, backColor =None, fontSize =None, error =None, prefix =None, suffix =None
    ):
        """ Formats the specified header and message according to the various formatting arguments
            and writes resulting message the log """

        if not headerColor:
            headerColor = u'#000000'
        if not headerBackColor:
            headerBackColor = u'#FFFFFF'
        if not color:
            color = u'#333333'
        if not backColor:
            backColor = u'#FFFFFF'
        if not fontSize:
            fontSize = 11

        # Out is formatted on separate lines because Qt text edit widget requires newlines to
        # change styles
        out = [
            u'<div style="font-size:%spx;color:%s;background-color:%s;">' % (
                fontSize, color, backColor),
            u'<span style="font-weight:bold;color:%s;background-color:%s;font-size:%spx;">' % (
                headerColor, headerBackColor, fontSize + 2),
            unicode(header) + u': ',
              u'</span>',
            unicode(message),
            u'</div>']

        if prefix:
            out.insert(0, prefix)

        #--- EXTRAS
        #       If an extras argument (dict, list, or basestring) was included, format it for
        #       friendly display
        if extras:
            out.append(u'<div>\n<ul style="font-size:%spx;color:%s;background-color:%s">' % (
                fontSize, color, backColor))

            if isinstance(extras, list):
                for item in extras:
                    out.append(u'<li>%s</li>' % item)
            elif isinstance(extras, dict):
                for n,v in extras.iteritems():
                    out.append(u'<li><span style="font-weight:bold">%s:</span> %s</li>' % (n, v))
            else:
                out.append(u'<li>%s</li>' % extras)
            out.append(u'</ul>\n<div>')

        #--- ERROR
        #       Format the error and stack trace for friendly display if present
        if error:
            out.append(u'<div style="font-size:14px;color:%s">%s</div>' % (headerColor, error))
            stack = Logger.getFormattedStackTrace(0, 3)
            out.extend([
                u'<br />',
                u'<div style="font-size:10px;color:#AAAAAA">',
                u'<span style="font-weight:bold">Thrown At:</span> %s' % stack.replace(
                    '\n', u'<br />').replace(
                    '  ', '&nbsp;&nbsp;').replace(
                    '\t', '&nbsp;&nbsp;&nbsp;&nbsp;'),
                u'</div>\n<br />'])

        if suffix:
            out.append(suffix)

        # Create final combined string and shorten known paths for compact display
        out = u'\n'.join(out).replace(
            self.sourceWebRootPath, u'/').replace(
            self.containerPath, u'//')

        self.logger.write(out)
開發者ID:sernst,項目名稱:StaticFlow,代碼行數:75,代碼來源:Site.py


注:本文中的pyaid.debug.Logger.Logger.getFormattedStackTrace方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。