/// <summary>
        /// Adds a sink that writes log events as documents to a SignalR hub.
        /// </summary>
        /// <param name="loggerConfiguration">The logger configuration.</param>
        /// <param name="context">The hub context.</param>
        /// <param name="restrictedToMinimumLevel">The minimum log event level required in order to write an event to the sink.</param>
        /// <param name="batchPostingLimit">The maximum number of events to post in a single batch.</param>
        /// <param name="period">The time to wait between checking for event batches.</param>
        /// <param name="formatProvider">Supplies culture-specific formatting information, or null.</param>
        /// <param name="groupNames">Names of the Signalr groups you are broadcasting the log event to. Default is All Groups.</param>
        /// <param name="userIds">ID's of the Signalr Users you are broadcasting the log event to. Default is All Users.</param>
        /// <param name="excludedConnectionIds">Signalr connection ID's to exclude from broadcast.</param>
        /// <returns>Logger configuration, allowing configuration to continue.</returns>
        /// <exception cref="ArgumentNullException">A required parameter is null.</exception>
        public static LoggerConfiguration SignalR(
            this LoggerSinkConfiguration loggerConfiguration,
            IHubContext <LogHub, ILogEventClient> context,
            LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum,
            int batchPostingLimit          = SignalRSink.DefaultBatchPostingLimit,
            TimeSpan?period                = null,
            IFormatProvider formatProvider = null,
            string[] groupNames            = null,
            string[] userIds               = null,
            string[] excludedConnectionIds = null)
        {
            if (loggerConfiguration == null)
            {
                throw new ArgumentNullException(nameof(loggerConfiguration));
            }
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            var defaultedPeriod = period ?? SignalRSink.DefaultPeriod;

            var signalRSink = new SignalRSink(context, batchPostingLimit, defaultedPeriod, formatProvider, groupNames, userIds, excludedConnectionIds);

            return(loggerConfiguration.Sink(signalRSink, restrictedToMinimumLevel));
        }
        /// <summary>
        /// Subscribes to an <see cref="T:System.IObservable`1"/> using a <see cref="T:SemanticLogging.SignalR.SignalRSink"/>.
        /// 
        /// </summary>
        /// <param name="eventStream">The event stream. Typically this is an instance of <see cref="T:Microsoft.Practices.EnterpriseLibrary.SemanticLogging.ObservableEventListener"/>.</param><param name="formatter">The formatter.</param><param name="colorMapper">The color mapper instance.</param>
        /// <returns>
        /// A subscription to the sink that can be disposed to unsubscribe the sink, or to get access to the sink instance.
        /// </returns>
        public static SinkSubscription<SignalRSink> LogToSignalR(this IObservable<EventEntry> eventStream, IEventTextFormatter formatter = null)
        {
            var sink = new SignalRSink();
            formatter = formatter ?? new EventTextFormatter();

            EnsureHostConfigured(sink);

            return new SinkSubscription<SignalRSink>(EventEntryExtensions.SubscribeWithFormatter(eventStream, formatter, sink), sink);
        }
 private static void EnsureHostConfigured(SignalRSink sink)
 {
     sink.Startup();
 }