Permalink
Browse files

Exceptional v2

This upgrades Exceptional to v2 and takes advantage of several features. HighlightJS is added, which will be followed up with a prettify removal later.
  • Loading branch information...
NickCraver committed Sep 20, 2017
1 parent b4116d9 commit f07b685eafd8861518ec577823bd9522774ff318
View
@@ -36,7 +36,7 @@ public static void LogException(Exception exception, string key = null)
.AddLoggedData("Ended-Unexpectedly", deserializationException.EndedUnexpectedly.ToString());
}
ErrorStore.LogExceptionWithoutContext(exception, appendFullStackTrace: true);
exception.LogNoContext();
RecordLogged(key);
}
@@ -160,9 +160,9 @@ private static IEnumerable<Error> GetSorted(IEnumerable<Error> source, Exception
case ExceptionSorts.MessageDesc:
return source.OrderByDescending(e => e.Message);
case ExceptionSorts.UrlAsc:
return source.OrderBy(e => e.Url);
return source.OrderBy(e => e.UrlPath);
case ExceptionSorts.UrlDesc:
return source.OrderByDescending(e => e.Url);
return source.OrderByDescending(e => e.UrlPath);
case ExceptionSorts.IPAddressAsc:
return source.OrderBy(e => e.IPAddress);
case ExceptionSorts.IPAddressDesc:
@@ -195,7 +195,7 @@ private string RenderDescription(Error error, string accountName)
sb.AppendFormat("Machine Name: {0}\r\n", error.MachineName);
sb.AppendFormat("Host: {0}\r\n", error.Host);
sb.AppendFormat("Created On (UTC): {0}\r\n", error.CreationDate.ToString(CultureInfo.CurrentCulture));
sb.AppendFormat("Url: {0}\r\n", error.Url);
sb.AppendFormat("Url: {0}\r\n", error.FullUrl);
sb.AppendFormat("HTTP Method: {0}\r\n", error.HTTPMethod);
sb.AppendFormat("IP Address: {0}\r\n", error.IPAddress);
sb.AppendFormat("Count: {0}\r\n", error.DuplicateCount.ToString());
@@ -38,7 +38,7 @@
<PackageReference Include="Jil" Version="2.15.3" />
<PackageReference Include="MiniProfiler" Version="3.2.0.157" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
<PackageReference Include="StackExchange.Exceptional" Version="1.0.130" />
<PackageReference Include="StackExchange.Exceptional" Version="2.0.0-alpha3-00180" />
<PackageReference Include="StackExchange.Redis" Version="1.2.1.0" />
<PackageReference Include="UnconstrainedMelody" Version="0.2.1" />
<Reference Include="Microsoft.CSharp" />
@@ -1,6 +1,6 @@
using System;
using StackExchange.Exceptional;
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
namespace StackExchange.Opserver
{
@@ -16,6 +16,9 @@ public class ExceptionsSettings : Settings<ExceptionsSettings>
public List<StackTraceSourceLinkPattern> StackTraceReplacements { get; set; } = new List<StackTraceSourceLinkPattern>();
private StackTraceSettings _stackTraceSettings;
public StackTraceSettings StackTraceSettings => _stackTraceSettings ?? (_stackTraceSettings = GetStackTraceSettings());
/// <summary>
/// How many exceptions before the exceptions are highlighted as a warning in the header, null (default) is ignored
/// </summary>
@@ -85,6 +88,26 @@ public class Store : ISettingsCollectionItem
public string ConnectionString { get; set; }
}
private StackTraceSettings GetStackTraceSettings()
{
var result = new StackTraceSettings();
foreach (var str in StackTraceReplacements)
{
if (str.Pattern.HasValue())
{
try
{
result.AddReplacement(str.Pattern, str.Replacement);
}
catch (Exception ex)
{
Current.LogException($"Unable to parse source link pattern for '{str.Name}': '{str.Pattern}'", ex);
}
}
}
return result;
}
public class StackTraceSourceLinkPattern : ISettingsCollectionItem
{
/// <summary>
@@ -94,7 +117,7 @@ public class StackTraceSourceLinkPattern : ISettingsCollectionItem
/// <summary>
/// A regular expression for detecting links in stack traces.
/// Used in conjuction with <see cref="Replacement"/>.
/// Used in conjunction with <see cref="Replacement"/>.
/// </summary>
public string Pattern { get; set; }
@@ -103,33 +126,6 @@ public class StackTraceSourceLinkPattern : ISettingsCollectionItem
/// matches via <see cref="Regex.Replace(string, string, string)"/>.
/// </summary>
public string Replacement { get; set; }
private static readonly Regex DontMatchAnything = new Regex("(?!)");
private Regex _regex;
public Regex RegexPattern()
{
if (_regex == null)
{
if (Pattern.HasValue())
{
try
{
_regex = new Regex(Pattern, RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.CultureInvariant);
}
catch (Exception ex)
{
Current.LogException($"Unable to parse source link pattern for '{nameof(Name)}': '{Pattern}'", ex);
_regex = DontMatchAnything;
}
}
else
{
_regex = DontMatchAnything;
}
}
return _regex;
}
}
}
}
View
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26730.8
VisualStudioVersion = 15.0.26906.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Opserver.Core", "Opserver.Core\Opserver.Core.csproj", "{C58AFF99-F4D9-4A83-866E-18DA0A633F6B}"
EndProject
@@ -10,6 +10,7 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{52AF00E9-833A-44FE-BE7B-0DC7B84E2814}"
ProjectSection(SolutionItems) = preProject
Build.bat = Build.bat
nuget.config = nuget.config
readme.md = readme.md
WebEssentials-Settings.json = WebEssentials-Settings.json
EndProjectSection
@@ -393,6 +393,7 @@
});
prepTableSorter();
prettyPrint();
hljs.initHighlighting();
}
return {

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -2,6 +2,7 @@
@import "../../font-awesome/less/font-awesome.less";
@import "_shared/_variables.less";
@import "_shared/_bootswatch.less";
@import "_shared/highlightjs.less";
@import "_shared/animations.less";
@import "_shared/spinkit.less";
@import "_shared/prettify.less";
@@ -0,0 +1,114 @@
/*
* Based on:
* Visual Studio 2015 dark style
* Author: Nicolas LLOBERA <nllobera@gmail.com>
*/
.command code, .hljs {
display: block;
overflow-x: auto;
padding: 0.5em;
background: #2f3640;
color: #e6e9ed;
border: solid 1px #f5f5f5;
}
.hljs-keyword,
.hljs-literal,
.hljs-symbol,
.hljs-name {
color: #4fc1e9;
}
.hljs-link {
color: #4fc1e9;
text-decoration: underline;
}
.hljs-built_in,
.hljs-type {
color: #4EC9B0;
}
.hljs-number,
.hljs-class {
color: #B8D7A3;
}
.hljs-string,
.hljs-meta-string {
color: #D69D85;
}
.hljs-regexp,
.hljs-template-tag {
color: #9A5334;
}
.hljs-subst,
.hljs-function,
.hljs-title,
.hljs-params,
.hljs-formula {
color: #DCDCDC;
}
.hljs-comment,
.hljs-quote {
color: #57A64A;
font-style: italic;
}
.hljs-doctag {
color: #608B4E;
}
.hljs-meta,
.hljs-meta-keyword,
.hljs-tag {
color: #8e9caf;
}
.hljs-variable,
.hljs-template-variable {
color: #BD63C5;
}
.hljs-attr,
.hljs-attribute,
.hljs-builtin-name {
color: #9CDCFE;
}
.hljs-section {
color: gold;
}
.hljs-emphasis {
font-style: italic;
}
.hljs-strong {
font-weight: bold;
}
.hljs-bullet,
.hljs-selector-tag,
.hljs-selector-id,
.hljs-selector-class,
.hljs-selector-attr,
.hljs-selector-pseudo {
color: #D7BA7D;
}
.hljs-addition {
background-color: #144212;
display: inline-block;
width: 100%;
}
.hljs-deletion {
background-color: #600;
display: inline-block;
width: 100%;
}
@@ -8657,6 +8657,102 @@ input[type="checkbox"] {
.modal .close {
color: #EBEBEB;
}
/*
* Based on:
* Visual Studio 2015 dark style
* Author: Nicolas LLOBERA <nllobera@gmail.com>
*/
.command code,
.hljs {
display: block;
overflow-x: auto;
padding: 0.5em;
background: #2f3640;
color: #e6e9ed;
border: solid 1px #f5f5f5;
}
.hljs-keyword,
.hljs-literal,
.hljs-symbol,
.hljs-name {
color: #4fc1e9;
}
.hljs-link {
color: #4fc1e9;
text-decoration: underline;
}
.hljs-built_in,
.hljs-type {
color: #4EC9B0;
}
.hljs-number,
.hljs-class {
color: #B8D7A3;
}
.hljs-string,
.hljs-meta-string {
color: #D69D85;
}
.hljs-regexp,
.hljs-template-tag {
color: #9A5334;
}
.hljs-subst,
.hljs-function,
.hljs-title,
.hljs-params,
.hljs-formula {
color: #DCDCDC;
}
.hljs-comment,
.hljs-quote {
color: #57A64A;
font-style: italic;
}
.hljs-doctag {
color: #608B4E;
}
.hljs-meta,
.hljs-meta-keyword,
.hljs-tag {
color: #8e9caf;
}
.hljs-variable,
.hljs-template-variable {
color: #BD63C5;
}
.hljs-attr,
.hljs-attribute,
.hljs-builtin-name {
color: #9CDCFE;
}
.hljs-section {
color: gold;
}
.hljs-emphasis {
font-style: italic;
}
.hljs-strong {
font-weight: bold;
}
.hljs-bullet,
.hljs-selector-tag,
.hljs-selector-id,
.hljs-selector-class,
.hljs-selector-attr,
.hljs-selector-pseudo {
color: #D7BA7D;
}
.hljs-addition {
background-color: #144212;
display: inline-block;
width: 100%;
}
.hljs-deletion {
background-color: #600;
display: inline-block;
width: 100%;
}
.spin,
.hover-spin:hover .fa {
-webkit-animation: spin 2s infinite linear;

Large diffs are not rendered by default.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit f07b685

Please sign in to comment.