260 lines
8.2 KiB
Plaintext
260 lines
8.2 KiB
Plaintext
@using System
|
|
@using System.Globalization
|
|
@using System.Linq
|
|
@using Microsoft.AspNetCore.Diagnostics.Elm
|
|
@using Microsoft.AspNetCore.Diagnostics.Elm.RazorViews
|
|
@using Microsoft.Extensions.RazorViews
|
|
@using Microsoft.Extensions.Logging
|
|
|
|
@functions
|
|
{
|
|
public DetailsPage(DetailsPageModel model)
|
|
{
|
|
Model = model;
|
|
}
|
|
|
|
public DetailsPageModel Model { get; set; }
|
|
|
|
public HelperResult LogRow(LogInfo log)
|
|
{
|
|
return new HelperResult((writer) =>
|
|
{
|
|
if (log.Severity >= Model.Options.MinLevel &&
|
|
(string.IsNullOrEmpty(Model.Options.NamePrefix) || log.Name.StartsWith(Model.Options.NamePrefix, StringComparison.Ordinal)))
|
|
{
|
|
PushWriter(writer);
|
|
WriteLiteral(" <tr>\r\n <td>");
|
|
Write(string.Format("{0:MM/dd/yy}", log.Time));
|
|
WriteLiteral("</td>\r\n <td>");
|
|
Write(string.Format("{0:H:mm:ss}", log.Time));
|
|
var severity = log.Severity.ToString().ToLowerInvariant();
|
|
WriteLiteral($"</td>\r\n <td class=\"{severity}\">");
|
|
Write(log.Severity);
|
|
|
|
WriteLiteral($"</td>\r\n <td title=\"{log.Name}\">");
|
|
Write(log.Name);
|
|
|
|
WriteLiteral($"</td>\r\n <td title=\"{log.Message}\""+
|
|
"class=\"logState\" width=\"100px\">");
|
|
Write(log.Message);
|
|
|
|
WriteLiteral($"</td>\r\n <td title=\"{log.Exception}\">");
|
|
Write(log.Exception);
|
|
|
|
WriteLiteral("</td>\r\n </tr>\r\n");
|
|
PopWriter();
|
|
}
|
|
});
|
|
}
|
|
|
|
public HelperResult Traverse(ScopeNode node)
|
|
{
|
|
return new HelperResult((writer) =>
|
|
{
|
|
var messageIndex = 0;
|
|
var childIndex = 0;
|
|
while (messageIndex < node.Messages.Count && childIndex < node.Children.Count)
|
|
{
|
|
if (node.Messages[messageIndex].Time < node.Children[childIndex].StartTime)
|
|
{
|
|
LogRow(node.Messages[messageIndex]);
|
|
messageIndex++;
|
|
}
|
|
else
|
|
{
|
|
Traverse(node.Children[childIndex]);
|
|
childIndex++;
|
|
}
|
|
}
|
|
if (messageIndex < node.Messages.Count)
|
|
{
|
|
for (var i = messageIndex; i < node.Messages.Count; i++)
|
|
{
|
|
LogRow(node.Messages[i]);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
for (var i = childIndex; i < node.Children.Count; i++)
|
|
{
|
|
Traverse(node.Children[i]);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|
|
@{
|
|
Response.ContentType = "text/html; charset=utf-8";
|
|
}
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<title>ASP.NET Core Logs</title>
|
|
<script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-2.1.1.min.js"></script>
|
|
<style>
|
|
<%$ include: Shared.css %> <%$ include: DetailsPage.css %>
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<h1>ASP.NET Core Logs</h1>
|
|
@{
|
|
var context = Model.Activity?.HttpInfo;
|
|
}
|
|
@if (context != null)
|
|
{
|
|
<h2 id="requestHeader">Request Details</h2>
|
|
<table id="requestDetails">
|
|
<colgroup><col id="label" /><col /></colgroup>
|
|
|
|
<tr>
|
|
<th>Path</th>
|
|
<td>@context.Path</td>
|
|
</tr>
|
|
<tr>
|
|
<th>Host</th>
|
|
<td>@context.Host</td>
|
|
</tr>
|
|
<tr>
|
|
<th>Content Type</th>
|
|
<td>@context.ContentType</td>
|
|
</tr>
|
|
<tr>
|
|
<th>Method</th>
|
|
<td>@context.Method</td>
|
|
</tr>
|
|
<tr>
|
|
<th>Protocol</th>
|
|
<td>@context.Protocol</td>
|
|
</tr>
|
|
<tr>
|
|
<th>Headers</th>
|
|
<td id="headerTd">
|
|
<table id="headerTable">
|
|
<thead>
|
|
<tr>
|
|
<th>Variable</th>
|
|
<th>Value</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach (var header in context.Headers)
|
|
{
|
|
<tr>
|
|
<td>@header.Key</td>
|
|
<td>@string.Join(";", header.Value)</td>
|
|
</tr>
|
|
}
|
|
</tbody>
|
|
</table>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th>Status Code</th>
|
|
<td>@context.StatusCode</td>
|
|
</tr>
|
|
<tr>
|
|
<th>User</th>
|
|
<td>@context.User.Identity.Name</td>
|
|
</tr>
|
|
<tr>
|
|
<th>Claims</th>
|
|
<td>
|
|
@if (context.User.Claims.Any())
|
|
{
|
|
<table id="claimsTable">
|
|
<thead>
|
|
<tr>
|
|
<th>Issuer</th>
|
|
<th>Value</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach (var claim in context.User.Claims)
|
|
{
|
|
<tr>
|
|
<td>@claim.Issuer</td>
|
|
<td>@claim.Value</td>
|
|
</tr>
|
|
}
|
|
</tbody>
|
|
</table>
|
|
}
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th>Scheme</th>
|
|
<td>@context.Scheme</td>
|
|
</tr>
|
|
<tr>
|
|
<th>Query</th>
|
|
<td>@context.Query.Value</td>
|
|
</tr>
|
|
<tr>
|
|
<th>Cookies</th>
|
|
<td>
|
|
@if (context.Cookies.Any())
|
|
{
|
|
<table id="cookieTable">
|
|
<thead>
|
|
<tr>
|
|
<th>Variable</th>
|
|
<th>Value</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach (var cookie in context.Cookies)
|
|
{
|
|
<tr>
|
|
<td>@cookie.Key</td>
|
|
<td>@string.Join(";", cookie.Value)</td>
|
|
</tr>
|
|
}
|
|
</tbody>
|
|
</table>
|
|
}
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
}
|
|
<h2>Logs</h2>
|
|
<form method="get">
|
|
<select name="level">
|
|
@foreach (var severity in Enum.GetValues(typeof(LogLevel)))
|
|
{
|
|
var severityInt = (int)severity;
|
|
if ((int)Model.Options.MinLevel == severityInt)
|
|
{
|
|
<option value="@severityInt" selected="selected">@severity</option>
|
|
}
|
|
else
|
|
{
|
|
<option value="@severityInt">@severity</option>
|
|
}
|
|
}
|
|
</select>
|
|
<input type="text" name="name" value="@Model.Options.NamePrefix" />
|
|
<input type="submit" value="filter" />
|
|
</form>
|
|
<table id="logs">
|
|
<thead>
|
|
<tr>
|
|
<th>Date</th>
|
|
<th>Time</th>
|
|
<th>Severity</th>
|
|
<th>Name</th>
|
|
<th>State</th>
|
|
<th>Error</th>
|
|
</tr>
|
|
</thead>
|
|
@Traverse(Model.Activity.Root)
|
|
</table>
|
|
<script type="text/javascript">
|
|
$(document).ready(function () {
|
|
$("#requestHeader").click(function () {
|
|
$("#requestDetails").toggle();
|
|
});
|
|
});
|
|
</script>
|
|
</body>
|
|
</html> |