Created
April 6, 2013 08:27
-
-
Save AndrewNewcomb/5325394 to your computer and use it in GitHub Desktop.
MiniProfilerTraceListener is a custom TraceListener that sends all messages to the StackExchange MiniProfiler.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Diagnostics; | |
using StackExchange.Profiling; | |
namespace PSL.Web.Infrastructure | |
{ | |
//Needs web.config entry | |
//<add name="TraceToMiniProfiler" type="PSL.Web.Infrastructure.MiniProfilerTraceListener, theassemblyname" initializeData="" /> | |
public class MiniProfilerTraceListener : TraceListener | |
{ | |
public override void Write(string message) | |
{ | |
WriteToProfiler(message); | |
} | |
public override void WriteLine(string message) | |
{ | |
WriteToProfiler(message); | |
} | |
private static void WriteToProfiler(string message) | |
{ | |
MiniProfiler profiler = MiniProfiler.Current; | |
using (profiler.Step(message)) | |
{ | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment