Exemplo n.º 1
0
        public string FormatStackTrace(string stackTraceText)
        {
            if (string.IsNullOrWhiteSpace(stackTraceText))
            {
                return(string.Empty);
            }

            string html;

            try
            {
                var formattedStackTrace = StackTraceFormatter.FormatHtml(stackTraceText,
                                                                         new StackTraceHtmlFragments
                {
                    BeforeFrame = "<span class='frame'>",
                    AfterFrame  = "</span>",
                });

                html = $"<pre><code>{formattedStackTrace}</code></pre>";
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, $"Could not parse Stack Trace for \n{stackTraceText}");
                html = $"Stack Trace could not be parsed/formatted:<br /> {ex.Message}";
            }

            return(html);
        }
Exemplo n.º 2
0
 public NonEscapedString StackTrace(string stackTrace)
 {
     try
     {
         return(new NonEscapedString(StackTraceFormatter.FormatHtml(stackTrace, StackTraceHtmlFragments)));
     }
     catch (RegexMatchTimeoutException)
     {
         return(new NonEscapedString(HtmlEncode(stackTrace)));
     }
 }
Exemplo n.º 3
0
        public override void Execute()
        {
            WriteLiteral("\r\n");



            #line 5 "..\..\Views\Dashboard\LogInfo.cshtml"


            var log = (ILogModel)ViewData["Model"];



            #line default
            #line hidden
            WriteLiteral(@"<div class=""container-fluid"">
    <div class=""mb-4 open"">
        <ul class=""nav nav-tabs"" role=""tablist"">
            <li class=""nav-item"">
                <a class=""nav-link active"" data-toggle=""tab"" href=""#overview"" role=""tab"" aria-controls=""overview"" aria-selected=""true"">概览</a>
            </li>
            <li class=""nav-item"">
                <a class=""nav-link"" data-toggle=""tab"" href=""#environment"" role=""tab"" aria-controls=""environment"" aria-selected=""false"">其他</a>
            </li>
");



            #line 19 "..\..\Views\Dashboard\LogInfo.cshtml"

            if (typeof(IRequestTraceLogModel).IsAssignableFrom(Context.Options.LogModelType))
            {
            #line default
            #line hidden
                WriteLiteral("                    <li class=\"nav-item\">\r\n\r\n                        <a class=\"na" +
                             "v-link\" data-toggle=\"tab\" href=\"#requestTrace\" role=\"tab\" aria-controls=\"request" +
                             "Trace\" onclick=\"requestTrace(\'");



            #line 24 "..\..\Views\Dashboard\LogInfo.cshtml"
                Write(log.Id.ToString());


            #line default
            #line hidden
                WriteLiteral("\')\" aria-selected=\"false\">请求追踪</a>\r\n                    </li>\r\n");



            #line 26 "..\..\Views\Dashboard\LogInfo.cshtml"
            }



            #line default
            #line hidden
            WriteLiteral(@"        </ul>
        <div class=""tab-content"">
            <div class=""tab-pane active"" id=""overview"" role=""tabpanel"">
                <div class=""table-responsive"">
                    <table class=""table table-bordered"">
                        <tbody>
                            <tr>
                                <td>Id</td>
                                <td class=""text-nowrap"">");



            #line 37 "..\..\Views\Dashboard\LogInfo.cshtml"
            Write(log.Id.ToString());


            #line default
            #line hidden
            WriteLiteral("</td>\r\n                            </tr>\r\n                            <tr>\r\n     " +
                         "                           <td>时间</td>\r\n                                <td clas" +
                         "s=\"text-nowrap\">");



            #line 41 "..\..\Views\Dashboard\LogInfo.cshtml"
            Write(log.LongDate.ToString("yyyy-MM-dd HH:mm:ss"));


            #line default
            #line hidden
            WriteLiteral("</td>\r\n                            </tr>\r\n                            <tr>\r\n     " +
                         "                           <td>级别</td>\r\n                                <td clas" +
                         "s=\"text-nowrap\"><button class=\"btn btn-outline-");



            #line 45 "..\..\Views\Dashboard\LogInfo.cshtml"
            Write(log.Level.ToUpper());


            #line default
            #line hidden
            WriteLiteral("\">");



            #line 45 "..\..\Views\Dashboard\LogInfo.cshtml"
            Write(log.Level.ToUpper());


            #line default
            #line hidden
            WriteLiteral("</button></td>\r\n                            </tr>\r\n                            <t" +
                         "r>\r\n                                <td>Logger</td>\r\n                           " +
                         "     <td class=\"text-nowrap\">");



            #line 49 "..\..\Views\Dashboard\LogInfo.cshtml"
            Write(log.Logger);


            #line default
            #line hidden
            WriteLiteral("</td>\r\n                            </tr>\r\n                            <tr>\r\n     " +
                         "                           <td>消息</td>\r\n                                <td clas" +
                         "s=\"text-nowrap\">");



            #line 53 "..\..\Views\Dashboard\LogInfo.cshtml"
            Write(log.Message);


            #line default
            #line hidden
            WriteLiteral(@"</td>
                            </tr>

                        </tbody>
                    </table>
                    <div class=""card"">
                        <div class=""card-header bg-light"">
                            堆栈信息
                        </div>
                        <div class=""card-body"">
                            <pre>");



            #line 63 "..\..\Views\Dashboard\LogInfo.cshtml"
            Write(Raw(StackTraceFormatter.FormatHtml(log.Exception)));


            #line default
            #line hidden
            WriteLiteral(@"</pre>
                        </div>
                    </div>
                </div>
            </div>

            <div class=""tab-pane"" id=""environment"" role=""tabpanel"">
                <div class=""table-responsive"">
                    <table class=""table table-bordered"">
                        <tbody>
");



            #line 73 "..\..\Views\Dashboard\LogInfo.cshtml"

            foreach (var propertyInfo in Context.Options.CustomPropertyInfos)
            {
            #line default
            #line hidden
                WriteLiteral("                                    <tr>\r\n                                       " +
                             " <td style=\"width: 13%\">");



            #line 77 "..\..\Views\Dashboard\LogInfo.cshtml"
                Write(propertyInfo.Name);


            #line default
            #line hidden
                WriteLiteral("</td>\r\n                                        <td class=\"text-nowrap\">");



            #line 78 "..\..\Views\Dashboard\LogInfo.cshtml"
                Write(propertyInfo.GetValue(log));


            #line default
            #line hidden
                WriteLiteral("</td>\r\n                                    </tr>\r\n");



            #line 80 "..\..\Views\Dashboard\LogInfo.cshtml"
            }



            #line default
            #line hidden
            WriteLiteral(@"                        </tbody>
                    </table>
                </div>
            </div>

            <div class=""tab-pane"" id=""requestTrace"" role=""tabpanel"">
                <div class=""table-responsive"">
                    <div id=""traceLogList"">

                    </div>
                </div>
            </div>
        </div>
    </div>
</div>");
        }
Exemplo n.º 4
0
 public NonEscapedString StackTrace(string stackTrace)
 {
     return(new NonEscapedString(StackTraceFormatter.FormatHtml(stackTrace, StackTraceHtmlFragments)));
 }