Skip to content

Commit

Permalink
Caching ResolveLogProvider's result
Browse files Browse the repository at this point in the history
  • Loading branch information
Elad Zelingher committed Jul 31, 2017
1 parent 5b6eefd commit 005ab87
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
9 changes: 8 additions & 1 deletion src/net45/WampSharp/App_Packages/LibLog.4.2/LibLog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -624,9 +624,16 @@ private static void RaiseOnCurrentLogProviderSet()
}
#endif

internal static ILogProvider ResolveLogProvider()
{
return mResolvedLogProvider.Value;
}

private static Lazy<ILogProvider> mResolvedLogProvider = new Lazy<ILogProvider>(() => InnerResolveLogProvider());

[SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "System.Console.WriteLine(System.String,System.Object,System.Object)")]
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
internal static ILogProvider ResolveLogProvider()
private static ILogProvider InnerResolveLogProvider()
{
try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public LoggerWithConnectionId(ILog logger)

public bool Log(LogLevel logLevel, Func<string> messageFunc, Exception exception = null, params object[] formatParameters)
{
using (LogProvider.OpenMappedContext("ConncetionId", mConnectionId))
using (LogProvider.OpenMappedContext("ConnectionId", mConnectionId))
{
return mLogger.Log(logLevel, messageFunc, exception, formatParameters);
}
Expand Down
13 changes: 3 additions & 10 deletions src/net45/WampSharp/Core/Listener/WampListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,10 @@ private IDisposable SessionIdMappedContext(TClient client)
sessionIdString = sessionIdValue.ToString();
}

if (LogProvider.CurrentLogProvider == null)
{
return Disposable.Empty;
}
else
{
IDisposable disposable =
LogProvider.OpenMappedContext("WampSessionId", sessionIdString);
IDisposable disposable =
LogProvider.OpenMappedContext("WampSessionId", sessionIdString);

return disposable;
}
return disposable;
}

protected virtual object GetSessionId(TClient client)
Expand Down

0 comments on commit 005ab87

Please sign in to comment.