private static void Main(string[] args) { using (var logWriter = CreateStandardOutputLogWriter()) { var shouter = new Shouter(logWriter); while (true) { shouter.Shout(new System.Threading.CancellationToken()); } } }
protected void ShoutLoop() { // Configue a LogWriter to write to the Windows Event Log. var eventLog = new EventLog("Application", ".", "ShoutService"); var eventLogTraceListener = new FormattedEventLogTraceListener(eventLog) { Filter = new SeverityFilter(new TraceEventType[] { TraceEventType.Error, TraceEventType.Information, TraceEventType.Warning}) }; var config = new LoggingConfiguration(); config.AddLogSource("All", SourceLevels.All, true) .AddTraceListener(eventLogTraceListener); // A using statement ensures the log gets flushed when this process exits. using (var logWriter = new LogWriter(config)) { var shouter = new Shouter(logWriter); do { shouter.Shout(cancellationTokenSource.Token); } while (!cancellationTokenSource.Token.IsCancellationRequested); } }
public Test() { _httpMessageHandler = new MockMessageHandler(); _logStream = new MemoryStream(); var init = Shouter.Initializer.CreateDefault(); init.LogWriter = CreateLogWriter(_logStream); init.HttpClient = new HttpClient(_httpMessageHandler); _pubsub = init.PubsubService; init.SubscriptionName += "-test"; init.ProjectId = Environment.GetEnvironmentVariable("GOOGLE_PROJECT_ID"); _topicPath = $"projects/{init.ProjectId}/topics/{init.SubscriptionName}-topic"; _subscriptionPath = $"projects/{init.ProjectId}/subscriptions/{init.SubscriptionName}"; CreateTopicAndSubscriptionOnce(); ClearSubscription(); _shouter = new Shouter(init); }