本文整理汇总了C#中ObservableEventListener.EnableEvents方法的典型用法代码示例。如果您正苦于以下问题:C# ObservableEventListener.EnableEvents方法的具体用法?C# ObservableEventListener.EnableEvents怎么用?C# ObservableEventListener.EnableEvents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObservableEventListener
的用法示例。
在下文中一共展示了ObservableEventListener.EnableEvents方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
// optimizing IOCP performance
int minWorkerThreads;
int minCompletionPortThreads;
ThreadPool.GetMinThreads(out minWorkerThreads, out minCompletionPortThreads);
ThreadPool.SetMinThreads(minWorkerThreads, Math.Max(16, minCompletionPortThreads));
int threadCount = Environment.ProcessorCount;
if (args.Length > 0)
{
threadCount = int.Parse(args[0]);
}
var eventListener = new ObservableEventListener();
eventListener.LogToConsole();
eventListener.EnableEvents(BootstrapperEventSource.Log, EventLevel.Verbose);
eventListener.EnableEvents(MqttIotHubAdapterEventSource.Log, EventLevel.Verbose);
eventListener.EnableEvents(DefaultEventSource.Log, EventLevel.Verbose);
try
{
var cts = new CancellationTokenSource();
var certificate = new X509Certificate2("protocol-gateway.contoso.com.pfx", "password");
var settingsProvider = new AppConfigSettingsProvider();
BlobSessionStatePersistenceProvider blobSessionStateProvider = BlobSessionStatePersistenceProvider.CreateAsync(
settingsProvider.GetSetting("BlobSessionStatePersistenceProvider.StorageConnectionString"),
settingsProvider.GetSetting("BlobSessionStatePersistenceProvider.StorageContainerName")).Result;
TableQos2StatePersistenceProvider tableQos2StateProvider = TableQos2StatePersistenceProvider.CreateAsync(
settingsProvider.GetSetting("TableQos2StatePersistenceProvider.StorageConnectionString"),
settingsProvider.GetSetting("TableQos2StatePersistenceProvider.StorageTableName")).Result;
var bootstrapper = new Bootstrapper(settingsProvider, blobSessionStateProvider, tableQos2StateProvider);
Task.Run(() => bootstrapper.RunAsync(certificate, threadCount, cts.Token), cts.Token);
while (true)
{
string input = Console.ReadLine();
if (input != null && input.ToLowerInvariant() == "exit")
{
break;
}
}
cts.Cancel();
bootstrapper.CloseCompletion.Wait(TimeSpan.FromSeconds(20));
}
finally
{
eventListener.Dispose();
}
}
示例2: Main
static void Main(string[] args)
{
if (args.Length < 5)
{
Console.WriteLine("Mamemaki.Slab.BigQuery.PlayGround.exe <projectId> <datasetId> <tableId> <serviceAccountEmail> <privateKeyFile>");
return;
}
var projectId = args[0];
var datasetId = args[1];
var tableId = args[2];
var serviceAccountEmail = args[3];
var privateKeyFile = args[4];
var tableSchemaFile = args[5];
using (var listenerConsole = new ObservableEventListener())
using (var listener = new ObservableEventListener())
{
var formatterConsole = new EventTextFormatter(
"+=========================================+");
// Setup listener for debug
listenerConsole.EnableEvents(SemanticLoggingEventSource.Log, EventLevel.LogAlways);
listenerConsole.EnableEvents(BigQuerySinkEventSource.Log, EventLevel.LogAlways);
listenerConsole.LogToConsole(formatterConsole);
// Setup listener for playgrond
listener.EnableEvents(PlayGroundEventSource.Log, EventLevel.LogAlways);
listener.LogToConsole(formatterConsole);
listener.LogToBigQuery(
projectId: projectId,
datasetId: datasetId,
tableId: tableId,
authMethod: "private_key",
serviceAccountEmail: serviceAccountEmail,
privateKeyFile: privateKeyFile,
privateKeyPassphrase: "notasecret",
autoCreateTable: true,
tableSchemaFile: tableSchemaFile,
insertIdFieldName: "%uuid%",
bufferingInterval: TimeSpan.FromSeconds(1),
bufferingCount: 3,
bufferingFlushAllTimeout: Constants.DefaultBufferingFlushAllTimeout,
maxBufferSize: 30000);
PlayGroundEventSource.Log.Trace("start");
InsertRows(3);
Thread.Sleep(1);
InsertRows(3);
PlayGroundEventSource.Log.Trace("end");
}
Console.WriteLine("Press any key to exit");
Console.ReadLine();
}
示例3: ConfigureLogging
private void ConfigureLogging()
{
eventListener = new ObservableEventListener();
eventListener.EnableEvents(SparkEngineEventSource.Log, EventLevel.LogAlways,
Keywords.All);
eventListener.EnableEvents(SparkMongoEventSource.Log, EventLevel.LogAlways,
Keywords.All);
eventListener.EnableEvents(SemanticLoggingEventSource.Log, EventLevel.LogAlways, Keywords.All);
var formatter = new JsonEventTextFormatter(EventTextFormatting.Indented);
eventListener.LogToFlatFile(@"C:\projects\fhir\log\spark.log", formatter);
}
示例4: Main
static void Main(string[] args)
{
Options options = new Options();
CommandLine.Parser.Default.ParseArguments(args, options);
if (!options.ShowingHelp)
{
ObservableEventListener Listener = new ObservableEventListener();
Listener.EnableEvents((EventSource)Harmonize.Instrumentation.Error, EventLevel.LogAlways, Keywords.All);
Listener.EnableEvents((EventSource)Harmonize.Instrumentation.Harmonization, EventLevel.LogAlways, Keywords.All);
//ObservableEventListener harmonyEventListener = new ObservableEventListener();
//harmonyEventListener.EnableEvents((EventSource)With.Harmony.Instrumentation.State, EventLevel.LogAlways, Keywords.All);
//ObservableEventListener owlCommandEventListener = new ObservableEventListener();
//owlCommandEventListener.EnableEvents((EventSource)With.Owl.Intuition.Instrumentation.Command.Endpoint, EventLevel.LogAlways, Keywords.All);
//ObservableEventListener owlPacketEventListener = new ObservableEventListener();
//owlPacketEventListener.EnableEvents((EventSource)With.Owl.Intuition.Instrumentation.Packet.Endpoint, EventLevel.LogAlways, Keywords.All);
//ObservableEventListener owlStateEventListener = new ObservableEventListener();
//owlStateEventListener.EnableEvents((EventSource)With.Owl.Intuition.Instrumentation.State.Machine, EventLevel.LogAlways, Keywords.All);
//ObservableEventListener xmppEventListener = new ObservableEventListener();
//xmppEventListener.EnableEvents((EventSource)With.Harmony.Instrumentation.Xmpp, EventLevel.LogAlways, Keywords.All);
//ObservableEventListener alljoynEventListener = new ObservableEventListener();
//alljoynEventListener.EnableEvents(With.Alljoyn.Instrumentation.Coordinator, EventLevel.LogAlways, Keywords.All);
//ObservableEventListener storeEventListener = new ObservableEventListener();
//storeEventListener.EnableEvents((EventSource)State.Instrumentation.Store, EventLevel.LogAlways, Keywords.All);
//ObservableEventListener messagingEventListener = new ObservableEventListener();
//messagingEventListener.EnableEvents((EventSource)With.Messaging.Instrumentation.Messages, EventLevel.LogAlways, Keywords.All);
options.TraceEvents.Split(',').Select(name => Listener.EnableEvents(name, EventLevel.LogAlways, Keywords.All)).ForEach(Cons.WriteLine);
using (new CompositeDisposable(Listener.LogToConsole()))
{
Client client = new Client(options);
client.Start();
System.Console.WriteLine("Started");
System.Console.WriteLine("Hit Return to stop");
System.Console.ReadLine();
client.Stop();
}
}
}
示例5: UnderReleaseBufferLeak
public void UnderReleaseBufferLeak()
{
ResourceLeakDetector.DetectionLevel preservedLevel = ResourceLeakDetector.Level;
try
{
ResourceLeakDetector.Level = ResourceLeakDetector.DetectionLevel.Paranoid;
var eventListener = new ObservableEventListener();
Mock<IObserver<EventEntry>> logListener = this.mockRepo.Create<IObserver<EventEntry>>();
var eventTextFormatter = new EventTextFormatter();
Func<EventEntry, bool> leakPredicate = y => y.TryFormatAsString(eventTextFormatter).Contains("LEAK");
logListener.Setup(x => x.OnNext(It.Is<EventEntry>(y => leakPredicate(y)))).Verifiable();
logListener.Setup(x => x.OnNext(It.Is<EventEntry>(y => !leakPredicate(y))));
eventListener.Subscribe(logListener.Object);
eventListener.EnableEvents(DefaultEventSource.Log, EventLevel.Verbose);
this.CreateAndForgetBuffer();
GC.Collect();
GC.WaitForPendingFinalizers();
this.mockRepo.Verify();
}
finally
{
ResourceLeakDetector.Level = preservedLevel;
}
}
示例6: TestEventSink
public async Task TestEventSink()
{
var listener = new TcpListener(IPAddress.Loopback, 0);
listener.Start();
int port = ((IPEndPoint)listener.Server.LocalEndPoint).Port;
var slabListener = new ObservableEventListener();
slabListener.Subscribe(new TcpEventSink(IPAddress.Loopback, port,
new ExponentialBackoffTcpReconnectionPolicy(),
new TestEventFormatter()));
var source = TestEventSource.GetInstance();
slabListener.EnableEvents(source, EventLevel.LogAlways, Keywords.All);
var listenerClient = await listener.AcceptTcpClientAsync();
source.Message("Boris", "Meep");
var receiverReader = new StreamReader(listenerClient.GetStream());
var line = await receiverReader.ReadLineAsync();
Assert.Equal(
"EventId=1 EventName=MessageInfo Level=Error \"FormattedMessage=Meep - Boris\" \"message=Boris\" \"caller=Meep\"",
line);
listenerClient.Close();
listener.Stop();
slabListener.Dispose();
}
示例7: EnableLoggingListener
private void EnableLoggingListener()
{
listener = new ObservableEventListener();
listener.LogToWindowsAzureTable("CustomEvents", "DefaultEndpointsProtocol=https;AccountName=musiccloudstorage;AccountKey=...");
//listener.EnableEvents(AuditEvent.Log, EventLevel.LogAlways, Keywords.All);
listener.EnableEvents(ErrorEvent.Log, EventLevel.LogAlways, Keywords.All);
}
示例8: TestExporter
public void TestExporter() {
var listener = new ObservableEventListener();
listener.EnableEvents(TflEventSource.Log, EventLevel.Verbose);
var subscription = listener.LogToConsole(new LegacyLogFormatter());
var file = Path.GetTempFileName();
File.WriteAllText(file, @"t1,t2,t3,t4
Monday,10,1.1,1/1/2014
Tuesday,11,2.2,2/1/2014
Wednesday,12,3.3,3/1/2014
Wednesday,12,3.3,3/1/2014
Thursday,13,4.4,4/1/2014
Friday,14,5.5,5/1/2014
Saturday,15,6.6,6/1/2014");
File.Delete(OUTPUT);
var profile = new Profiler().Profile(file);
new ProfileExporter().Export(profile, OUTPUT);
subscription.Dispose();
listener.DisableEvents(TflEventSource.Log);
listener.Dispose();
Assert.IsTrue(File.Exists(OUTPUT));
}
示例9: Initialize
public override void Initialize()
{
var eventListener = new ObservableEventListener();
eventListener.EnableEvents(
VirtoCommerceEventSource.Log,
EventLevel.LogAlways,
Keywords.All);
var assetsConnection = ConfigurationManager.ConnectionStrings["AssetsConnectionString"];
if (assetsConnection != null)
{
var properties = assetsConnection.ConnectionString.ToDictionary(";", "=");
var provider = properties["provider"];
var assetsConnectionString = properties.ToString(";", "=", "provider");
if (string.Equals(provider, FileSystemBlobProvider.ProviderName, StringComparison.OrdinalIgnoreCase))
{
eventListener.LogToRollingFlatFile("AvaTax.log",
10000,
"hh",
RollFileExistsBehavior.Increment,
RollInterval.Day);
}
else
if (string.Equals(provider, AzureBlobProvider.ProviderName, StringComparison.OrdinalIgnoreCase))
{
eventListener.LogToWindowsAzureTable(
"VirtoCommerce2", assetsConnectionString);
}
}
var settingsManager = _container.Resolve<ISettingsManager>();
var avalaraTax = new AvaTaxSettings(_usernamePropertyName, _passwordPropertyName, _serviceUrlPropertyName, _companyCodePropertyName, _isEnabledPropertyName, _isValidateAddressPropertyName, settingsManager);
_container.RegisterType<AvaTaxController>
(new InjectionConstructor(
avalaraTax));
_container.RegisterInstance<ITaxSettings>(avalaraTax);
//Subscribe to cart changes. Calculate taxes
_container.RegisterType<IObserver<CartChangeEvent>, CalculateCartTaxesObserver>("CalculateCartTaxesObserver");
//Subscribe to order changes. Calculate taxes
_container.RegisterType<IObserver<OrderChangeEvent>, CalculateOrderTaxesObserver>("CalculateOrderTaxesObserver");
//Subscribe to order changes. Calculate taxes
_container.RegisterType<IObserver<OrderChangeEvent>, CancelOrderTaxesObserver>("CancelOrderTaxesObserver");
//Subscribe to order changes. Adjust taxes
_container.RegisterType<IObserver<OrderChangeEvent>, CalculateTaxAdjustmentObserver>("CalculateTaxAdjustmentObserver");
}
示例10: RegisterEFLogger
private static void RegisterEFLogger()
{
var listener = new ObservableEventListener();
listener.EnableEvents(EFLogging.Logger, EventLevel.LogAlways, Keywords.All);
listener.LogToFlatFile("EFSqls.log");
listener.LogToWindowsAzureTable(instanceName: "Protiviti", connectionString: "UseDevelopmentStorage=true",tableAddress:"EFSqls");
}
示例11: RunAsync
async Task RunAsync(CancellationToken cancellationToken)
{
var settingsProvider = new RoleEnvironmentSettingsProvider();
var eventListener = new ObservableEventListener();
eventListener.LogToWindowsAzureTable(RoleEnvironment.CurrentRoleInstance.Id, settingsProvider.GetSetting("BlobSessionStatePersistenceProvider.StorageConnectionString"), bufferingInterval: TimeSpan.FromMinutes(2));
eventListener.EnableEvents(BootstrapperEventSource.Log, EventLevel.Informational);
eventListener.EnableEvents(MqttIotHubAdapterEventSource.Log, EventLevel.Informational);
eventListener.EnableEvents(DefaultEventSource.Log, EventLevel.Informational);
int minWorkerThreads;
int minCompletionPortThreads;
ThreadPool.GetMinThreads(out minWorkerThreads, out minCompletionPortThreads);
ThreadPool.SetMinThreads(minWorkerThreads, Math.Max(16, minCompletionPortThreads));
int threadCount = Environment.ProcessorCount;
BlobSessionStatePersistenceProvider blobSessionStateProvider =
await BlobSessionStatePersistenceProvider.CreateAsync(
settingsProvider.GetSetting("BlobSessionStatePersistenceProvider.StorageConnectionString"),
settingsProvider.GetSetting("BlobSessionStatePersistenceProvider.StorageContainerName"));
TableQos2StatePersistenceProvider tableQos2StateProvider =
await TableQos2StatePersistenceProvider.CreateAsync(
settingsProvider.GetSetting("TableQos2StatePersistenceProvider.StorageConnectionString"),
settingsProvider.GetSetting("TableQos2StatePersistenceProvider.StorageTableName"));
var bootstrapper = new Bootstrapper(
settingsProvider,
blobSessionStateProvider,
tableQos2StateProvider);
X509Certificate2 tlsCertificate = GetTlsCertificate(settingsProvider.GetSetting("TlsCertificateThumbprint"),
StoreName.My, StoreLocation.LocalMachine);
try
{
await bootstrapper.RunAsync(tlsCertificate, threadCount, cancellationToken);
}
catch (Exception ex)
{
Trace.TraceError(ex.ToString());
throw;
}
await bootstrapper.CloseCompletion;
}
示例12: TestBase
/// <summary>
/// Initializes a new instance of the <see cref="TestBase" /> class.
/// </summary>
protected TestBase()
{
var observableEventListener = new ObservableEventListener();
observableEventListener.EnableEvents(ExceptionLoggingEventSource.Log, EventLevel.LogAlways);
observableEventListener.LogToConsole();
}
示例13: RegisterLogger
private static void RegisterLogger()
{
var listener = new ObservableEventListener();
listener.EnableEvents(WebApiTracing.Log, EventLevel.LogAlways, Keywords.All);
listener.LogToConsole();
listener.LogToFlatFile("test.log");
listener.LogToWindowsAzureTable(instanceName: "Protiviti", connectionString: "UseDevelopmentStorage=true");
}
示例14: LogViewModel
public LogViewModel()
{
LoggedItems = new ObservableCollection<string>();
EventListener = new ObservableEventListener();
EventListener.EnableEvents(Logger.Write, EventLevel.Verbose);
_syncContext = SynchronizationContext.Current;
EventListener.LogToCollection(PublishLogItem);
// Can only be called on the dispatcher's thread.
}
示例15: Given
protected override void Given()
{
ColorMapper = new MockDefaultConsoleColorMapper();
MockConsole = new MockConsoleOutput();
Formatter = new EventTextFormatter(EventTextFormatter.DashSeparator) { VerbosityThreshold = EventLevel.Informational };
Listener = new ObservableEventListener();
Listener.LogToConsole(Formatter, ColorMapper);
Listener.EnableEvents(TestEventSource.Log, EventLevel.LogAlways);
}