239 lines
7.3 KiB
Plaintext
239 lines
7.3 KiB
Plaintext
@using System
|
|
@using System.Globalization
|
|
@using System.Linq
|
|
@using Microsoft.AspNet.Diagnostics.Elm
|
|
@using Microsoft.AspNet.Diagnostics.Views
|
|
@using Microsoft.AspNet.Diagnostics.Elm.Views
|
|
@using Microsoft.Extensions.Logging
|
|
|
|
@functions
|
|
{
|
|
public DetailsPage(DetailsPageModel model)
|
|
{
|
|
Model = model;
|
|
}
|
|
|
|
public DetailsPageModel Model { get; set; }
|
|
}
|
|
|
|
@helper LogRow(LogInfo log)
|
|
{
|
|
if (log.Severity >= Model.Options.MinLevel &&
|
|
(string.IsNullOrEmpty(Model.Options.NamePrefix) || log.Name.StartsWith(Model.Options.NamePrefix, StringComparison.Ordinal)))
|
|
{
|
|
<tr>
|
|
<td>@string.Format("{0:MM/dd/yy}", log.Time)</td>
|
|
<td>@string.Format("{0:H:mm:ss}", log.Time)</td>
|
|
<td class="@log.Severity.ToString().ToLowerInvariant()">@log.Severity</td>
|
|
<td title="@log.Name">@log.Name</td>
|
|
<td title="@log.Message" class="logState" width="100px">@log.Message</td>
|
|
<td title="@log.Exception">@log.Exception</td>
|
|
</tr>
|
|
}
|
|
}
|
|
|
|
@helper Traverse(ScopeNode node)
|
|
{
|
|
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])
|
|
}
|
|
}
|
|
}
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<title>ASP.NET 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 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> |