Skip to content

Commit

Permalink
Make tracing signals a config setting
Browse files Browse the repository at this point in the history
  • Loading branch information
davidfowl committed Sep 5, 2011
1 parent 4c653da commit 5026708
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
22 changes: 16 additions & 6 deletions Chat/Global.asax.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,34 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CSharp.RuntimeBinder;
using SignalR;
using SignalR.Infrastructure;
using SignalR.Transports;
using System.Configuration;

namespace Chat {
public class Global : System.Web.HttpApplication {
public static DateTimeOffset Started = DateTimeOffset.UtcNow;

protected void Application_Start() {
var bus = new TracedSignalBus(new InProcessSignalBus());
DependencyResolver.Register(typeof(ISignalBus), () => bus);
var setting = ConfigurationManager.AppSettings["traceSignals"];
bool traceSignals;
if (!String.IsNullOrEmpty(setting) &&
Boolean.TryParse(setting, out traceSignals) &&
traceSignals) {
var bus = new TracedSignalBus(new InProcessSignalBus());
DependencyResolver.Register(typeof(ISignalBus), () => bus);

var store = new TracedMessageStore(new InProcessMessageStore());
DependencyResolver.Register(typeof(IMessageStore), () => store);
var store = new TracedMessageStore(new InProcessMessageStore());
DependencyResolver.Register(typeof(IMessageStore), () => store);
}

AppDomain.CurrentDomain.FirstChanceException += (sender, e) => {
var ex = e.Exception.GetBaseException();
if (!(ex is InvalidOperationException) &&
!(ex is RuntimeBinderException) &&
!(ex is MissingMethodException)) {
!(ex is MissingMethodException) &&
!(ex is ThreadAbortException)) {
Elmah.ErrorSignal.Get(this).Raise(ex);
}
};
Expand Down
3 changes: 3 additions & 0 deletions Chat/Web.config
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
<section name="errorFilter" requirePermission="false" type="Elmah.ErrorFilterSectionHandler, Elmah" />
</sectionGroup>
</configSections>
<appSettings>
<add key="traceSignals" value="false" />
</appSettings>
<elmah>
<security allowRemoteAccess="true" />
<errorFilter>
Expand Down

0 comments on commit 5026708

Please sign in to comment.