netStack.js是一个用于.NET的最小jQuery语法高亮显示插件,使您能够使用自己的CSS样式高亮显示异常信息(堆栈跟踪)。
1.将堆栈跟踪插入<预>or<代码>标签
<pre class="stacktrace"> ConsoleApplication1.MyCustomException: some message .... ---> System.Exception: Oh noes! at ConsoleApplication1.SomeObject.OtherMethod() in C:\ConsoleApplication1\SomeObject.cs:line 24 at ConsoleApplication1.SomeObject..ctor() in C:\ConsoleApplication1\SomeObject.cs:line 14 --- End of inner exception stack trace --- at ConsoleApplication1.SomeObject..ctor() in C:\ConsoleApplication1\SomeObject.cs:line 18 at ConsoleApplication1.Program.DoSomething() in C:\ConsoleApplication1\Program.cs:line 23 at ConsoleApplication1.Program.Main(String[] args) in C:\ConsoleApplication1\Program.cs:line 13 </pre>
2.下载并在jQuery库后插入jQuery netStack.js。
<script src="/path/to/cdn/jquery.min.js"></script> <script src="netStack.js"></script>
3.初始化上的插件<预>要素
$('.stacktrace').netStack();
4.将您自己的样式应用于高亮显示的字符串。
pre, code {
background-color: #222;
color: #ffffff;
font-family:'Roboto Mono'
}
.st-type {
color: #0a8472;
font-weight: bolder;
}
.st-method {
color: #70c9ba;
font-weight: bolder;
}
.st-frame-params {
color: #ffffff;
font-weight: normal;
}
.st-param-type { color: #0a8472; }
.st-param-name { color: #ffffff; }
.st-file { color: #f8b068; }
.st-line { color: #ff4f68; }
5.类的默认值。
$('.stacktrace').netStack({
frame: 'st-frame',
type: 'st-type',
method: 'st-method',
paramsList: 'st-frame-params',
paramType: 'st-param-type',
paramName: 'st-param-name',
file: 'st-file',
line: 'st-line'
});
v1.1.2 (2023-02-07)
2021-11-17
v1.1.0 (2021-10-02)
2021-02-16
2020-02-28
2020-02-22
2019-08-15
2019-06-11
2019-02-11
2019-01-07
2018/08/18